1 package com
.google
.appengine
.api
.datastore
;
3 import com
.google
.appengine
.api
.datastore
.BaseQueryResultsSource
.WrappedQueryResult
;
4 import com
.google
.apphosting
.datastore
.DatastoreV4
;
5 import com
.google
.apphosting
.datastore
.DatastoreV4
.QueryResultBatch
;
6 import com
.google
.apphosting
.datastore
.DatastoreV4
.QueryResultBatch
.MoreResultsType
;
7 import com
.google
.common
.collect
.ImmutableList
;
8 import com
.google
.common
.collect
.Lists
;
10 import java
.util
.Collection
;
11 import java
.util
.Collections
;
12 import java
.util
.List
;
15 * Wrapper for V4 protos with common functions.
17 class WrappedQueryResultV4
implements WrappedQueryResult
{
18 private final QueryResultBatch batch
;
20 WrappedQueryResultV4(QueryResultBatch batch
) {
25 public Cursor
getEndCursor() {
26 if (batch
.hasEndCursor()) {
27 return new Cursor(batch
.getEndCursor());
33 public List
<Entity
> getEntities(Collection
<Projection
> projections
) {
34 List
<Entity
> entityList
= Lists
.newArrayListWithCapacity(batch
.getEntityResultCount());
35 if (projections
.isEmpty()) {
36 for (DatastoreV4
.EntityResult entityResult
: batch
.getEntityResultList()) {
37 entityList
.add(DataTypeTranslator
.toEntity(entityResult
.getEntity()));
40 for (DatastoreV4
.EntityResult entityResult
: batch
.getEntityResultList()) {
41 entityList
.add(DataTypeTranslator
.toEntity(entityResult
.getEntity(), projections
));
48 public List
<Cursor
> getResultCursors() {
49 return Collections
.<Cursor
>nCopies(batch
.getEntityResultCount(), null);
53 public Cursor
getSkippedResultsCursor() {
58 public boolean hasMoreResults() {
59 return batch
.getMoreResults() == MoreResultsType
.NOT_FINISHED
;
63 public int numSkippedResults() {
64 return batch
.getSkippedResults();
68 public List
<Index
> getIndexInfo(Collection
<Index
> monitoredIndexBuffer
) {
69 return ImmutableList
.of();
72 QueryResultBatch
getBatch() {