diff --git a/swh/storage/cassandra/cql.py b/swh/storage/cassandra/cql.py --- a/swh/storage/cassandra/cql.py +++ b/swh/storage/cassandra/cql.py @@ -900,11 +900,11 @@ @_prepared_select_statement( RawExtrinsicMetadataRow, - "WHERE id=? AND authority_url=? AND discovery_date>? AND authority_type=?", + "WHERE target=? AND authority_url=? AND discovery_date>? AND authority_type=?", ) def raw_extrinsic_metadata_get_after_date( self, - id: str, + target: str, authority_type: str, authority_url: str, after: datetime.datetime, @@ -914,18 +914,18 @@ return map( RawExtrinsicMetadataRow.from_dict, self._execute_with_retries( - statement, [id, authority_url, after, authority_type] + statement, [target, authority_url, after, authority_type] ), ) @_prepared_select_statement( RawExtrinsicMetadataRow, - "WHERE id=? AND authority_type=? AND authority_url=? " + "WHERE target=? AND authority_type=? AND authority_url=? " "AND (discovery_date, fetcher_name, fetcher_version) > (?, ?, ?)", ) def raw_extrinsic_metadata_get_after_date_and_fetcher( self, - id: str, + target: str, authority_type: str, authority_url: str, after_date: datetime.datetime, @@ -939,7 +939,7 @@ self._execute_with_retries( statement, [ - id, + target, authority_type, authority_url, after_date, @@ -950,14 +950,17 @@ ) @_prepared_select_statement( - RawExtrinsicMetadataRow, "WHERE id=? AND authority_url=? AND authority_type=?" + RawExtrinsicMetadataRow, + "WHERE target=? AND authority_url=? AND authority_type=?", ) def raw_extrinsic_metadata_get( - self, id: str, authority_type: str, authority_url: str, *, statement + self, target: str, authority_type: str, authority_url: str, *, statement ) -> Iterable[RawExtrinsicMetadataRow]: return map( RawExtrinsicMetadataRow.from_dict, - self._execute_with_retries(statement, [id, authority_url, authority_type]), + self._execute_with_retries( + statement, [target, authority_url, authority_type] + ), ) ########################## diff --git a/swh/storage/cassandra/model.py b/swh/storage/cassandra/model.py --- a/swh/storage/cassandra/model.py +++ b/swh/storage/cassandra/model.py @@ -236,7 +236,7 @@ @dataclasses.dataclass class RawExtrinsicMetadataRow(BaseRow): TABLE = "raw_extrinsic_metadata" - PARTITION_KEY = ("id",) + PARTITION_KEY = ("target",) CLUSTERING_KEY = ( "authority_type", "authority_url", @@ -246,7 +246,7 @@ ) type: str - id: str + target: str authority_type: str authority_url: str diff --git a/swh/storage/cassandra/schema.py b/swh/storage/cassandra/schema.py --- a/swh/storage/cassandra/schema.py +++ b/swh/storage/cassandra/schema.py @@ -206,7 +206,7 @@ CREATE TABLE IF NOT EXISTS raw_extrinsic_metadata ( type text, - id text, + target text, -- metadata source authority_type text, @@ -228,8 +228,8 @@ path blob, directory text, - PRIMARY KEY ((id), authority_type, authority_url, discovery_date, - fetcher_name, fetcher_version) + PRIMARY KEY ((target), authority_type, authority_url, discovery_date, + fetcher_name, fetcher_version) ); diff --git a/swh/storage/cassandra/storage.py b/swh/storage/cassandra/storage.py --- a/swh/storage/cassandra/storage.py +++ b/swh/storage/cassandra/storage.py @@ -1148,7 +1148,7 @@ try: row = RawExtrinsicMetadataRow( type=metadata_entry.type.value, - id=str(metadata_entry.target), + target=str(metadata_entry.target), authority_type=metadata_entry.authority.type.value, authority_url=metadata_entry.authority.url, discovery_date=metadata_entry.discovery_date, @@ -1222,7 +1222,7 @@ for entry in entries: discovery_date = entry.discovery_date.replace(tzinfo=datetime.timezone.utc) - assert str(id) == entry.id + assert str(id) == entry.target result = RawExtrinsicMetadata( type=MetadataTargetType(entry.type), diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -573,24 +573,26 @@ def raw_extrinsic_metadata_get_after_date( self, - id: str, + target: str, authority_type: str, authority_url: str, after: datetime.datetime, ) -> Iterable[RawExtrinsicMetadataRow]: - metadata = self.raw_extrinsic_metadata_get(id, authority_type, authority_url) + metadata = self.raw_extrinsic_metadata_get( + target, authority_type, authority_url + ) return (m for m in metadata if m.discovery_date > after) def raw_extrinsic_metadata_get_after_date_and_fetcher( self, - id: str, + target: str, authority_type: str, authority_url: str, after_date: datetime.datetime, after_fetcher_name: str, after_fetcher_version: str, ) -> Iterable[RawExtrinsicMetadataRow]: - metadata = self._raw_extrinsic_metadata.get_from_partition_key((id,)) + metadata = self._raw_extrinsic_metadata.get_from_partition_key((target,)) after_tuple = (after_date, after_fetcher_name, after_fetcher_version) return ( m @@ -601,9 +603,9 @@ ) def raw_extrinsic_metadata_get( - self, id: str, authority_type: str, authority_url: str + self, target: str, authority_type: str, authority_url: str ) -> Iterable[RawExtrinsicMetadataRow]: - metadata = self._raw_extrinsic_metadata.get_from_partition_key((id,)) + metadata = self._raw_extrinsic_metadata.get_from_partition_key((target,)) return ( m for m in metadata