Skip to content

Commit f5e46d2

Browse files
committed
Merge branch 'release/2.0.0' into develop
2 parents d3b520e + dce300d commit f5e46d2

14 files changed

+329
-125
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ target
1616
old/
1717

1818
tikerpopTests\.log
19+
20+
ArangoDBGraphTest*

README.md

+101-23
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,122 @@ An implementation of the [Apache TinkerPop OLTP Provider](https://tinkerpop.apac
88

99
This Provider supports:
1010
* Apache TinkerPop 3.3
11-
* ArangoDB 3.3 (via ArangoDB Java Driver 4.6.0).
11+
* ArangoDB 3.3 (via ArangoDB Java Driver 5.0.0).
1212

13-
## Installation & Testing
13+
## ArangoDB
1414

15-
Please check the
16-
[ArangoDB Installation Manual](https://docs.arangodb.com/latest/Manual/Deployment/)
17-
for installation and compilation instructions.
18-
19-
Start ArangoDB on localhost port 8529.
20-
21-
The ArangoDB Provider implementation can be built locally via
22-
```
23-
mvn clean install -Dmaven.tests.skip=true -Dgpg.skip=true
24-
```
25-
26-
**Note** that we skip tests since not ALL TinkerPop tests pass (failing ones are known to fail - there
27-
are some issues/discrepancies between the tests and how the ArangoDB provider is implemented).
15+
Please check the
16+
[ArangoDB Installation Manual](https://docs.arangodb.com/latest/Manual/Deployment/) for guides on how to install ArangoDB.
2817

2918
## Maven
3019

31-
To add the driver to your project with maven, add the following code to your pom.xml
32-
(please use a driver with a version number compatible to your ArangoDB server's version):
20+
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)
3321

3422
```XML
3523
<dependencies>
3624
<dependency>
3725
<groupId>org.arangodb</groupId>
3826
<artifactId>arangodb-tinkerpop-provider</artifactId>
39-
<version>2.0.0-SNAPSHOT</version>
27+
<version>2.0.0</version>
4028
</dependency>
41-
....
29+
....
4230
</dependencies>
4331
```
4432

45-
## More
33+
The same coordinates can be used with Gradle and any other build system that uses maven repositories.
34+
35+
36+
## Using ArangoDBGraph via the TinkerPop API
37+
This example is based on the TinkerPop documentation ([Creating a graph](http://tinkerpop.apache.org/docs/3.3.3/tutorials/getting-started/#_creating_a_graph)):
38+
39+
```java
40+
ArangoDBConfigurationBuilder builder = new ArangoDBConfigurationBuilder();
41+
builder.graph("modern")
42+
.withVertexCollection("software")
43+
.withVertexCollection("person")
44+
.withEdgeCollection("knows")
45+
.withEdgeCollection("created")
46+
.configureEdge("knows", "person", "person")
47+
.configureEdge("created", "person", "software");
48+
49+
// use the default database (and user:password) or configure a different database
50+
// builder.arangoHosts("172.168.1.10:4456")
51+
// .arangoUser("stripe")
52+
// .arangoPassword("gizmo")
53+
54+
// create a ArangoDB graph
55+
BaseConfiguration conf = builder.build();
56+
Graph graph = GraphFactory.open(conf);
57+
GraphTraversalSource gts = new GraphTraversalSource(graph);
58+
59+
// Clone to avoid setup time
60+
GraphTraversalSource g = gts.clone();
61+
// Add vertices
62+
Vertex v1 = g.addV("person").property(T.id, 1).property("name", "marko")
63+
.property("age", 29).next();
64+
g = gts.clone();
65+
Vertex v2 = g.addV("software").property(T.id, 3).property("name", "lop")
66+
.property("lang", "java").next();
67+
68+
// Add edges
69+
g = gts.clone();
70+
Edge e1 = g.addEd("created").from(v1).to(v2).property(T.id, 9)
71+
.property("weight", 0.4).next();
72+
73+
// Graph traversal
74+
// Find "marko" in the graph
75+
g = gts.clone();
76+
Vertex rv = g.V().has("name","marko").next();
77+
assert v1 == rv;
78+
79+
// Walk along the "created" edges to "software" vertices
80+
g = gts.clone();
81+
Edge re = g.V().has("name","marko").outE("created").next();
82+
assert re == e1;
83+
84+
g = gts.clone();
85+
rv = g.V().has("name","marko").outE("created").inV().next();
86+
// If the edge is irrelevant
87+
// rv = g.V().has("name","marko").out("created").next();
88+
assert rv == v2;
89+
90+
91+
// Select the "name" property of the "software" vertices
92+
g = gts.clone();
93+
String name = g.V().has("name","marko").out("created").values("name").next();
94+
assert name.equals("lop");
95+
96+
// close the graph
97+
graph.close();
98+
```
99+
100+
## A note on element IDs
101+
102+
The provider inmplementation supports user supplied IDs, that is:
103+
104+
```
105+
Vertex v1 = g.addV("person").property(T.id, 1);
106+
```
46107

47-
You will find details on how to instantiate an ArangoDBGraph in the JavaDocs. A GremlinPlugin
48-
implementation is also provided so the provider can be used from the Gremlin console.
108+
will create a vertex with id "1". However, implementation wise, in ArangoDB we are only allowed to manipulate the documents `key`, not its `id`. For this reason, providing a TinkerPop vertex id (`T.id`) actually sets the vertex's ArangoDB `key`. As a result, retreiving the vertex by the given id will fail:
49109

50-
TBD - Add more detailed installation and use information.
110+
```
111+
Vertex v2 = g.V(1);
112+
assert v2 == null;
113+
```
114+
115+
Since we know that documents IDs are created by concatenating (with a slash) the document's collection and its key, then we can find the vertex like so:
116+
117+
```
118+
Vertex v2 = g.V("person/1");
119+
assert v2 == v1;
120+
```
121+
122+
## Contributing
123+
124+
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.).
125+
126+
127+
## More
51128

129+
Please visit our Wiki for additional information on how to use the latest version, build locally, run tests, etc.

pom.xml

+77-51
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.arangodb</groupId>
88
<artifactId>arangodb-tinkerpop-provider</artifactId>
9-
<version>2.0.0-SNAPSHOT</version>
9+
<version>2.0.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>ArangoDB-TinkerPop-Provider</name>
@@ -54,6 +54,59 @@
5454
<javadoc.opts>-Xdoclint:none</javadoc.opts>
5555
</properties>
5656
</profile>
57+
58+
<profile>
59+
<id>release</id>
60+
<build>
61+
<plugins>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-source-plugin</artifactId>
65+
<version>2.4</version>
66+
<executions>
67+
<execution>
68+
<goals>
69+
<goal>jar</goal>
70+
</goals>
71+
</execution>
72+
</executions>
73+
</plugin>
74+
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-javadoc-plugin</artifactId>
78+
<version>3.0.1</version>
79+
<executions>
80+
<execution>
81+
<id>attach-javadocs</id>
82+
<goals>
83+
<goal>jar</goal>
84+
</goals>
85+
<configuration>
86+
<additionalparam>${javadoc.opts}</additionalparam>
87+
</configuration>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-gpg-plugin</artifactId>
95+
<version>1.5</version>
96+
<executions>
97+
<execution>
98+
<id>sign-artifacts</id>
99+
<phase>verify</phase>
100+
<goals>
101+
<goal>sign</goal>
102+
</goals>
103+
</execution>
104+
</executions>
105+
</plugin>
106+
</plugins>
107+
</build>
108+
</profile>
109+
57110
</profiles>
58111

59112
<build>
@@ -103,75 +156,48 @@
103156
</configuration>
104157
</plugin>
105158

106-
<plugin>
107-
<groupId>org.apache.maven.plugins</groupId>
108-
<artifactId>maven-source-plugin</artifactId>
109-
<version>2.4</version>
110-
<executions>
111-
<execution>
112-
<goals>
113-
<goal>jar</goal>
114-
</goals>
115-
</execution>
116-
</executions>
117-
</plugin>
118159

119-
<plugin>
120-
<groupId>org.apache.maven.plugins</groupId>
121-
<artifactId>maven-javadoc-plugin</artifactId>
122-
<version>3.0.1</version>
123-
<executions>
124-
<execution>
125-
<id>attach-javadocs</id>
126-
<goals>
127-
<goal>jar</goal>
128-
</goals>
129-
<configuration>
130-
<additionalparam>${javadoc.opts}</additionalparam>
131-
</configuration>
132-
</execution>
133-
</executions>
134-
</plugin>
135160

136-
<!-- Not all Gremlin Tests Pass, but its OK -->
137161
<plugin>
138-
<groupId>org.apache.maven.plugins</groupId>
139-
<artifactId>maven-surefire-plugin</artifactId>
140-
<version>2.22.0</version>
162+
<artifactId>maven-deploy-plugin</artifactId>
163+
<version>2.8.2</version>
141164
<configuration>
142-
<skipTests>true</skipTests>
165+
<uniqueVersion>false</uniqueVersion>
166+
<retryFailedDeploymentCount>10</retryFailedDeploymentCount>
167+
<skip>true</skip>
143168
</configuration>
144169
</plugin>
145170

171+
172+
146173
<plugin>
147-
<artifactId>maven-deploy-plugin</artifactId>
148-
<version>2.8.2</version>
174+
<artifactId>maven-scm-plugin</artifactId>
175+
<version>1.8.1</version>
149176
<configuration>
150-
<uniqueVersion>false</uniqueVersion>
151-
<retryFailedDeploymentCount>10</retryFailedDeploymentCount>
177+
<tag>${project.artifactId}-${project.version}</tag>
152178
</configuration>
153179
</plugin>
154180

155181
<plugin>
156-
<groupId>org.apache.maven.plugins</groupId>
157-
<artifactId>maven-gpg-plugin</artifactId>
158-
<version>1.5</version>
159-
<executions>
160-
<execution>
161-
<id>sign-artifacts</id>
162-
<phase>verify</phase>
163-
<goals>
164-
<goal>sign</goal>
165-
</goals>
166-
</execution>
167-
</executions>
182+
<groupId>org.sonatype.plugins</groupId>
183+
<artifactId>nexus-staging-maven-plugin</artifactId>
184+
<version>1.6.7</version>
185+
<extensions>true</extensions>
186+
<configuration>
187+
<serverId>ossrh</serverId>
188+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
189+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
190+
</configuration>
168191
</plugin>
169192
</plugins>
170193
</build>
171194

195+
196+
197+
172198
<properties>
173199
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
174-
<arangodb-java-driver.version>4.6.0</arangodb-java-driver.version>
200+
<arangodb-java-driver.version>5.0.0</arangodb-java-driver.version>
175201
<tinkerpop.version>3.3.3</tinkerpop.version>
176202
<junit.version>4.12</junit.version>
177203
<logback-classic.version>1.1.3</logback-classic.version>

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBBaseDocument.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,5 @@ public boolean isPaired() {
205205
public void setPaired(boolean paired) {
206206
this.paired = paired;
207207
}
208-
209-
@Override
210-
public boolean equals(final Object object) {
211-
if (null == object)
212-
return false;
213-
214-
if (this == object)
215-
return true;
216-
if (!(object instanceof ArangoDBBaseDocument))
217-
return false;
218-
return this._id().equals(((ArangoDBBaseDocument)object)._id());
219-
}
220-
221-
@Override
222-
public int hashCode() {
223-
return _id.hashCode();
224-
}
208+
225209
}

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBGraphClient.java

+6
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ public <T> ArangoCursor<T> getElementProperties(
687687
.ret("v");
688688

689689
String query = queryBuilder.toString();
690+
logger.debug("AQL {}", query);
690691
return executeAqlQuery(query, bindVars, null, propertyType);
691692
}
692693

@@ -725,6 +726,7 @@ public ArangoCursor<ArangoDBVertex> getGraphVertices(
725726
}
726727
queryBuilder.ret("v");
727728
String query = queryBuilder.toString();
729+
logger.debug("AQL {}", query);
728730
return executeAqlQuery(query, bindVars, null, ArangoDBVertex.class);
729731
}
730732

@@ -762,6 +764,7 @@ public ArangoCursor<ArangoDBEdge> getGraphEdges(
762764
}
763765
queryBuilder.ret("e");
764766
String query = queryBuilder.toString();
767+
logger.debug("AQL {}", query);
765768
return executeAqlQuery(query, bindVars, null, ArangoDBEdge.class);
766769
}
767770

@@ -794,6 +797,7 @@ public ArangoCursor<ArangoDBVertex> getEdgeVertices(
794797
.collect(Collectors.joining(",", "[", "]\n")))
795798
.ret("Document(v)");
796799
String query = queryBuilder.toString();
800+
logger.debug("AQL {}", query);
797801
return executeAqlQuery(query, bindVars, null, ArangoDBVertex.class);
798802
}
799803

@@ -810,6 +814,7 @@ public ArangoCursor<String> getGraphVariablesId(String graphName) {
810814
queryBuilder.iterateCollection(graphName, "v", ArangoDBUtil.GRAPH_VARIABLES_COLLECTION, bindVars)
811815
.ret("v._id");
812816
String query = queryBuilder.toString();
817+
logger.debug("AQL {}", query);
813818
return executeAqlQuery(query, bindVars, null, String.class);
814819
}
815820

@@ -831,6 +836,7 @@ public ArangoCursor<ArangoDBGraphVariables> getGraphVariables(
831836
.documentById(id, "v", bindVars)
832837
.ret("v");
833838
String query = queryBuilder.toString();
839+
logger.debug("AQL {}", query);
834840
return executeAqlQuery(query, bindVars, null, ArangoDBGraphVariables.class);
835841
}
836842

0 commit comments

Comments
 (0)