def _Dynamic_Get(self, req, res):


    transaction = req.has_transaction() and req.transaction() or None


    if req.allow_deferred() and req.key_size() > _MAXIMUM_RESULTS:



      keys_to_get = req.key_list()[-_MAXIMUM_RESULTS:]
      deferred_keys = req.key_list()[:-_MAXIMUM_RESULTS]
      res.deferred_list().extend(deferred_keys)
    else:

      keys_to_get = req.key_list()

    res.set_in_order(not req.allow_deferred())

    total_response_bytes = 0
    for index, record in enumerate(self._datastore.Get(keys_to_get,
                                                       transaction,
                                                       req.has_failover_ms(),
                                                       self._trusted,
                                                       self._app_id)):
      entity = record.entity
      entity_size = entity and entity.ByteSize() or 0


      if (req.allow_deferred()
          and index > 0
          and total_response_bytes + entity_size > _MAXIMUM_QUERY_RESULT_BYTES):

        res.deferred_list().extend(keys_to_get[index:])
        break
      else:
        entity_result = res.add_entity()
        if record.metadata.has_updated_version():
          entity_result.set_version(record.metadata.updated_version())

        if entity:
          entity_result.mutable_entity().CopyFrom(entity)
          total_response_bytes += entity_size
        else:

          entity_result.mutable_key().CopyFrom(keys_to_get[index])
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/datastore/datastore_stub_util.py/DatastoreStub._Dynamic_Get/original