Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cassandra/cql.py
Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | class CqlRunner: | ||||
@_prepared_statement("SELECT id FROM revision WHERE id IN ?") | @_prepared_statement("SELECT id FROM revision WHERE id IN ?") | ||||
def revision_get_ids(self, revision_ids, *, statement) -> Iterable[int]: | def revision_get_ids(self, revision_ids, *, statement) -> Iterable[int]: | ||||
return ( | return ( | ||||
row["id"] for row in self._execute_with_retries(statement, [revision_ids]) | row["id"] for row in self._execute_with_retries(statement, [revision_ids]) | ||||
) | ) | ||||
@_prepared_select_statement(RevisionRow, "WHERE id IN ?") | @_prepared_select_statement(RevisionRow, "WHERE id IN ?") | ||||
def revision_get(self, revision_ids, *, statement) -> Iterable[RevisionRow]: | def revision_get( | ||||
self, revision_ids: List[Sha1Git], *, statement | |||||
) -> Iterable[RevisionRow]: | |||||
return map( | return map( | ||||
RevisionRow.from_dict, self._execute_with_retries(statement, [revision_ids]) | RevisionRow.from_dict, self._execute_with_retries(statement, [revision_ids]) | ||||
) | ) | ||||
@_prepared_select_statement(RevisionRow, "WHERE token(id) > ? LIMIT 1") | @_prepared_select_statement(RevisionRow, "WHERE token(id) > ? LIMIT 1") | ||||
def revision_get_random(self, *, statement) -> Optional[RevisionRow]: | def revision_get_random(self, *, statement) -> Optional[RevisionRow]: | ||||
return self._get_random_row(RevisionRow, statement) | return self._get_random_row(RevisionRow, statement) | ||||
▲ Show 20 Lines • Show All 550 Lines • Show Last 20 Lines |