Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 724 Lines • ▼ Show 20 Lines | def origin_get_one(self, origin_url: str) -> Optional[Origin]: | ||||
""" | """ | ||||
rows = list(self._cql_runner.origin_get_by_url(origin_url)) | rows = list(self._cql_runner.origin_get_by_url(origin_url)) | ||||
if rows: | if rows: | ||||
assert len(rows) == 1 | assert len(rows) == 1 | ||||
return Origin(url=rows[0].url) | return Origin(url=rows[0].url) | ||||
else: | else: | ||||
return None | return None | ||||
def origin_get_by_sha1( | def origin_get_by_sha1(self, sha1s: List[bytes]) -> List[Optional[Dict[str, Any]]]: | ||||
self, sha1s: List[bytes] | |||||
) -> Iterable[Optional[Dict[str, Any]]]: | |||||
results = [] | results = [] | ||||
for sha1 in sha1s: | for sha1 in sha1s: | ||||
rows = self._cql_runner.origin_get_by_sha1(sha1) | rows = self._cql_runner.origin_get_by_sha1(sha1) | ||||
origin = {"url": rows.one().url} if rows else None | origin = {"url": rows.one().url} if rows else None | ||||
results.append(origin) | results.append(origin) | ||||
return results | return results | ||||
def origin_list( | def origin_list( | ||||
▲ Show 20 Lines • Show All 518 Lines • Show Last 20 Lines |