FetchOptions (Google App Engine API for Java)

com.google.appengine.api.datastore

Class FetchOptions

  • java.lang.Object
    • com.google.appengine.api.datastore.FetchOptions


  • public final class FetchOptions
    extends java.lang.Object
    Describes the limit, offset, and chunk size to be applied when executing a 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));
     
    • Field Detai