SQL Storage

A CAS storage which stores blobs in a SQL database

class*args, **kwargs)

Bases: dict

digest_hash: str
digest_size_bytes: int
data: bytes
class SqlProvider, *, sql_ro_provider: SqlProvider | None = None)

Bases: StorageABC

has_blob(digest: Digest) bool

Return True if the blob with the given instance/digest exists.

get_blob(digest: Digest) IO[bytes] | None

Return a file-like object containing the blob. Most implementations will read the entire file into memory and return a BytesIO object. Eventually this should be corrected to handle files which cannot fit into memory.

The file-like object must be readable and seekable.

If the blob isn’t present in storage, return None.

delete_blob(digest: Digest) None

Delete the blob from storage if it’s present.

commit_write(digest: Digest, write_session: IO[bytes]) None

Store the contents for a digest.

The storage object is not responsible for verifying that the data written to the write_session actually matches the digest. The caller must do that.

missing_blobs(digests: List[Digest]) List[Digest]

Return a container containing the blobs not present in CAS.

bulk_update_blobs(digest_blob_pairs: List[Tuple[Digest, bytes]]) List[Status]

Implement the StorageABC’s bulk_update_blobs method.

The StorageABC interface takes in a list of digest/blob pairs and returns a list of results. The list of results MUST be ordered to correspond with the order of the input list.

bulk_read_blobs(digests: List[Digest]) Dict[str, bytes]

Given an iterable container of digests, return a {hash: file-like object} dictionary corresponding to the blobs represented by the input digests.

Each file-like object must be readable and seekable.

bulk_delete(digests: List[Digest]) List[str]

Delete a list of blobs from storage.