You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To add the provider to your project via maven you need to add the following dependency (shown is the latest version - you can replace the version with the one you need)
The same coordinates can be used with Gradle and any other build system that uses maven repositories.
Using ArangoDBGraph via the TinkerPop API
This example is based on the TinkerPop documentation (Creating a graph):
ArangoDBConfigurationBuilderbuilder = newArangoDBConfigurationBuilder();
builder.graph("modern")
.withVertexCollection("software")
.withVertexCollection("person")
.withEdgeCollection("knows")
.withEdgeCollection("created")
.configureEdge("knows", "person", "person")
.configureEdge("created", "person", "software");
// use the default database (and user:password) or configure a different database// builder.arangoHosts("172.168.1.10:4456")// .arangoUser("stripe")// .arangoPassword("gizmo")// create a ArangoDB graphBaseConfigurationconf = builder.build();
Graphgraph = GraphFactory.open(conf);
GraphTraversalSourcegts = newGraphTraversalSource(graph);
// Clone to avoid setup timeGraphTraversalSourceg = gts.clone();
// Add verticesVertexv1 = g.addV("person").property(T.id, "1").property("name", "marko")
.property("age", 29).next();
g = gts.clone();
Vertexv2 = g.addV("software").property(T.id, "3").property("name", "lop")
.property("lang", "java").next();
// Add edgesg = gts.clone();
Edgee1 = g.addE("created").from(v1).to(v2).property(T.id, "9")
.property("weight", 0.4).next();
// Graph traversal // Find "marko" in the graphg = gts.clone();
Vertexrv = g.V().has("name","marko").next();
assertv1 == rv;
// Walk along the "created" edges to "software" verticesg = gts.clone();
Edgere = g.V().has("name","marko").outE("created").next();
assertre == e1;
g = gts.clone();
rv = g.V().has("name","marko").outE("created").inV().next();
// If the edge is irrelevant// rv = g.V().has("name","marko").out("created").next();assertrv == v2;
// Select the "name" property of the "software" verticesg = gts.clone();
Stringname = (String) g.V().has("name","marko").out("created").values("name").next();
assertname.equals("lop");
// close the graph and the traversal sourcegts.close();
graph.close();
A note on element IDs
The provider implementation supports user supplied IDs, i.e. provide an id property for graph
elements, but currently we only support String ids, that is:
Vertex v1 = g.addV("person").property(T.id, "1");
will create a vertex with id "1". However, implementation wise, in ArangoDB we are only allowed to manipulate the documents name, not its id. For this reason, providing a TinkerPop vertex id (T.id) actually sets the vertex's ArangoDB name. As a result, retrieving the vertex by the given id will fail:
Vertex v2 = g.V("1");
assert v2 == null;
Since we know that documents IDs are created by concatenating (with a slash) the document's collection and its name, then we can find the vertex like so:
Vertex v2 = g.V("person/1");
assert v2 == v1;
Contributing
We welcome bug reports (bugs, feature requests, etc.) as well as patches. When reporting a bug try to include as much information as possible (expected behaviour, seen behaviour, steps to reproduce, etc.).
More
Please visit our Wiki for additional information on how to use the latest version, build locally, run tests, etc.
About
An implementation of the Tinkerpop OLTP Provider for ArangoDB