当前位置: 首页>>代码示例>>Python>>正文


Python datastore_query.QueryOptions方法代码示例

本文整理汇总了Python中google.appengine.datastore.datastore_query.QueryOptions方法的典型用法代码示例。如果您正苦于以下问题:Python datastore_query.QueryOptions方法的具体用法?Python datastore_query.QueryOptions怎么用?Python datastore_query.QueryOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.datastore.datastore_query的用法示例。


在下文中一共展示了datastore_query.QueryOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __iter__

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def __iter__(self):
    query = self._key_range.make_ascending_datastore_query(
        self._query_spec.entity_kind, filters=self._query_spec.filters)
    # get a connection without adapter.
    connection = datastore_rpc.Connection()
    query_options = datastore_query.QueryOptions(
        batch_size=self._query_spec.batch_size,
        start_cursor=self._cursor,
        produce_cursors=True)

    # Transform datastore.Query:
    # datastore.Query -> datastore_query.Query -> datastore_query.Batcher ->
    # datastore_query.ResultsIterator
    self._query = datastore_query.ResultsIterator(
        query.GetQuery().run(connection, query_options))
    for entity_proto in self._query:
      yield entity_proto 
开发者ID:elsigh,项目名称:browserscope,代码行数:19,代码来源:datastore_range_iterators.py

示例2: Get

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def Get(self, limit, offset=0, **kwargs):
    """Deprecated, use list(Run(...)) instead.

    Args:
      limit: int or long representing the maximum number of entities to return.
      offset: int or long representing the number of entities to skip
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      # a list of entities
      [Entity, ...]
    """
    if limit is None:
      kwargs.setdefault('batch_size', _MAX_INT_32)

    return list(self.Run(limit=limit, offset=offset, **kwargs)) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:18,代码来源:datastore.py

示例3: __GetProjectionOverride

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def __GetProjectionOverride(self,  config):
    """Returns a tuple of (original projection, projeciton override).

    If projection is None, there is no projection. If override is None,
    projection is sufficent for this query.
    """
    projection = datastore_query.QueryOptions.projection(config)
    if  projection is None:
      projection = self.__projection
    else:
      projection = projection

    if not projection:
      return None, None



    override = set()
    for prop, _ in self.__orderings:
      if prop not in projection:
        override.add(prop)
    if not override:
      return projection, None

    return projection, projection + tuple(override) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:27,代码来源:datastore.py

示例4: run

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def run(self, **kwargs):
    """Iterator for this query.

    If you know the number of results you need, use run(limit=...) instead,
    or use a GQL query with a LIMIT clause. It's more efficient. If you want
    all results use run(batch_size=<large number>).

    Args:
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      Iterator for this query.
    """
    raw_query = self._get_query()
    iterator = raw_query.Run(**kwargs)
    self._last_raw_query = raw_query

    keys_only = kwargs.get('keys_only')
    if keys_only is None:
      keys_only = self.is_keys_only()

    if keys_only:
      return iterator
    else:
      return _QueryIterator(self._model_class, iter(iterator)) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:27,代码来源:__init__.py

示例5: get

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def get(self, **kwargs):
    """Get first result from this.

    Beware: get() ignores the LIMIT clause on GQL queries.

    Args:
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      First result from running the query if there are any, else None.
    """
    results = self.run(limit=1, **kwargs)
    try:
      return results.next()
    except StopIteration:
      return None 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:18,代码来源:__init__.py

示例6: count

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def count(self, limit=1000, **kwargs):
    """Number of entities this query fetches.

    Beware: count() ignores the LIMIT clause on GQL queries.

    Args:
      limit: A number. If there are more results than this, stop short and
        just return this number. Providing this argument makes the count
        operation more efficient.
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      Number of entities this query fetches.
    """
    raw_query = self._get_query()
    result = raw_query.Count(limit=limit, **kwargs)
    self._last_raw_query = raw_query

    return result 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:__init__.py

示例7: fetch

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def fetch(self, limit, offset=0, **kwargs):
    """Return a list of items selected using SQL-like limit and offset.

    Always use run(limit=...) instead of fetch() when iterating over a query.

    Beware: offset must read and discard all skipped entities. Use
    cursor()/with_cursor() instead.

    Args:
      limit: Maximum number of results to return.
      offset: Optional number of results to skip first; default zero.
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      A list of db.Model instances.  There may be fewer than 'limit'
      results if there aren't enough results to satisfy the request.
    """
    if limit is None:
      kwargs.setdefault('batch_size', datastore._MAX_INT_32)
    return list(self.run(limit=limit, offset=offset, **kwargs)) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:22,代码来源:__init__.py

示例8: __iter__

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def __iter__(self):
    query = self._key_range.make_ascending_datastore_query(
        self._query_spec.entity_kind, filters=self._query_spec.filters)

    connection = datastore_rpc.Connection()
    query_options = datastore_query.QueryOptions(
        batch_size=self._query_spec.batch_size,
        start_cursor=self._cursor,
        produce_cursors=True)




    self._query = datastore_query.ResultsIterator(
        query.GetQuery().run(connection, query_options))
    for entity_proto in self._query:
      yield entity_proto 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:19,代码来源:datastore_range_iterators.py

示例9: _iter_key_range

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def _iter_key_range(self, k_range):
    assert hasattr(self, "start_time_us"), "start_time_us property was not set"
    if self._ns_range is None:
      # _iter_ns_range will have already have dealt with unapplied jobs so only
      # handle the case where it would not have been called.
      self._apply_key_range(k_range)

    raw_entity_kind = self._get_raw_entity_kind(self._entity_kind)
    query = k_range.make_ascending_datastore_query(
        raw_entity_kind, keys_only=True, filters=self._filters)
    for key in query.Run(
        config=datastore_query.QueryOptions(batch_size=self._batch_size)):
      yield key, key 
开发者ID:elsigh,项目名称:browserscope,代码行数:15,代码来源:input_readers.py

示例10: _make_query

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def _make_query(self):
    qry = Message.query().order(-Message.when)
    options = datastore_query.QueryOptions(batch_size=13, limit=43)
    return qry, options 
开发者ID:GoogleCloudPlatform,项目名称:datastore-ndb-python,代码行数:6,代码来源:main.py

示例11: Hint

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def Hint(self, hint):
    """Sets a hint for how this query should run.

    The query hint gives us information about how best to execute your query.
    Currently, we can only do one index scan, so the query hint should be used
    to indicates which index we should scan against.

    Use FILTER_FIRST if your first filter will only match a few results. In
    this case, it will be most efficient to scan against the index for this
    property, load the results into memory, and apply the remaining filters
    and sort orders there.

    Similarly, use ANCESTOR_FIRST if the query's ancestor only has a few
    descendants. In this case, it will be most efficient to scan all entities
    below the ancestor and load them into memory first.

    Use ORDER_FIRST if the query has a sort order and the result set is large
    or you only plan to fetch the first few results. In that case, we
    shouldn't try to load all of the results into memory; instead, we should
    scan the index for this property, which is in sorted order.

    Note that hints are currently ignored in the v3 datastore!

    Arg:
      one of datastore.Query.[ORDER_FIRST, ANCESTOR_FIRST, FILTER_FIRST]

    Returns:
      # this query
      Query
    """
    if hint is not self.__query_options.hint:
      self.__query_options = datastore_query.QueryOptions(
          hint=hint, config=self.__query_options)
    return self 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:36,代码来源:datastore.py

示例12: GetQueryOptions

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def GetQueryOptions(self):
    """Returns a datastore_query.QueryOptions for the current instance."""
    return self.__query_options 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:5,代码来源:datastore.py

示例13: Run

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def Run(self, **kwargs):
    """Runs this query.

    If a filter string is invalid, raises BadFilterError. If a filter value is
    invalid, raises BadValueError. If an IN filter is provided, and a sort
    order on another property is provided, raises BadQueryError.

    If you know in advance how many results you want, use limit=#. It's
    more efficient.

    Args:
      kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().

    Returns:
      # an iterator that provides access to the query results
      Iterator
    """
    config = _GetConfigFromKwargs(kwargs, convert_rpc=True,
                                  config_class=datastore_query.QueryOptions)
    itr = Iterator(self.GetBatcher(config=config))

    self.__index_list_source = itr.GetIndexList

    self.__cursor_source = itr.cursor

    self.__compiled_query_source = itr._compiled_query
    return itr 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:29,代码来源:datastore.py

示例14: __setstate__

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def __setstate__(self, state):

    if '_Query__query_options' not in state:
      state['_Query__query_options'] = datastore_query.QueryOptions(
        keys_only=state.pop('_Query__keys_only'),
        produce_cursors=state.pop('_Query__compile'),
        start_cursor=state.pop('_Query__cursor'),
        end_cursor=state.pop('_Query__end_cursor'))
    self.__dict__ = state 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:11,代码来源:datastore.py

示例15: _ToPb

# 需要导入模块: from google.appengine.datastore import datastore_query [as 别名]
# 或者: from google.appengine.datastore.datastore_query import QueryOptions [as 别名]
def _ToPb(self, limit=None, offset=None, count=None):

    query_options = datastore_query.QueryOptions(
        config=self.GetQueryOptions(),
        limit=limit,
        offset=offset,
        batch_size=count)
    return self.GetQuery()._to_pb(_GetConnection(), query_options) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:10,代码来源:datastore.py


注:本文中的google.appengine.datastore.datastore_query.QueryOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。