Skip to content

Commit 5cea3d2

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 3783 b: refs/heads/pubsub-alpha c: 35ea69a h: refs/heads/master i: 3781: f8eddf5 3779: 25fcc24 3775: 862e1eb
1 parent 68f34bf commit 5cea3d2

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: 0c2f9e93ffb78aadb55c3abf558e47c616336c18
5+
refs/heads/pubsub-alpha: 35ea69a5a4102de920f7732b52e29ebc8372d974
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/QueryResultsImpl.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class QueryResultsImpl<T> extends AbstractIterator<T> implements QueryResults<T>
3434
private Query<T> query;
3535
private ResultType<?> actualResultType;
3636
private com.google.datastore.v1beta3.QueryResultBatch queryResultBatchPb;
37+
private com.google.datastore.v1beta3.Query mostRecentQueryPb;
3738
private boolean lastBatch;
3839
private Iterator<com.google.datastore.v1beta3.EntityResult> entityResultPbIter;
3940
private ByteString cursor;
@@ -58,7 +59,7 @@ class QueryResultsImpl<T> extends AbstractIterator<T> implements QueryResults<T>
5859
if (queryResultBatchPb.getSkippedResults() > 0) {
5960
cursor = queryResultBatchPb.getSkippedCursor();
6061
} else {
61-
cursor = ByteString.EMPTY;
62+
cursor = mostRecentQueryPb.getStartCursor();
6263
}
6364
}
6465

@@ -70,7 +71,13 @@ private void sendRequest() {
7071
}
7172
requestPb.setPartitionId(partitionIdPb);
7273
query.populatePb(requestPb);
73-
queryResultBatchPb = datastore.runQuery(requestPb.build()).getBatch();
74+
com.google.datastore.v1beta3.RunQueryResponse runQueryResponsePb =
75+
datastore.runQuery(requestPb.build());
76+
queryResultBatchPb = runQueryResponsePb.getBatch();
77+
mostRecentQueryPb = runQueryResponsePb.getQuery();
78+
if (mostRecentQueryPb == null) {
79+
mostRecentQueryPb = requestPb.getQuery();
80+
}
7481
lastBatch = queryResultBatchPb.getMoreResults() != MoreResultsType.NOT_FINISHED;
7582
entityResultPbIter = queryResultBatchPb.getEntityResultsList().iterator();
7683
actualResultType = ResultType.fromPb(queryResultBatchPb.getEntityResultType());

0 commit comments

Comments
 (0)