App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | List of all members
google.appengine.datastore.datastore_query.Batch Class Reference
Inheritance diagram for google.appengine.datastore.datastore_query.Batch:
google.appengine.datastore.datastore_query._AugmentedBatch

Public Member Functions

def create_async
 
def __init__
 
def query_options
 
def query
 
def results
 
def keys_only
 
def index_list
 
def start_cursor
 
def end_cursor
 
def skipped_results
 
def more_results
 
def next_batch
 
def cursor
 
def next_batch_async
 
def __getstate__
 

Detailed Description

A batch of results returned by a query.

This class contains a batch of results returned from the datastore and
relevant metadata. This metadata includes:
  query: The query that produced this batch
  query_options: The QueryOptions used to run the query. This does not
    contained any options passed to the .next_batch() call that created the
    current batch.
  start_cursor, end_cursor: These are the cursors that can be used
    with a query to re-fetch this batch. They can also be used to
    find all entities before or after the given batch (by use start_cursor as
    an end cursor or vice versa). start_cursor can also be advanced to
    point to a position within the batch using Cursor.advance().
  skipped_results: the number of result skipped because of the offset
    given to the request that generated it. This can be set either on
    the original Query.run() request or in subsequent .next_batch() calls.
  more_results: If this is true there are more results that can be retrieved
    either by .next_batch() or Batcher.next().

This class is also able to fetch the next batch of the query using
.next_batch(). As batches of results must be fetched serially, .next_batch()
can only be called once. Additional calls to .next_batch() will return None.
When there are no more batches .next_batch() will return None as well. Note
that batches returned by iterating over Batcher will always return None for
.next_batch() as the Bather handles fetching the next batch automatically.

A Batch typically represents the result of a single RPC request. The datastore
operates on a "best effort" basis so the batch returned by .next_batch()
or Query.run_async().get_result() may not have satisfied the requested offset
or number of results (specified through FetchOptions.offset and
FetchOptions.batch_size respectively). To satisfy these restrictions
additional batches may be needed (with FetchOptions that specify the remaining
offset or results needed). The Batcher class hides these limitations.

Constructor & Destructor Documentation

def google.appengine.datastore.datastore_query.Batch.__init__ (   self,
  batch_shared,
  start_cursor = Cursor() 
)
Constructor.

This class is constructed in stages (one when an RPC is sent and another
when an rpc is completed) and should not be constructed directly!!
Use Query.run_async().get_result() to create a Batch or Query.run()
to use a batcher.

This constructor does not perform verification.

Args:
  batch_shared: Data shared between batches for a a single query run.
  start_cursor: Optional cursor pointing before this batch.

Member Function Documentation

def google.appengine.datastore.datastore_query.Batch.cursor (   self,
  index 
)
Gets the cursor that points just after the result at index - 1.

The index is relative to first result in .results. Since start_cursor
points to the position before the first skipped result, the range of
indexes this function supports is limited to
[-skipped_results, len(results)].

For example, using start_cursor=batch.cursor(i) and
end_cursor=batch.cursor(j) will return the results found in
batch.results[i:j]. Note that any result added in the range (i-1, j]
will appear in the new query's results.

Warning: Any index in the range (-skipped_results, 0) may cause
continuation to miss or duplicate results if outside a transaction.

Args:
  index: An int, the index relative to the first result before which the
cursor should point.

Returns:
  A Cursor that points to a position just after the result index - 1,
  which if used as a start_cursor will cause the first result to be
  batch.result[index].
def google.appengine.datastore.datastore_query.Batch.end_cursor (   self)
A cursor that points to the position just after the current batch.
def google.appengine.datastore.datastore_query.Batch.index_list (   self)
Returns the list of indexes used to peform this batch's query.
Possibly None when the adapter does not implement pb_to_index.
def google.appengine.datastore.datastore_query.Batch.keys_only (   self)
Whether the entities in this batch only contain keys.
def google.appengine.datastore.datastore_query.Batch.more_results (   self)
Whether more results can be retrieved from the query.
def google.appengine.datastore.datastore_query.Batch.next_batch (   self,
  fetch_options = None 
)
Synchronously get the next batch or None if there are no more batches.

Args:
  fetch_options: Optional fetch options to use when fetching the next batch.
Merged with both the fetch options on the original call and the
connection.

Returns:
  A new Batch of results or None if either the next batch has already been
  fetched or there are no more results.
def google.appengine.datastore.datastore_query.Batch.next_batch_async (   self,
  fetch_options = None 
)
Asynchronously get the next batch or None if there are no more batches.

Args:
  fetch_options: Optional fetch options to use when fetching the next batch.
Merged with both the fetch options on the original call and the
connection.

Returns:
  An async object that can be used to get the next Batch or None if either
  the next batch has already been fetched or there are no more results.
def google.appengine.datastore.datastore_query.Batch.query (   self)
The query the current batch came from.
def google.appengine.datastore.datastore_query.Batch.query_options (   self)
The QueryOptions used to retrieve the first batch.
def google.appengine.datastore.datastore_query.Batch.results (   self)
A list of entities in this batch.
def google.appengine.datastore.datastore_query.Batch.skipped_results (   self)
The number of results skipped because of an offset in the request.

An offset is satisfied before any results are returned. The start_cursor
points to the position in the query before the skipped results.
def google.appengine.datastore.datastore_query.Batch.start_cursor (   self)
A cursor that points to the position just before the current batch.

The documentation for this class was generated from the following file: