Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/cql.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | from .model import ( | ||||
ExtIDByTargetRow, | ExtIDByTargetRow, | ||||
ExtIDRow, | ExtIDRow, | ||||
MetadataAuthorityRow, | MetadataAuthorityRow, | ||||
MetadataFetcherRow, | MetadataFetcherRow, | ||||
ObjectCountRow, | ObjectCountRow, | ||||
OriginRow, | OriginRow, | ||||
OriginVisitRow, | OriginVisitRow, | ||||
OriginVisitStatusRow, | OriginVisitStatusRow, | ||||
RawExtrinsicMetadataByIdRow, | |||||
RawExtrinsicMetadataRow, | RawExtrinsicMetadataRow, | ||||
ReleaseRow, | ReleaseRow, | ||||
RevisionParentRow, | RevisionParentRow, | ||||
RevisionRow, | RevisionRow, | ||||
SkippedContentRow, | SkippedContentRow, | ||||
SnapshotBranchRow, | SnapshotBranchRow, | ||||
SnapshotRow, | SnapshotRow, | ||||
content_index_table_name, | content_index_table_name, | ||||
▲ Show 20 Lines • Show All 954 Lines • ▼ Show 20 Lines | class CqlRunner: | ||||
) -> Optional[MetadataFetcherRow]: | ) -> Optional[MetadataFetcherRow]: | ||||
rows = list(self._execute_with_retries(statement, [name, version])) | rows = list(self._execute_with_retries(statement, [name, version])) | ||||
if rows: | if rows: | ||||
return MetadataFetcherRow.from_dict(rows[0]) | return MetadataFetcherRow.from_dict(rows[0]) | ||||
else: | else: | ||||
return None | return None | ||||
######################### | ######################### | ||||
# 'raw_extrinsic_metadata_by_id' table | |||||
######################### | |||||
@_prepared_insert_statement(RawExtrinsicMetadataByIdRow) | |||||
def raw_extrinsic_metadata_by_id_add(self, row, *, statement): | |||||
self._add_one(statement, row) | |||||
@_prepared_select_statement(RawExtrinsicMetadataByIdRow, "WHERE id IN ?") | |||||
def raw_extrinsic_metadata_get_by_ids( | |||||
self, ids: List[Sha1Git], *, statement | |||||
) -> Iterable[RawExtrinsicMetadataByIdRow]: | |||||
return map( | |||||
RawExtrinsicMetadataByIdRow.from_dict, | |||||
self._execute_with_retries(statement, [ids]), | |||||
) | |||||
######################### | |||||
# 'raw_extrinsic_metadata' table | # 'raw_extrinsic_metadata' table | ||||
######################### | ######################### | ||||
@_prepared_insert_statement(RawExtrinsicMetadataRow) | @_prepared_insert_statement(RawExtrinsicMetadataRow) | ||||
def raw_extrinsic_metadata_add(self, raw_extrinsic_metadata, *, statement): | def raw_extrinsic_metadata_add(self, raw_extrinsic_metadata, *, statement): | ||||
self._add_one(statement, raw_extrinsic_metadata) | self._add_one(statement, raw_extrinsic_metadata) | ||||
@_prepared_select_statement( | @_prepared_select_statement( | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |