def _read_undone_shard_from_datastore(self, shard_id=None):
    """Reads undone worke pieces which are assigned to shard with given id."""
    self._work = {}
    client = self._datastore_client
    parent_key = client.key(KIND_WORK_TYPE, self._work_type_entity_id)
    filters = [('is_completed', '=', False)]
    if shard_id is not None:
      filters.append(('shard_id', '=', shard_id))
    for entity in client.query_fetch(kind=KIND_WORK, ancestor=parent_key,
                                     filters=filters):
      work_id = entity.key.flat_path[-1]
      self.work[work_id] = dict(entity)
      if len(self._work) >= MAX_WORK_RECORDS_READ:
        break
Reads undone worke pieces which are assigned to shard with given id.