Class FetchOptions
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));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classContains static creation methods forFetchOptions. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.Instead of using DEFAULT_CHUNK_SIZE, do not specify a chunk size. -
Method Summary
Modifier and TypeMethodDescriptionchunkSize(int chunkSize) Sets the chunk size.Deprecated.usestartCursorinstead.Sets the cursor at which to end the query.boolean@Nullable IntegerReturns the chunk size, ornullif no chunk size was provided.@Nullable CursorDeprecated.usegetStartCursor()instead@Nullable CursorReturns the end cursor, ornullif no end cursor was provided.@Nullable IntegergetLimit()Returns the limit, ornullif no limit was provided.@Nullable IntegerReturns the offset, ornullif no offset was provided.@Nullable IntegerReturns the prefetch size, ornullif no prefetch size was provided.@Nullable CursorReturns the start cursor, ornullif no start cursor was provided.inthashCode()limit(int limit) Sets the limit.offset(int offset) Sets the offset.prefetchSize(int prefetchSize) Sets the number of entities to prefetch.startCursor(Cursor startCursor) Sets the cursor at which to start the query.toString()
-
Field Details
-
DEFAULT_CHUNK_SIZE
Deprecated.Instead of using DEFAULT_CHUNK_SIZE, do not specify a chunk size.- See Also:
-
-
Method Details
-
limit
Sets the limit. Please read the class javadoc for an explanation of how limit is used.- Parameters:
limit- The limit to set. Must be non-negative.- Returns:
this(for chaining)
-
offset
Sets the offset. Please read the class javadoc for an explanation of how offset is used.- Parameters:
offset- The offset to set. Must be 0 or greater.- Returns:
this(for chaining)
-
chunkSize
Sets the chunk size. Please read the class javadoc for an explanation of how chunk size is used.- Parameters:
chunkSize- The chunk size to set. Must be greater than 0.- Returns:
this(for chaining)
-
prefetchSize
Sets the number of entities to prefetch.- Parameters:
prefetchSize- The prefetch size to set. Must be >= 0.- Returns:
this(for chaining)
-
cursor
Deprecated.usestartCursorinstead.Sets the cursor to start the query from.- Parameters:
cursor- the cursor to set- Returns:
this(for chaining)
-
startCursor
Sets the cursor at which to start the query.- Parameters:
startCursor- the cursor to set- Returns:
this(for chaining)
-
endCursor
Sets the cursor at which to end the query.- Parameters:
endCursor- the cursor to set- Returns:
this(for chaining)
-
getLimit
Returns the limit, ornullif no limit was provided. -
getOffset
Returns the offset, ornullif no offset was provided. -
getChunkSize
Returns the chunk size, ornullif no chunk size was provided. -
getPrefetchSize
Returns the prefetch size, ornullif no prefetch size was provided. -
getCursor
Deprecated.usegetStartCursor()instead- Returns:
- The start cursor, or
nullif no cursor was provided.
-
getStartCursor
Returns the start cursor, ornullif no start cursor was provided. -
getEndCursor
Returns the end cursor, ornullif no end cursor was provided. -
hashCode
public int hashCode() -
equals
-
toString
-