Search in sources :

Example 1 with NextRequest

use of com.google.apphosting.datastore.DatastoreV3Pb.NextRequest in project appengine-java-standard by GoogleCloudPlatform.

the class RemoteApiServlet method executeRunQuery.

private byte[] executeRunQuery(Request request) {
    Query queryRequest = new Query();
    parseFromBytes(queryRequest, request.getRequestAsBytes());
    int batchSize = Math.max(1000, queryRequest.getLimit());
    queryRequest.setCount(batchSize);
    QueryResult runQueryResponse = new QueryResult();
    byte[] res = ApiProxy.makeSyncCall("datastore_v3", "RunQuery", request.getRequestAsBytes());
    parseFromBytes(runQueryResponse, res);
    if (queryRequest.hasLimit()) {
        // Try to pull all results
        while (runQueryResponse.isMoreResults()) {
            NextRequest nextRequest = new NextRequest();
            nextRequest.getMutableCursor().mergeFrom(runQueryResponse.getCursor());
            nextRequest.setCount(batchSize);
            byte[] nextRes = ApiProxy.makeSyncCall("datastore_v3", "Next", nextRequest.toByteArray());
            parseFromBytes(runQueryResponse, nextRes);
        }
    }
    return runQueryResponse.toByteArray();
}
Also used : QueryResult(com.google.apphosting.datastore.DatastoreV3Pb.QueryResult) Query(com.google.apphosting.datastore.DatastoreV3Pb.Query) NextRequest(com.google.apphosting.datastore.DatastoreV3Pb.NextRequest)

Example 2 with NextRequest

use of com.google.apphosting.datastore.DatastoreV3Pb.NextRequest in project appengine-java-standard by GoogleCloudPlatform.

the class QueryResultsSourceV3 method buildNextCallPrototype.

@Override
public NextRequest buildNextCallPrototype(QueryResult initialResult) {
    DatastoreV3Pb.NextRequest req = new DatastoreV3Pb.NextRequest();
    req.setCursor(initialResult.getCursor());
    if (initialResult.hasCompiledCursor()) {
        // Compiled cursor setting should match original query.
        req.setCompile(true);
    }
    // This used to call .freeze() but that method has been deleted, see go/javaproto1freezeremoval
    return req;
}
Also used : NextRequest(com.google.apphosting.datastore.DatastoreV3Pb.NextRequest) NextRequest(com.google.apphosting.datastore.DatastoreV3Pb.NextRequest) DatastoreV3Pb(com.google.apphosting.datastore.DatastoreV3Pb)

Aggregations

NextRequest (com.google.apphosting.datastore.DatastoreV3Pb.NextRequest)2 DatastoreV3Pb (com.google.apphosting.datastore.DatastoreV3Pb)1 Query (com.google.apphosting.datastore.DatastoreV3Pb.Query)1 QueryResult (com.google.apphosting.datastore.DatastoreV3Pb.QueryResult)1