Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | class CassandraStorage: | ||||
def content_missing_per_sha1(self, contents): | def content_missing_per_sha1(self, contents): | ||||
return self.content_missing([{"sha1": c for c in contents}]) | return self.content_missing([{"sha1": c for c in contents}]) | ||||
def content_missing_per_sha1_git(self, contents): | def content_missing_per_sha1_git(self, contents): | ||||
return self.content_missing( | return self.content_missing( | ||||
[{"sha1_git": c for c in contents}], key_hash="sha1_git" | [{"sha1_git": c for c in contents}], key_hash="sha1_git" | ||||
) | ) | ||||
def content_metadata_add( | |||||
self, | |||||
id: str, | |||||
context: Dict[str, Union[str, bytes, int]], | |||||
discovery_date: datetime.datetime, | |||||
authority: Dict[str, Any], | |||||
fetcher: Dict[str, Any], | |||||
format: str, | |||||
metadata: bytes, | |||||
) -> None: | |||||
self._object_metadata_add( | |||||
"content", | |||||
id, | |||||
discovery_date, | |||||
authority, | |||||
fetcher, | |||||
format, | |||||
metadata, | |||||
context, | |||||
) | |||||
def content_metadata_get( | |||||
self, | |||||
id: str, | |||||
authority: Dict[str, str], | |||||
after: Optional[datetime.datetime] = None, | |||||
page_token: Optional[bytes] = None, | |||||
limit: int = 1000, | |||||
) -> Dict[str, Any]: | |||||
return self._object_metadata_get( | |||||
"content", id, authority, after, page_token, limit, | |||||
) | |||||
def content_get_random(self): | def content_get_random(self): | ||||
return self._cql_runner.content_get_random().sha1_git | return self._cql_runner.content_get_random().sha1_git | ||||
def _skipped_content_get_from_hash(self, algo, hash_) -> Iterable: | def _skipped_content_get_from_hash(self, algo, hash_) -> Iterable: | ||||
"""From the name of a hash algorithm and a value of that hash, | """From the name of a hash algorithm and a value of that hash, | ||||
looks up the "hash -> token" secondary table | looks up the "hash -> token" secondary table | ||||
(skipped_content_by_{algo}) to get tokens. | (skipped_content_by_{algo}) to get tokens. | ||||
Then, looks up the main table (content) to get all contents with | Then, looks up the main table (content) to get all contents with | ||||
▲ Show 20 Lines • Show All 946 Lines • Show Last 20 Lines |