Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/cql.py
Show First 20 Lines • Show All 1,346 Lines • ▼ Show 20 Lines | @_prepared_select_statement( | ||||
"AND target_type=? AND target=?", | "AND target_type=? AND target=?", | ||||
) | ) | ||||
def extid_get_from_pk( | def extid_get_from_pk( | ||||
self, | self, | ||||
extid_type: str, | extid_type: str, | ||||
extid: bytes, | extid: bytes, | ||||
extid_version: int, | extid_version: int, | ||||
target: CoreSWHID, | target: CoreSWHID, | ||||
payload_type: str, | |||||
payload: Sha1Git, | |||||
*, | *, | ||||
statement, | statement, | ||||
) -> Optional[ExtIDRow]: | ) -> Optional[ExtIDRow]: | ||||
rows = list( | rows = list( | ||||
self._execute_with_retries( | self._execute_with_retries( | ||||
statement, | statement, | ||||
[ | [ | ||||
extid_type, | extid_type, | ||||
extid, | extid, | ||||
extid_version, | extid_version, | ||||
target.object_type.value, | target.object_type.value, | ||||
target.object_id, | target.object_id, | ||||
payload_type, | |||||
payload, | |||||
], | ], | ||||
), | ), | ||||
) | ) | ||||
assert len(rows) <= 1 | assert len(rows) <= 1 | ||||
if rows: | if rows: | ||||
return ExtIDRow(**rows[0]) | return ExtIDRow(**rows[0]) | ||||
else: | else: | ||||
return None | return None | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |