Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/in_memory.py
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | from swh.model.model import ( | ||||
OriginVisitStatus, | OriginVisitStatus, | ||||
Origin, | Origin, | ||||
SHA1_SIZE, | SHA1_SIZE, | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
MetadataTargetType, | MetadataTargetType, | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Sha1, | |||||
Sha1Git, | Sha1Git, | ||||
) | ) | ||||
from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes, hash_to_hex | from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes, hash_to_hex | ||||
from swh.storage.interface import ListOrder, PagedResult, VISIT_STATUSES | from swh.storage.interface import ListOrder, PagedResult, VISIT_STATUSES | ||||
from swh.storage.objstorage import ObjStorage | from swh.storage.objstorage import ObjStorage | ||||
from swh.storage.utils import now | from swh.storage.utils import now | ||||
from .converters import origin_url_to_sha1 | from .converters import origin_url_to_sha1 | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | ) -> None: | ||||
for algorithm in DEFAULT_ALGORITHMS: | for algorithm in DEFAULT_ALGORITHMS: | ||||
hash_ = new_cont.get_hash(algorithm) | hash_ = new_cont.get_hash(algorithm) | ||||
self._content_indexes[algorithm][hash_].add(new_key) | self._content_indexes[algorithm][hash_].add(new_key) | ||||
def content_add_metadata(self, content: List[Content]) -> Dict: | def content_add_metadata(self, content: List[Content]) -> Dict: | ||||
return self._content_add(content, with_data=False) | return self._content_add(content, with_data=False) | ||||
def content_get( | def content_get_data(self, content: Sha1) -> Optional[bytes]: | ||||
self, contents: List[bytes] | # FIXME: Make this method support slicing the `data` | ||||
) -> Iterable[Optional[Dict[str, bytes]]]: | return self.objstorage.content_get(content) | ||||
# FIXME: Make this method support slicing the `data`. | |||||
vlorentz: same | |||||
if len(contents) > BULK_BLOCK_CONTENT_LEN_MAX: | |||||
raise StorageArgumentException( | |||||
f"Send at maximum {BULK_BLOCK_CONTENT_LEN_MAX} contents." | |||||
) | |||||
yield from self.objstorage.content_get(contents) | |||||
def content_get_partition( | def content_get_partition( | ||||
self, | self, | ||||
partition_id: int, | partition_id: int, | ||||
nb_partitions: int, | nb_partitions: int, | ||||
page_token: Optional[str] = None, | page_token: Optional[str] = None, | ||||
limit: int = 1000, | limit: int = 1000, | ||||
) -> PagedResult[Content]: | ) -> PagedResult[Content]: | ||||
▲ Show 20 Lines • Show All 1,016 Lines • Show Last 20 Lines |
same