View source on GitHub |
A class that implements the Iterator interface for Batches.
Inherits From: expected_type
google.appengine.datastore.datastore_query.Batcher(
query_options, first_async_batch
)
Typically constructed by a call to Query.run().
The class hides the "best effort" nature of the datastore by potentially making multiple requests to the datastore and merging the resulting batches. This is accomplished efficiently by prefetching results and mixing both non-blocking and blocking calls to the datastore as needed.
Iterating through batches is almost always more efficient than pulling all results at once as RPC latency is hidden by asynchronously prefetching results.
The batches produce by this class cannot be used to fetch the next batch (through Batch.next_batch()) as before the current batch is returned the request for the next batch has already been sent.
Args | |
---|---|
query_options
|
The QueryOptions used to create the first batch. |
first_async_batch
|
The first batch produced by Query.run_async(query_options). |
Methods
next
next()
Get the next batch. See .next_batch().
next_batch
next_batch(
min_batch_size
)
Get the next batch.
The batch returned by this function cannot be used to fetch the next batch (through Batch.next_batch()). Instead this function will always return None. To retrieve the next batch use .next() or .next_batch(N).
This function may return a batch larger than min_to_fetch, but will never return smaller unless there are no more results.
Special values can be used for min_batch_size: ASYNC_ONLY - Do not perform any synchrounous fetches from the datastore even if the this produces a batch with no results. AT_LEAST_OFFSET - Only pull enough results to satifiy the offset. AT_LEAST_ONE - Pull batches until at least one result is returned.
Args | |
---|---|
min_batch_size
|
The minimum number of results to retrieve or one of (ASYNC_ONLY, AT_LEAST_OFFSET, AT_LEAST_ONE) |
Returns | |
---|---|
The next Batch of results. |
__iter__
__iter__()
Class Variables | |
---|---|
ASYNC_ONLY |
None
|
AT_LEAST_OFFSET |
0
|
AT_LEAST_ONE |
Instance of google.appengine.api.validation.Validator.expected_type
|