Skip to content

Instantly share code, notes, and snippets.

@bshambaugh
Created April 5, 2018 21:39
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/59c09224bc993ed93947d07f2894f838 to your computer and use it in GitHub Desktop.
Save bshambaugh/59c09224bc993ed93947d07f2894f838 to your computer and use it in GitHub Desktop.
Gremlin Jena Test ....
import org.apache.commons.configuration.BaseConfiguration;
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.structure.SqlgGraph;
import java.util.Iterator;
import java.util.List;
public class GremlinJenaTest2 {
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);
g.addVertex(T.label, "A", "name", "halo");
g.tx().commit();
List<Vertex> vertices = g.traversal().V().hasLabel("A").toList();
System.out.println(vertices.size());
for(Vertex anObject : vertices){
System.out.println(anObject.label());
}
try {
g.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@bshambaugh
Copy link
Author

How does this compare to http://sql2gremlin.com/ ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment