Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | ) -> Iterable[Optional[Dict[str, bytes]]]: | ||||
if len(contents) > BULK_BLOCK_CONTENT_LEN_MAX: | if len(contents) > BULK_BLOCK_CONTENT_LEN_MAX: | ||||
raise StorageArgumentException( | raise StorageArgumentException( | ||||
f"Send at maximum {BULK_BLOCK_CONTENT_LEN_MAX} contents." | f"Send at maximum {BULK_BLOCK_CONTENT_LEN_MAX} contents." | ||||
) | ) | ||||
yield from self.objstorage.content_get(contents) | yield from self.objstorage.content_get(contents) | ||||
@timed | @timed | ||||
@db_transaction() | @db_transaction() | ||||
def content_get_range(self, start, end, limit=1000, db=None, cur=None): | def content_get_range( | ||||
self, start: bytes, end: bytes, limit: int = 1000, db=None, cur=None | |||||
) -> Dict[str, Any]: | |||||
if limit is None: | if limit is None: | ||||
raise StorageArgumentException("limit should not be None") | raise StorageArgumentException("limit should not be None") | ||||
contents = [] | contents = [] | ||||
next_content = None | next_content = None | ||||
for counter, content_row in enumerate( | for counter, content_row in enumerate( | ||||
db.content_get_range(start, end, limit + 1, cur) | db.content_get_range(start, end, limit + 1, cur) | ||||
): | ): | ||||
content = dict(zip(db.content_get_metadata_keys, content_row)) | content = dict(zip(db.content_get_metadata_keys, content_row)) | ||||
▲ Show 20 Lines • Show All 1,126 Lines • Show Last 20 Lines |