Skip to content

Commit f0c7769

Browse files
committed
async implementation
1 parent 3b8cd7e commit f0c7769

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/main/java/com/arangodb/async/ArangoDatabaseAsync.java

+15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.arangodb.async;
2222

23+
import com.arangodb.ArangoCursor;
2324
import com.arangodb.ArangoDBException;
2425
import com.arangodb.ArangoSerializationAccessor;
2526
import com.arangodb.DbName;
@@ -331,6 +332,20 @@ <T> CompletableFuture<ArangoCursorAsync<T>> query(
331332
*/
332333
<T> CompletableFuture<ArangoCursorAsync<T>> cursor(final String cursorId, final Class<T> type);
333334

335+
/**
336+
* Return an cursor from the given cursor-ID if still existing
337+
*
338+
* @param cursorId The ID of the cursor
339+
* @param type The type of the result (POJO class, VPackSlice, String for JSON, or Collection/List/Map)
340+
* @param nextBatchId The ID of the next cursor batch (set only if cursor allows retries, see
341+
* {@link AqlQueryOptions#allowRetry(Boolean)}
342+
* @return cursor of the results
343+
* @see <a href= "https://www.arangodb.com/docs/stable/http/aql-query-cursor-accessing-cursors
344+
* .html#read-next-batch-from-cursor">API Documentation</a>
345+
* @since ArangoDB 3.11
346+
*/
347+
<T> CompletableFuture<ArangoCursorAsync<T>> cursor(String cursorId, Class<T> type, String nextBatchId);
348+
334349
/**
335350
* Explain an AQL query and return information about it
336351
*

src/main/java/com/arangodb/async/internal/ArangoDatabaseAsyncImpl.java

+11
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ public <T> CompletableFuture<ArangoCursorAsync<T>> cursor(final String cursorId,
223223
return execution.thenApply(result -> createCursor(result, type, null, hostHandle));
224224
}
225225

226+
@Override
227+
public <T> CompletableFuture<ArangoCursorAsync<T>> cursor(final String cursorId, final Class<T> type,
228+
final String nextBatchId) {
229+
final HostHandle hostHandle = new HostHandle();
230+
final CompletableFuture<CursorEntity> execution = executor.execute(queryNextByBatchIdRequest(cursorId,
231+
nextBatchId, null,
232+
null),
233+
CursorEntity.class, hostHandle);
234+
return execution.thenApply(result -> createCursor(result, type, null, hostHandle));
235+
}
236+
226237
private <T> ArangoCursorAsync<T> createCursor(
227238
final CursorEntity result,
228239
final Class<T> type,

0 commit comments

Comments
 (0)