-
-
Notifications
You must be signed in to change notification settings - Fork 16
Configuration
An ArangoDBGraph is instantiated from an Apache Commons Configuration instance. The configuration can be provided programmatically or in a file. The configuration contains two sets of information. One, options relevant to the ArangoDB database as required by the ArangoDB Java Driver (detailed here). Second, options relevant to the graph instance. All settings are prefixed with "gremlin.arangodb.conf" in order to allow the configuration file to hold additional information not relevant to the ArangoDB Tinkerpop Proivder.
The ArangoDB Java Driver configuration options are used simply by appending the appropriate configuration key. For example:
gremlin.arangodb.conf.arangodb.hosts = 127.0.0.1:8529
A graph is made up of vertices and edges. As such, the simplest ArangoDB database would only require a vertex and an edge collection to store a graph. However, Gremlin supports property Graphs, which allows graph elements (vertices and edges) to have a string label denoting the element type. For this, the ArangoDB database would benefit from having separate collections for each of the types. The graph configuration options allows the graph schema (types and allowed relations between types) to be defined.
The configuration must provide as a minimum the database name and the graph name. If no vertex, edge and relation information is provided, the graph will be considered schema-less.
To define the schema, (EdgeCollections in ArangoDB world) three properties are defined:
- graph.vertex
- graph.edge
- graph.relation
The graph.vertex and graph.edge properties allow definition of the ArangoDB collections used to store vertices and edges respectively. The relations property is used to describe the allowed edge-vertices relations. These three properties can appear multiple times.
For simple graphs, only one graph.vertex and graph.edge properties need to be provided. In this case, edges are allowed to connect to vertices of any type. For example:
gremlin.arangodb.conf.graph.vertex = Place
gremlin.arangodb.conf.graph.edge = Transition
would allow the user to create Vertices that represent Places, and Edges that represent Transitions. A transition can be created between any two Places (i.e. graph represents a PetriNet).
In other words, with relation definitions the resulting graph schema would be fully connected, that is, edges would be allowed between any two pair of vertices.
For more complex graph structures, the graph.relation property is used to tell the ArangoDB what relations are allowed. The relation configuration values use the following structure:
edge:from(,from)*->to(,to)*
where edge is the edge type, and from and to are vertex types. Commas can be used to declare multiple from/to types.
The configuration:
gremlin.arangodb.conf.graph.vertex = Place
gremlin.arangodb.conf.graph.vertex = Transition
gremlin.arangodb.conf.graph.edge = PTArc
gremlin.arangodb.conf.graph.edge = TPArc
gremlin.arangodb.conf.graph.relation = PTArc:Place->Transition
gremlin.arangodb.conf.graph.relation = TPArc:Transition->Place
would allow the user to create nodes to represent Places and Transitions, and edges to represent Arcs. However, in this case, we have two type of arcs: PTArc and TPArc. The relations specify that PTArcs can only go from Place to Transitions and TPArcs can only go from Transitions to Places.
A relation can also specify multiple to/from nodes. In this case, the to/from values is a comma separated list of names.
gremlin.arangodb.conf.graph.vertex = male
gremlin.arangodb.conf.graph.vertex = female
gremlin.arangodb.conf.graph.edge = relation
gremlin.arangodb.conf.graph.relation = relation:male,female->male,female
In order to allow multiple graphs in the same database, vertex and edge collections are prefixed with the graph name in order to avoid collection clashes. To disable this behaviour, e.g. in order to use existing collections/graphs, the graph.shouldPrefixCollectionNames property should be set to false
.
The list of allowed settings is:
- graph.db // The name of the database
- graph.name // The name of the graph
- graph.vertex
- graph.edge
- graph.relation
- graph.shouldPrefixCollectionNames
- arangodb.hosts
- arangodb.timeout
- arangodb.user
- arangodb.password
- arangodb.usessl
- arangodb.chunksize
- arangodb.connections.max
- arangodb.protocol
- arangodb.acquireHostList
- arangodb.loadBalancingStrategy
The following is a properties file for connecting to an ArangoDB in the localhost and using the modern graph schema.
gremlin.graph = com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph
gremlin.arangodb.conf.graph.db = tinkerpop
gremlin.arangodb.conf.graph.name = modern
gremlin.arangodb.conf.graph.vertex = person
gremlin.arangodb.conf.graph.vertex = software
gremlin.arangodb.conf.graph.edge = knows
gremlin.arangodb.conf.graph.edge = created
gremlin.arangodb.conf.graph.relation = knows:person->person
gremlin.arangodb.conf.graph.relation = created:person->software
gremlin.arangodb.conf.arangodb.hosts = localhost
gremlin.arangodb.conf.arangodb.user = admin
gremlin.arangodb.conf.arangodb.password = admin123