def _split_input_from_params(cls, app, entity_kind_name,
                               params, shard_count):
    """Return input reader objects. Helper for split_input."""

    raw_entity_kind = util.get_short_name(entity_kind_name)

    # we use datastore.Query instead of ext.db.Query here, because we can't
    # erase ordering on db.Query once we set it.
    ds_query = datastore.Query(kind=raw_entity_kind, _app=app, keys_only=True)
    ds_query.Order("__key__")
    first_entity_key_list = ds_query.Get(1)
    if not first_entity_key_list:
      return []
    first_entity_key = first_entity_key_list[0]
    ds_query.Order(("__key__", datastore.Query.DESCENDING))
    try:
      last_entity_key, = ds_query.Get(1)
    except db.NeedIndexError, e:
      # TODO(user): Show this error in the worker log, not the app logs.
      logging.warning("Cannot create accurate approximation of keyspace, "
                      "guessing instead. Please address this problem: %s", e)
      # TODO(user): Use a key-end hint from the user input parameters
      # in this case, in the event the user has a good way of figuring out
      # the range of the keyspace.
      last_entity_key = key_range.KeyRange.guess_end_key(raw_entity_kind,
                                                         first_entity_key)
    full_keyrange = key_range.KeyRange(
        first_entity_key, last_entity_key, None, True, True, _app=app)
    key_ranges = [full_keyrange]
    number_of_half_splits = int(math.floor(math.log(shard_count, 2)))
    for _ in range(0, number_of_half_splits):
      new_ranges = []
      for r in key_ranges:
        new_ranges += r.split_range(1)
      key_ranges = new_ranges
    return [cls(entity_kind_name, r, params) for r in key_ranges]
Return input reader objects. Helper for split_input.
mapreduce/input_readers.py