Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/storage.py
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | ): | ||||
* batch: using UNLOGGED BATCH to insert many entries in a few statements | * batch: using UNLOGGED BATCH to insert many entries in a few statements | ||||
""" | """ | ||||
self._hosts = hosts | self._hosts = hosts | ||||
self._keyspace = keyspace | self._keyspace = keyspace | ||||
self._port = port | self._port = port | ||||
self._consistency_level = consistency_level | self._consistency_level = consistency_level | ||||
self._set_cql_runner() | self._set_cql_runner() | ||||
self.journal_writer: JournalWriter = JournalWriter(journal_writer) | self.journal_writer: JournalWriter = JournalWriter(journal_writer) | ||||
self.objstorage: ObjStorage = ObjStorage(objstorage) | self.objstorage: ObjStorage = ObjStorage(self, objstorage) | ||||
self._allow_overwrite = allow_overwrite | self._allow_overwrite = allow_overwrite | ||||
if directory_entries_insert_algo not in DIRECTORY_ENTRIES_INSERT_ALGOS: | if directory_entries_insert_algo not in DIRECTORY_ENTRIES_INSERT_ALGOS: | ||||
raise ValueError( | raise ValueError( | ||||
f"directory_entries_insert_algo must be one of: " | f"directory_entries_insert_algo must be one of: " | ||||
f"{', '.join(DIRECTORY_ENTRIES_INSERT_ALGOS)}" | f"{', '.join(DIRECTORY_ENTRIES_INSERT_ALGOS)}" | ||||
) | ) | ||||
self._directory_entries_insert_algo = directory_entries_insert_algo | self._directory_entries_insert_algo = directory_entries_insert_algo | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | class CassandraStorage: | ||||
) -> None: | ) -> None: | ||||
raise NotImplementedError( | raise NotImplementedError( | ||||
"content_update is not supported by the Cassandra backend" | "content_update is not supported by the Cassandra backend" | ||||
) | ) | ||||
def content_add_metadata(self, content: List[Content]) -> Dict[str, int]: | def content_add_metadata(self, content: List[Content]) -> Dict[str, int]: | ||||
return self._content_add(content, with_data=False) | return self._content_add(content, with_data=False) | ||||
def content_get_data(self, content: Sha1) -> Optional[bytes]: | def content_get_data(self, content: Union[Sha1, HashDict]) -> Optional[bytes]: | ||||
# FIXME: Make this method support slicing the `data` | # FIXME: Make this method support slicing the `data` | ||||
return self.objstorage.content_get(content) | return self.objstorage.content_get(content) | ||||
def content_get_partition( | def content_get_partition( | ||||
self, | self, | ||||
partition_id: int, | partition_id: int, | ||||
nb_partitions: int, | nb_partitions: int, | ||||
page_token: Optional[str] = None, | page_token: Optional[str] = None, | ||||
▲ Show 20 Lines • Show All 1,477 Lines • Show Last 20 Lines |