Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | class Storage(): | ||||
def content_get(self, content): | def content_get(self, content): | ||||
"""Retrieve in bulk contents and their data. | """Retrieve in bulk contents and their data. | ||||
Args: | Args: | ||||
content: iterables of sha1 | content: iterables of sha1 | ||||
Yields: | Yields: | ||||
dict: Generates streams of contents as dict with their raw data: | Dict[str, bytes]: Generates streams of contents as dict with their | ||||
raw data: | |||||
ardumont: [bytes, bytes]? | |||||
Done Inline ActionsNo, keys are 'sha1' and 'data'. vlorentz: No, keys are `'sha1'` and `'data'`. | |||||
Not Done Inline Actionsyes, my bad ;) ardumont: yes, my bad ;) | |||||
- sha1: sha1's content | - sha1 (bytes): content id | ||||
- data: bytes data of the content | - data (bytes): content's raw data | ||||
Raises: | Raises: | ||||
ValueError in case of too much contents are required. | ValueError in case of too much contents are required. | ||||
cf. BULK_BLOCK_CONTENT_LEN_MAX | cf. BULK_BLOCK_CONTENT_LEN_MAX | ||||
""" | """ | ||||
# FIXME: Improve on server module to slice the result | # FIXME: Make this method support slicing the `data`. | ||||
if len(content) > BULK_BLOCK_CONTENT_LEN_MAX: | if len(content) > BULK_BLOCK_CONTENT_LEN_MAX: | ||||
raise ValueError( | raise ValueError( | ||||
"Send at maximum %s contents." % BULK_BLOCK_CONTENT_LEN_MAX) | "Send at maximum %s contents." % BULK_BLOCK_CONTENT_LEN_MAX) | ||||
for obj_id in content: | for obj_id in content: | ||||
try: | try: | ||||
data = self.objstorage.get(obj_id) | data = self.objstorage.get(obj_id) | ||||
except ObjNotFoundError: | except ObjNotFoundError: | ||||
▲ Show 20 Lines • Show All 1,218 Lines • Show Last 20 Lines |
[bytes, bytes]?