public final class FetchOptions
extends java.lang.Object
PreparedQuery
.
limit
is the maximum number of results the query will return.
offset
is the number of results to skip before returning any results. Results that are
skipped due to offset do not count against limit
.
Note: Using offset
still retrieves skipped entities internally. This affects the
latency of the query, and your application is billed for the operations required to
retrieve them. Using cursors lets you avoid these costs.
startCursor
and endCursor
are previously generated cursors that point to
locations in a result set. If specified queries will start and end at these locations.
prefetchSize
is the number of results retrieved on the first call to the datastore.
chunkSize
determines the internal chunking strategy of the Iterator
returned
by PreparedQuery.asIterator(FetchOptions)
and the Iterable
returned by PreparedQuery.asIterable(FetchOptions)
.
Note that unlike limit
, offset
and cursor
, prefetchSize
and
chunkSize
have no impact on the result of the PreparedQuery
, but rather only the
performance of the PreparedQuery
.
Notes on usage:
The recommended way to instantiate a FetchOptions
object is to import FetchOptions
and invoke a static creation method followed by an instance mutator (if needed):
import com.google.appengine.api.datastore.FetchOptions; Cursor cursor = ... ... // limit 10 datastoreService.prepare(query).asList(FetchOptions.Builder.withLimit(10)); // limit 10, start cursor datastoreService.prepare(query).asList(FetchOptions.Builder.withLimit(10).startCursor(cursor));
Modifier and Type | Class and Description |
---|---|
static class |
FetchOptions.Builder
Contains static creation methods for
FetchOptions . |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CHUNK_SIZE
Deprecated.
Instead of using DEFAULT_CHUNK_SIZE, do not specify a chunk size.
|
Modifier and Type | Method and Description |
---|---|
FetchOptions |
chunkSize(int chunkSize)
Sets the chunk size.
|
FetchOptions |
cursor(Cursor cursor)
Deprecated.
use
startCursor instead. |
FetchOptions |
endCursor(Cursor endCursor)
Sets the cursor at which to end the query.
|
boolean |
equals(java.lang.Object obj) |
java.lang.Integer |
getChunkSize() |
Cursor |
getCursor()
Deprecated.
use
getStartCursor() instead |
Cursor |
getEndCursor() |
java.lang.Integer |
getLimit() |
java.lang.Integer |
getOffset() |
java.lang.Integer |
getPrefetchSize() |
Cursor |
getStartCursor() |
int |
hashCode() |
FetchOptions |
limit(int limit)
Sets the limit.
|
FetchOptions |
offset(int offset)
Sets the offset.
|
FetchOptions |
prefetchSize(int prefetchSize)
Sets the number of entities to prefetch.
|
FetchOptions |
startCursor(Cursor startCursor)
Sets the cursor at which to start the query.
|
java.lang.String |
toString() |
@Deprecated public static final int DEFAULT_CHUNK_SIZE
public FetchOptions limit(int limit)
limit
- The limit to set. Must be non-negative.this
(for chaining)public FetchOptions offset(int offset)
offset
- The offset to set. Must be 0 or greater.this
(for chaining)public FetchOptions chunkSize(int chunkSize)
chunkSize
- The chunk size to set. Must be greater than 0.this
(for chaining)public FetchOptions prefetchSize(int prefetchSize)
prefetchSize
- The prefetch size to set. Must be >= 0.this
(for chaining)@Deprecated public FetchOptions cursor(Cursor cursor)
startCursor
instead.cursor
- the cursor to setthis
(for chaining)public FetchOptions startCursor(Cursor startCursor)
startCursor
- the cursor to setthis
(for chaining)public FetchOptions endCursor(Cursor endCursor)
endCursor
- the cursor to setthis
(for chaining)public java.lang.Integer getLimit()
null
if no limit was provided.public java.lang.Integer getOffset()
null
if no offset was provided.public java.lang.Integer getChunkSize()
null
if no chunk size was provided.public java.lang.Integer getPrefetchSize()
null
if no prefetch size was provided.@Deprecated public Cursor getCursor()
getStartCursor()
insteadnull
if no cursor was provided.public Cursor getStartCursor()
null
if no start cursor was provided.public Cursor getEndCursor()
null
if no end cursor was provided.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object