Class FetchOptions
- java.lang.Object
-
- com.google.appengine.api.datastore.FetchOptions
-
public final class FetchOptions extends Object
Describes the limit, offset, and chunk size to be applied when executing aPreparedQuery.limitis the maximum number of results the query will return.offsetis the number of results to skip before returning any results. Results that are skipped due to offset do not count againstlimit.
Note: Usingoffsetstill 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.startCursorandendCursorare previously generated cursors that point to locations in a result set. If specified queries will start and end at these locations.prefetchSizeis the number of results retrieved on the first call to the datastore.chunkSizedetermines the internal chunking strategy of theIteratorreturned byPreparedQuery.asIterator(FetchOptions)and theIterablereturned byPreparedQuery.asIterable(FetchOptions).Note that unlike
limit,offsetandcursor,prefetchSizeandchunkSizehave no impact on the result of thePreparedQuery, but rather only the performance of thePreparedQuery.Notes on usage:
The recommended way to instantiate aFetchOptionsobject is to importFetchOptionsand 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 Classes Modifier and Type Class Description static classFetchOptions.BuilderContains static creation methods forFetchOptions.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_CHUNK_SIZEDeprecated.Instead of using DEFAULT_CHUNK_SIZE, do not specify a chunk size.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FetchOptionschunkSize(int chunkSize)Sets the chunk size.FetchOptionscursor(Cursor cursor)Deprecated.usestartCursorinstead.FetchOptionsendCursor(Cursor endCursor)Sets the cursor at which to end the query.booleanequals(@Nullable Object obj)@Nullable IntegergetChunkSize()Returns the chunk size, ornullif no chunk size was provided.@Nullable CursorgetCursor()Deprecated.usegetStartCursor()instead@Nullable CursorgetEndCursor()Returns the end cursor, ornullif no end cursor was provided.@Nullable IntegergetLimit()Returns the limit, ornullif no limit was provided.@Nullable IntegergetOffset()Returns the offset, ornullif no offset was provided.@Nullable IntegergetPrefetchSize()Returns the prefetch size, ornullif no prefetch size was provided.@Nullable CursorgetStartCursor()Returns the start cursor, ornullif no start cursor was provided.inthashCode()FetchOptionslimit(int limit)Sets the limit.FetchOptionsoffset(int offset)Sets the offset.FetchOptionsprefetchSize(int prefetchSize)Sets the number of entities to prefetch.FetchOptionsstartCursor(Cursor startCursor)Sets the cursor at which to start the query.StringtoString()
-
-
-
Field Detail
-
DEFAULT_CHUNK_SIZE
@Deprecated public static final int DEFAULT_CHUNK_SIZE
Deprecated.Instead of using DEFAULT_CHUNK_SIZE, do not specify a chunk size.- See Also:
- Constant Field Values
-
-
Method Detail
-
limit
public FetchOptions limit(int 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
public FetchOptions offset(int 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
public FetchOptions chunkSize(int 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
public FetchOptions prefetchSize(int prefetchSize)
Sets the number of entities to prefetch.- Parameters:
prefetchSize- The prefetch size to set. Must be >= 0.- Returns:
this(for chaining)
-
cursor
@Deprecated public FetchOptions cursor(Cursor cursor)
Deprecated.usestartCursorinstead.Sets the cursor to start the query from.- Parameters:
cursor- the cursor to set- Returns:
this(for chaining)
-
startCursor
public FetchOptions startCursor(Cursor startCursor)
Sets the cursor at which to start the query.- Parameters:
startCursor- the cursor to set- Returns:
this(for chaining)
-
endCursor
public FetchOptions endCursor(Cursor endCursor)
Sets the cursor at which to end the query.- Parameters:
endCursor- the cursor to set- Returns:
this(for chaining)
-
getLimit
public @Nullable Integer getLimit()
Returns the limit, ornullif no limit was provided.
-
getOffset
public @Nullable Integer getOffset()
Returns the offset, ornullif no offset was provided.
-
getChunkSize
public @Nullable Integer getChunkSize()
Returns the chunk size, ornullif no chunk size was provided.
-
getPrefetchSize
public @Nullable Integer getPrefetchSize()
Returns the prefetch size, ornullif no prefetch size was provided.
-
getCursor
@Deprecated public @Nullable Cursor getCursor()
Deprecated.usegetStartCursor()instead- Returns:
- The start cursor, or
nullif no cursor was provided.
-
getStartCursor
public @Nullable Cursor getStartCursor()
Returns the start cursor, ornullif no start cursor was provided.
-
getEndCursor
public @Nullable Cursor getEndCursor()
Returns the end cursor, ornullif no end cursor was provided.
-
-