Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | ) -> PagedResult[Content]: | ||||
if counter >= limit: | if counter >= limit: | ||||
next_page_token = str(last_id) | next_page_token = str(last_id) | ||||
break | break | ||||
contents.append(Content(**row_d)) | contents.append(Content(**row_d)) | ||||
assert len(contents) <= limit | assert len(contents) <= limit | ||||
return PagedResult(results=contents, next_page_token=next_page_token) | return PagedResult(results=contents, next_page_token=next_page_token) | ||||
def content_get_metadata(self, contents: List[bytes]) -> Dict[bytes, List[Dict]]: | def content_get(self, contents: List[Sha1]) -> List[Optional[Content]]: | ||||
result: Dict[bytes, List[Dict]] = {sha1: [] for sha1 in contents} | contents_by_sha1: Dict[Sha1, Optional[Content]] = {} | ||||
for sha1 in contents: | for sha1 in contents: | ||||
# Get all (sha1, sha1_git, sha256, blake2s256) whose sha1 | # Get all (sha1, sha1_git, sha256, blake2s256) whose sha1 | ||||
# matches the argument, from the index table ('content_by_sha1') | # matches the argument, from the index table ('content_by_sha1') | ||||
for row in self._content_get_from_hash("sha1", sha1): | for row in self._content_get_from_hash("sha1", sha1): | ||||
content_metadata = row._asdict() | row_d = row._asdict() | ||||
content_metadata.pop("ctime") | row_d.pop("ctime") | ||||
ardumont: Why do we pop the ctime again? | |||||
Not Done Inline Actionsno idea, I just copied the pg storage's behavior. vlorentz: no idea, I just copied the pg storage's behavior. | |||||
result[content_metadata["sha1"]].append(content_metadata) | content = Content(**row_d) | ||||
return result | contents_by_sha1[content.sha1] = content | ||||
return [contents_by_sha1.get(sha1) for sha1 in contents] | |||||
def content_find(self, content: Dict[str, Any]) -> List[Content]: | def content_find(self, content: Dict[str, Any]) -> List[Content]: | ||||
# Find an algorithm that is common to all the requested contents. | # Find an algorithm that is common to all the requested contents. | ||||
# It will be used to do an initial filtering efficiently. | # It will be used to do an initial filtering efficiently. | ||||
filter_algos = list(set(content).intersection(HASH_ALGORITHMS)) | filter_algos = list(set(content).intersection(HASH_ALGORITHMS)) | ||||
if not filter_algos: | if not filter_algos: | ||||
raise StorageArgumentException( | raise StorageArgumentException( | ||||
"content keys must contain at least one " | "content keys must contain at least one " | ||||
▲ Show 20 Lines • Show All 1,038 Lines • Show Last 20 Lines |
Why do we pop the ctime again?