Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_cassandra_migration.py
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | ) -> Optional[ContentRow]: | ||||
return ContentRowWithXor(**rows[0]) | return ContentRowWithXor(**rows[0]) | ||||
else: | else: | ||||
return None | return None | ||||
@_prepared_select_statement( | @_prepared_select_statement( | ||||
ContentRowWithXor, | ContentRowWithXor, | ||||
f"WHERE token({', '.join(ContentRowWithXor.PARTITION_KEY)}) = ?", | f"WHERE token({', '.join(ContentRowWithXor.PARTITION_KEY)}) = ?", | ||||
) | ) | ||||
def content_get_from_token( | def content_get_from_tokens( | ||||
self, token, *, statement | self, tokens, *, statement | ||||
) -> Iterable[ContentRowWithXor]: | ) -> Iterable[ContentRowWithXor]: | ||||
return map( | return map( | ||||
ContentRowWithXor.from_dict, self._execute_with_retries(statement, [token]) | ContentRowWithXor.from_dict, | ||||
self._execute_many_with_retries(statement, [(token,) for token in tokens]), | |||||
) | ) | ||||
# Redecorate content_add_prepare with the new ContentRow class | # Redecorate content_add_prepare with the new ContentRow class | ||||
content_add_prepare = _prepared_insert_statement(ContentRowWithXor)( # type: ignore | content_add_prepare = _prepared_insert_statement(ContentRowWithXor)( # type: ignore | ||||
CqlRunner.content_add_prepare.__wrapped__ # type: ignore | CqlRunner.content_add_prepare.__wrapped__ # type: ignore | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | ) -> Optional[ContentRow]: | ||||
return ContentRowWithXorPK(**rows[0]) | return ContentRowWithXorPK(**rows[0]) | ||||
else: | else: | ||||
return None | return None | ||||
@_prepared_select_statement( | @_prepared_select_statement( | ||||
ContentRowWithXorPK, | ContentRowWithXorPK, | ||||
f"WHERE token({', '.join(ContentRowWithXorPK.PARTITION_KEY)}) = ?", | f"WHERE token({', '.join(ContentRowWithXorPK.PARTITION_KEY)}) = ?", | ||||
) | ) | ||||
def content_get_from_token( | def content_get_from_tokens( | ||||
self, token, *, statement | self, tokens, *, statement | ||||
) -> Iterable[ContentRowWithXorPK]: | ) -> Iterable[ContentRowWithXorPK]: | ||||
return map( | return map( | ||||
ContentRowWithXorPK.from_dict, | ContentRowWithXorPK.from_dict, | ||||
self._execute_with_retries(statement, [token]), | self._execute_many_with_retries(statement, [(token,) for token in tokens]), | ||||
) | ) | ||||
# Redecorate content_add_prepare with the new ContentRow class | # Redecorate content_add_prepare with the new ContentRow class | ||||
content_add_prepare = _prepared_insert_statement(ContentRowWithXorPK)( # type: ignore # noqa | content_add_prepare = _prepared_insert_statement(ContentRowWithXorPK)( # type: ignore # noqa | ||||
CqlRunner.content_add_prepare.__wrapped__ # type: ignore | CqlRunner.content_add_prepare.__wrapped__ # type: ignore | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |