Skip to content

Instantly share code, notes, and snippets.

@bshambaugh
Created April 7, 2018 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bshambaugh/5369a5dafd1f2991871a1969ad2b69e2 to your computer and use it in GitHub Desktop.
Save bshambaugh/5369a5dafd1f2991871a1969ad2b69e2 to your computer and use it in GitHub Desktop.
for some reason the edges are missing in the postgresql table...
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.Scope;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.umlg.sqlg.predicate.Text;
import org.umlg.sqlg.structure.SqlgGraph;
import java.util.Iterator;
import java.util.List;
public class GremlinJenaTest21 {
public static void main(String[] arg) {
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("jdbc.url", "jdbc:postgresql://localhost:5432/sqlgraphdb");
conf.setProperty("jdbc.username", "batman");
conf.setProperty("jdbc.password", "password");
Graph g = SqlgGraph.open(conf);
Vertex lop = g.addVertex(T.label,"Software","name","lop","lang","java");
Vertex ripple = g.addVertex(T.label,"Software","name","ripple","lang","java");
Vertex marko = g.addVertex(T.label,"Person","name","marko","age",29);
Vertex vadas = g.addVertex(T.label,"Person","name","vadas","age",27);
Vertex josh = g.addVertex(T.label,"Person","name","josh","age",32);
Vertex peter = g.addVertex(T.label,"Person","name","peter","age",35);
// I added this for multiple filter conditions
Vertex joshtwo = g.addVertex(T.label,"Person","name","josh","age",35);
// These edges do not appear in my postgresql table
marko.addEdge("created",lop,"weight",0.4);
marko.addEdge("knows",vadas,"weight",0.5);
marko.addEdge("knows",josh,"weight",0.5);
peter.addEdge("created",lop,"weight",0.2);
josh.addEdge("created",lop,"weight",0.4);
josh.addEdge("created",ripple,"weight",0.1);
// I added this for multiple filter conditions
joshtwo.addEdge("created",lop,"weight",0.4);
g.tx().commit();
List persons = g.traversal().V().hasLabel("Person").group().by("name").by(__.values("age").sum()).toList();
System.out.println(persons);
try {
g.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment