1 package com
.google
.appengine
.api
.datastore
;
3 import com
.google
.apphosting
.datastore
.DatastoreV4
.ContinueQueryRequest
;
4 import com
.google
.apphosting
.datastore
.DatastoreV4
.ContinueQueryResponse
;
5 import com
.google
.apphosting
.datastore
.DatastoreV4
.RunQueryResponse
;
7 import java
.util
.concurrent
.Future
;
10 * V4 service specific code for iterating query results and requesting more results.
11 * Instances can be shared between queries using the same ApiConfig.
13 class QueryResultsSourceV4
extends
14 BaseQueryResultsSource
<RunQueryResponse
, ContinueQueryRequest
, ContinueQueryResponse
> {
16 private final DatastoreV4Proxy datastoreProxy
;
18 QueryResultsSourceV4(DatastoreCallbacks callbacks
, FetchOptions fetchOptions
, Transaction txn
,
19 Query query
, Future
<RunQueryResponse
> runQueryResponse
, DatastoreV4Proxy datastoreProxy
) {
20 super(callbacks
, fetchOptions
, txn
, query
, runQueryResponse
);
21 this.datastoreProxy
= datastoreProxy
;
25 ContinueQueryRequest
buildNextCallPrototype(RunQueryResponse initialResponse
) {
26 return ContinueQueryRequest
.newBuilder()
27 .setQueryHandle(initialResponse
.getQueryHandle())
32 Future
<ContinueQueryResponse
> makeNextCall(ContinueQueryRequest prototype
,
33 WrappedQueryResult queryResult
, Integer fetchCountOrNull
, Integer offsetOrNull
) {
34 return datastoreProxy
.continueQuery(prototype
);
38 WrappedQueryResult
wrapInitialResult(RunQueryResponse initialResponse
) {
39 return new WrappedQueryResultV4(initialResponse
.getBatch());
43 WrappedQueryResult
wrapResult(ContinueQueryResponse res
) {
44 return new WrappedQueryResultV4(res
.getBatch());