Skip to content

Commit 8b6878d

Browse files
author
Achim Brandt
committed
more updates for new cursor API
1 parent 32d53d9 commit 8b6878d

File tree

8 files changed

+407
-178
lines changed

8 files changed

+407
-178
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ E.g. get all Simpsons aged 3 or older in ascending order:
238238
Map<String, Object> bindVars = new MapBuilder().put("age", 3).get();
239239

240240
DocumentCursor<MyObject> documentCursor = arangoDriver.executeDocumentQuery(
241-
query, bindVars, MyObject.class, true, 20
242-
);
241+
query, bindVars, driver.getDefaultAqlQueryOptions(), MyObject.class);
243242

244243
while (DocumentEntity<MyObject> documentEntity : documentCursor.asList()) {
245244
MyObject obj = documentEntity.getEntity();

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4743,8 +4743,8 @@ public <T> EdgeEntity<T> graphCreateEdge(
47434743
String toHandle,
47444744
T value,
47454745
Boolean waitForSync) throws ArangoException {
4746-
return graphDriver.createEdge(getDefaultDatabase(), graphName, edgeCollectionName, fromHandle, toHandle, value,
4747-
waitForSync);
4746+
return graphDriver.createEdge(getDefaultDatabase(), graphName, edgeCollectionName, null, fromHandle, toHandle,
4747+
value, waitForSync);
47484748
}
47494749

47504750
/**
@@ -5345,7 +5345,8 @@ public <T> EdgeCursor<T> graphGetShortesPath(
53455345

53465346
String query = "for i in graph_shortest_path(@graphName, @startVertexExample, @endVertexExample, @options) return i";
53475347

5348-
Map<String, Object> options = shortestPathOptions == null ? null : shortestPathOptions.toMap();
5348+
Map<String, Object> options = shortestPathOptions == null ? new MapBuilder().get() : shortestPathOptions
5349+
.toMap();
53495350

53505351
Map<String, Object> bindVars = new MapBuilder().put("graphName", graphName)
53515352
.put("startVertexExample", startVertexExample).put("endVertexExample", endVertexExample)

src/main/java/com/arangodb/InternalGraphDriver.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -338,28 +338,6 @@ DeletedEntity deleteVertex(
338338
Long ifMatchRevision,
339339
Long ifNoneMatchRevision) throws ArangoException;
340340

341-
/**
342-
*
343-
*
344-
* @param database
345-
* @param graphName
346-
* @param edgeCollectionName
347-
* @param fromHandle
348-
* @param toHandle
349-
* @param value
350-
* @param waitForSync
351-
* @return <T> EdgeEntity<T>
352-
* @throws ArangoException
353-
*/
354-
<T> EdgeEntity<T> createEdge(
355-
String database,
356-
String graphName,
357-
String edgeCollectionName,
358-
String fromHandle,
359-
String toHandle,
360-
T value,
361-
Boolean waitForSync) throws ArangoException;
362-
363341
/**
364342
*
365343
*

src/main/java/com/arangodb/entity/CollectionOptions.java

Lines changed: 139 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -6,134 +6,147 @@
66
*
77
* Convenience object for collection creation.
88
*
9-
* @see com.arangodb.entity.CollectionEntity
10-
* author fbartels - f.bartels@triagens.de
9+
* @see com.arangodb.entity.CollectionEntity author fbartels -
10+
* f.bartels@triagens.de
1111
*/
1212
public class CollectionOptions {
1313

14-
/**
15-
* If true each write operation is synchronised to disk before the server sends a response
16-
*/
17-
private Boolean waitForSync;
18-
19-
/**
20-
* Whether or not the collection will be compacted.
21-
*/
22-
private Boolean doCompact;
23-
24-
/**
25-
* The maximal size setting for journals / datafiles.
26-
*/
27-
private Integer journalSize;
28-
29-
/**
30-
* If true the collection is a system collection
31-
*/
32-
private Boolean isSystem;
33-
34-
/**
35-
* If true then the collection data will be kept in memory only and ArangoDB will not write or sync the data to disk.
36-
*/
37-
private Boolean isVolatile;
38-
39-
/**
40-
* The collections type, either EDGE or DOCUMENT
41-
*/
42-
private CollectionType type;
43-
44-
/**
45-
* The collection key options
46-
* @see com.arangodb.entity.CollectionKeyOption
47-
*/
48-
private CollectionKeyOption keyOptions;
49-
50-
/**
51-
* in a cluster, this value determines the number of shards to create for the collection. In a single server setup,
52-
* this option is meaningless.
53-
*/
54-
private int numberOfShards;
55-
56-
/**
57-
* in a cluster, this attribute determines which document attributes are used to determine the target shard for
58-
* documents. Documents are sent to shards based on the values of their shard key attributes. The values of all
59-
* shard key attributes in a document are hashed, and the hash value is used to determine the target shard.
60-
*/
61-
private List<String> shardKeys;
62-
63-
64-
public CollectionOptions() {
65-
}
66-
67-
public Boolean getWaitForSync() {
68-
return waitForSync;
69-
}
70-
71-
public void setWaitForSync(Boolean waitForSync) {
72-
this.waitForSync = waitForSync;
73-
}
74-
75-
public Boolean getDoCompact() {
76-
return doCompact;
77-
}
78-
79-
public void setDoCompact(Boolean doCompact) {
80-
this.doCompact = doCompact;
81-
}
82-
83-
public Integer getJournalSize() {
84-
return journalSize;
85-
}
86-
87-
public void setJournalSize(Integer journalSize) {
88-
this.journalSize = journalSize;
89-
}
90-
91-
public Boolean getIsSystem() {
92-
return isSystem;
93-
}
94-
95-
public void setIsSystem(Boolean isSystem) {
96-
this.isSystem = isSystem;
97-
}
98-
99-
public Boolean getIsVolatile() {
100-
return isVolatile;
101-
}
102-
103-
public void setIsVolatile(Boolean isVolatile) {
104-
this.isVolatile = isVolatile;
105-
}
106-
107-
public CollectionType getType() {
108-
return type;
109-
}
110-
111-
public void setType(CollectionType type) {
112-
this.type = type;
113-
}
114-
115-
public CollectionKeyOption getKeyOptions() {
116-
return keyOptions;
117-
}
118-
119-
public void setKeyOptions(CollectionKeyOption keyOptions) {
120-
this.keyOptions = keyOptions;
121-
}
122-
123-
public int getNumberOfShards() {
124-
return numberOfShards;
125-
}
126-
127-
public void setNumberOfShards(int numberOfShards) {
128-
this.numberOfShards = numberOfShards;
129-
}
130-
131-
public List<String> getShardKeys() {
132-
return shardKeys;
133-
}
134-
135-
public void setShardKeys(List<String> shardKeys) {
136-
this.shardKeys = shardKeys;
137-
}
14+
/**
15+
* If true each write operation is synchronised to disk before the server
16+
* sends a response
17+
*/
18+
private Boolean waitForSync;
19+
20+
/**
21+
* Whether or not the collection will be compacted.
22+
*/
23+
private Boolean doCompact;
24+
25+
/**
26+
* The maximal size setting for journals / datafiles.
27+
*/
28+
private Integer journalSize;
29+
30+
/**
31+
* If true the collection is a system collection
32+
*/
33+
private Boolean isSystem;
34+
35+
/**
36+
* If true then the collection data will be kept in memory only and ArangoDB
37+
* will not write or sync the data to disk.
38+
*/
39+
private Boolean isVolatile;
40+
41+
/**
42+
* The collections type, either EDGE or DOCUMENT
43+
*/
44+
private CollectionType type;
45+
46+
/**
47+
* The collection key options
48+
*
49+
* @see com.arangodb.entity.CollectionKeyOption
50+
*/
51+
private CollectionKeyOption keyOptions;
52+
53+
/**
54+
* in a cluster, this value determines the number of shards to create for
55+
* the collection. In a single server setup, this option is meaningless.
56+
*/
57+
private int numberOfShards;
58+
59+
/**
60+
* in a cluster, this attribute determines which document attributes are
61+
* used to determine the target shard for documents. Documents are sent to
62+
* shards based on the values of their shard key attributes. The values of
63+
* all shard key attributes in a document are hashed, and the hash value is
64+
* used to determine the target shard.
65+
*/
66+
private List<String> shardKeys;
67+
68+
public CollectionOptions() {
69+
}
70+
71+
public Boolean getWaitForSync() {
72+
return waitForSync;
73+
}
74+
75+
public CollectionOptions setWaitForSync(Boolean waitForSync) {
76+
this.waitForSync = waitForSync;
77+
return this;
78+
}
79+
80+
public Boolean getDoCompact() {
81+
return doCompact;
82+
}
83+
84+
public CollectionOptions setDoCompact(Boolean doCompact) {
85+
this.doCompact = doCompact;
86+
return this;
87+
}
88+
89+
public Integer getJournalSize() {
90+
return journalSize;
91+
}
92+
93+
public CollectionOptions setJournalSize(Integer journalSize) {
94+
this.journalSize = journalSize;
95+
return this;
96+
}
97+
98+
public Boolean getIsSystem() {
99+
return isSystem;
100+
}
101+
102+
public CollectionOptions setIsSystem(Boolean isSystem) {
103+
this.isSystem = isSystem;
104+
return this;
105+
}
106+
107+
public Boolean getIsVolatile() {
108+
return isVolatile;
109+
}
110+
111+
public CollectionOptions setIsVolatile(Boolean isVolatile) {
112+
this.isVolatile = isVolatile;
113+
return this;
114+
}
115+
116+
public CollectionType getType() {
117+
return type;
118+
}
119+
120+
public CollectionOptions setType(CollectionType type) {
121+
this.type = type;
122+
return this;
123+
}
124+
125+
public CollectionKeyOption getKeyOptions() {
126+
return keyOptions;
127+
}
128+
129+
public CollectionOptions setKeyOptions(CollectionKeyOption keyOptions) {
130+
this.keyOptions = keyOptions;
131+
return this;
132+
}
133+
134+
public int getNumberOfShards() {
135+
return numberOfShards;
136+
}
137+
138+
public CollectionOptions setNumberOfShards(int numberOfShards) {
139+
this.numberOfShards = numberOfShards;
140+
return this;
141+
}
142+
143+
public List<String> getShardKeys() {
144+
return shardKeys;
145+
}
146+
147+
public CollectionOptions setShardKeys(List<String> shardKeys) {
148+
this.shardKeys = shardKeys;
149+
return this;
150+
}
138151

139152
}
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.arangodb.entity;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
public class EdgeDefinitionEntity {
@@ -8,27 +9,35 @@ public class EdgeDefinitionEntity {
89
List<String> from;
910
List<String> to;
1011

12+
public EdgeDefinitionEntity() {
13+
this.from = new ArrayList<String>();
14+
this.to = new ArrayList<String>();
15+
}
16+
1117
public String getCollection() {
1218
return collection;
1319
}
1420

15-
public void setCollection(String collection) {
21+
public EdgeDefinitionEntity setCollection(String collection) {
1622
this.collection = collection;
23+
return this;
1724
}
1825

1926
public List<String> getFrom() {
2027
return from;
2128
}
2229

23-
public void setFrom(List<String> from) {
30+
public EdgeDefinitionEntity setFrom(List<String> from) {
2431
this.from = from;
32+
return this;
2533
}
2634

2735
public List<String> getTo() {
2836
return to;
2937
}
3038

31-
public void setTo(List<String> to) {
39+
public EdgeDefinitionEntity setTo(List<String> to) {
3240
this.to = to;
41+
return this;
3342
}
3443
}

src/main/java/com/arangodb/impl/InternalGraphDriverImpl.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,6 @@ public DeletedEntity deleteVertex(
418418
return createEntity(res, DeletedEntity.class);
419419
}
420420

421-
@Override
422-
public <T> EdgeEntity<T> createEdge(
423-
String database,
424-
String graphName,
425-
String edgeCollectionName,
426-
String fromHandle,
427-
String toHandle,
428-
T value,
429-
Boolean waitForSync) throws ArangoException {
430-
return this.createEdge(database, graphName, edgeCollectionName, null, fromHandle, toHandle, value, waitForSync);
431-
432-
}
433-
434421
@Override
435422
public <T> EdgeEntity<T> createEdge(
436423
String database,

0 commit comments

Comments
 (0)