/** * * * <pre> * A cursor that points to the position after the last result in the batch. * </pre> * * <code>bytes end_cursor = 4;</code> */ public Builder clearEndCursor() { endCursor_ = getDefaultInstance().getEndCursor(); onChanged(); return this; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.QueryResultBatch)) { return super.equals(obj); } com.google.datastore.v1.QueryResultBatch other = (com.google.datastore.v1.QueryResultBatch) obj; boolean result = true; result = result && (getSkippedResults() == other.getSkippedResults()); result = result && getSkippedCursor().equals(other.getSkippedCursor()); result = result && entityResultType_ == other.entityResultType_; result = result && getEntityResultsList().equals(other.getEntityResultsList()); result = result && getEndCursor().equals(other.getEndCursor()); result = result && moreResults_ == other.moreResults_; result = result && (getSnapshotVersion() == other.getSnapshotVersion()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SKIPPED_RESULTS_FIELD_NUMBER; hash = (53 * hash) + getSkippedResults(); hash = (37 * hash) + SKIPPED_CURSOR_FIELD_NUMBER; hash = (53 * hash) + getSkippedCursor().hashCode(); hash = (37 * hash) + ENTITY_RESULT_TYPE_FIELD_NUMBER; hash = (53 * hash) + entityResultType_; if (getEntityResultsCount() > 0) { hash = (37 * hash) + ENTITY_RESULTS_FIELD_NUMBER; hash = (53 * hash) + getEntityResultsList().hashCode(); } hash = (37 * hash) + END_CURSOR_FIELD_NUMBER; hash = (53 * hash) + getEndCursor().hashCode(); hash = (37 * hash) + MORE_RESULTS_FIELD_NUMBER; hash = (53 * hash) + moreResults_; hash = (37 * hash) + SNAPSHOT_VERSION_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSnapshotVersion()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Override protected T computeNext() { while (!entityResultPbIter.hasNext() && !lastBatch) { query = query.nextQuery(runQueryResponsePb); sendRequest(); } if (!entityResultPbIter.hasNext()) { cursor = runQueryResponsePb.getBatch().getEndCursor(); return endOfData(); } com.google.datastore.v1.EntityResult entityResultPb = entityResultPbIter.next(); cursor = entityResultPb.getCursor(); @SuppressWarnings("unchecked") T result = (T) actualResultType.convert(entityResultPb.getEntity()); return result; }
if (other.getEndCursor() != com.google.protobuf.ByteString.EMPTY) { setEndCursor(other.getEndCursor());
@Override StructuredQuery<V> nextQuery(com.google.datastore.v1.RunQueryResponse responsePb) { Builder<V> builder = toBuilder(); builder.setStartCursor(new Cursor(responsePb.getBatch().getEndCursor())); if (offset > 0 && responsePb.getBatch().getSkippedResults() < offset) { builder.setOffset(offset - responsePb.getBatch().getSkippedResults()); } else { builder.setOffset(0); if (limit != null) { builder.setLimit(limit - responsePb.getBatch().getEntityResultsCount()); } } return builder.build(); }
.andReturn(response); if (response.getBatch().getMoreResults() != QueryResultBatch.MoreResultsType.NOT_FINISHED) { endCursors.add(response.getBatch().getEndCursor());
/** * <pre> * A cursor that points to the position after the last result in the batch. * </pre> * * <code>optional bytes end_cursor = 4;</code> */ public Builder clearEndCursor() { endCursor_ = getDefaultInstance().getEndCursor(); onChanged(); return this; }
/** * * * <pre> * A cursor that points to the position after the last result in the batch. * </pre> * * <code>bytes end_cursor = 4;</code> */ public Builder clearEndCursor() { endCursor_ = getDefaultInstance().getEndCursor(); onChanged(); return this; }
static QueryResult build(final com.google.datastore.v1.RunQueryResponse response) { final com.google.datastore.v1.QueryResultBatch batch = response.getBatch(); return new QueryResult(ImmutableList.copyOf( response.getBatch().getEntityResultsList().stream() .map(entity -> Entity.builder(entity.getEntity()).build()) .collect(Collectors.toList())), batch.getEndCursor()); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.QueryResultBatch)) { return super.equals(obj); } com.google.datastore.v1.QueryResultBatch other = (com.google.datastore.v1.QueryResultBatch) obj; boolean result = true; result = result && (getSkippedResults() == other.getSkippedResults()); result = result && getSkippedCursor().equals(other.getSkippedCursor()); result = result && entityResultType_ == other.entityResultType_; result = result && getEntityResultsList().equals(other.getEntityResultsList()); result = result && getEndCursor().equals(other.getEndCursor()); result = result && moreResults_ == other.moreResults_; result = result && (getSnapshotVersion() == other.getSnapshotVersion()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SKIPPED_RESULTS_FIELD_NUMBER; hash = (53 * hash) + getSkippedResults(); hash = (37 * hash) + SKIPPED_CURSOR_FIELD_NUMBER; hash = (53 * hash) + getSkippedCursor().hashCode(); hash = (37 * hash) + ENTITY_RESULT_TYPE_FIELD_NUMBER; hash = (53 * hash) + entityResultType_; if (getEntityResultsCount() > 0) { hash = (37 * hash) + ENTITY_RESULTS_FIELD_NUMBER; hash = (53 * hash) + getEntityResultsList().hashCode(); } hash = (37 * hash) + END_CURSOR_FIELD_NUMBER; hash = (53 * hash) + getEndCursor().hashCode(); hash = (37 * hash) + MORE_RESULTS_FIELD_NUMBER; hash = (53 * hash) + moreResults_; hash = (37 * hash) + SNAPSHOT_VERSION_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSnapshotVersion()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + SKIPPED_RESULTS_FIELD_NUMBER; hash = (53 * hash) + getSkippedResults(); hash = (37 * hash) + SKIPPED_CURSOR_FIELD_NUMBER; hash = (53 * hash) + getSkippedCursor().hashCode(); hash = (37 * hash) + ENTITY_RESULT_TYPE_FIELD_NUMBER; hash = (53 * hash) + entityResultType_; if (getEntityResultsCount() > 0) { hash = (37 * hash) + ENTITY_RESULTS_FIELD_NUMBER; hash = (53 * hash) + getEntityResultsList().hashCode(); } hash = (37 * hash) + END_CURSOR_FIELD_NUMBER; hash = (53 * hash) + getEndCursor().hashCode(); hash = (37 * hash) + MORE_RESULTS_FIELD_NUMBER; hash = (53 * hash) + moreResults_; hash = (37 * hash) + SNAPSHOT_VERSION_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getSnapshotVersion()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.QueryResultBatch)) { return super.equals(obj); } com.google.datastore.v1.QueryResultBatch other = (com.google.datastore.v1.QueryResultBatch) obj; boolean result = true; result = result && (getSkippedResults() == other.getSkippedResults()); result = result && getSkippedCursor() .equals(other.getSkippedCursor()); result = result && entityResultType_ == other.entityResultType_; result = result && getEntityResultsList() .equals(other.getEntityResultsList()); result = result && getEndCursor() .equals(other.getEndCursor()); result = result && moreResults_ == other.moreResults_; result = result && (getSnapshotVersion() == other.getSnapshotVersion()); return result; }
@Override protected T computeNext() { while (!entityResultPbIter.hasNext() && !lastBatch) { query = query.nextQuery(runQueryResponsePb); sendRequest(); } if (!entityResultPbIter.hasNext()) { cursor = runQueryResponsePb.getBatch().getEndCursor(); return endOfData(); } com.google.datastore.v1.EntityResult entityResultPb = entityResultPbIter.next(); cursor = entityResultPb.getCursor(); @SuppressWarnings("unchecked") T result = (T) actualResultType.convert(entityResultPb.getEntity()); return result; }
private Iterator<EntityResult> getIteratorAndMoveCursor() throws DatastoreException { Query.Builder query = this.query.toBuilder(); query.setLimit(Int32Value.newBuilder().setValue(QUERY_BATCH_LIMIT)); if (currentBatch != null && !currentBatch.getEndCursor().isEmpty()) { query.setStartCursor(currentBatch.getEndCursor()); } RunQueryRequest request = makeRequest(query.build(), namespace); RunQueryResponse response = datastore.runQuery(request); currentBatch = response.getBatch(); int numFetch = currentBatch.getEntityResultsCount(); // All indications from the API are that there are/may be more results. moreResults = ((numFetch == QUERY_BATCH_LIMIT) || (currentBatch.getMoreResults() == NOT_FINISHED)); // May receive a batch of 0 results if the number of records is a multiple // of the request limit. if (numFetch == 0) { return null; } return currentBatch.getEntityResultsList().iterator(); } }
Int32Value.newBuilder().setValue(Math.min(userLimit, QUERY_BATCH_LIMIT))); if (currentBatch != null && !currentBatch.getEndCursor().isEmpty()) { queryBuilder.setStartCursor(currentBatch.getEndCursor());
keySplits.add(result.getEntity().getKey()); scatterPointQuery.setStartCursor(batch.getEndCursor()); scatterPointQuery.getLimitBuilder().setValue( scatterPointQuery.getLimit().getValue() - batch.getEntityResultsCount());
keySplits.add(result.getEntity().getKey()); scatterPointQuery.setStartCursor(batch.getEndCursor()); scatterPointQuery.getLimitBuilder().setValue( scatterPointQuery.getLimit().getValue() - batch.getEntityResultsCount());
@Override StructuredQuery<V> nextQuery(com.google.datastore.v1.RunQueryResponse responsePb) { Builder<V> builder = toBuilder(); builder.setStartCursor(new Cursor(responsePb.getBatch().getEndCursor())); if (offset > 0 && responsePb.getBatch().getSkippedResults() < offset) { builder.setOffset(offset - responsePb.getBatch().getSkippedResults()); } else { builder.setOffset(0); if (limit != null) { builder.setLimit(limit - responsePb.getBatch().getEntityResultsCount()); } } return builder.build(); }