AddressReader¶
- class lsst.pipe.base.quantum_graph.AddressReader(stream: IO[bytes], int_size: int, n_rows: int, n_addresses: int, start_index: int, rows: dict[uuid.UUID, lsst.pipe.base.quantum_graph._multiblock.AddressRow], rows_per_page: int, unread_pages: dict[int, int])¶
Bases:
object
A helper object for reading address files for multi-block files.
Attributes Summary
The maximum value of a UUID's integer form.
The size (in bytes) of the header of this address file.
The size (in bytes) of each row of this address file.
Methods Summary
compute_header_size
(int_size)Return the size (in bytes) of the header of an address file.
compute_row_size
(int_size, n_addresses)Return the size (in bytes) of each row of an address file.
find
(key)Read the row for the given UUID.
from_stream
(stream, page_size[, start_index])Construct from a stream by reading the header.
open_in_zip
(zf, name, page_size[, int_size, ...])Make a reader for an address file in a zip archive.
read_all
()Read all addresses in the file.
Attributes Documentation
- MAX_UUID_INT: ClassVar[int] = 340282366920938463463374607431768211456¶
The maximum value of a UUID’s integer form.
- header_size¶
The size (in bytes) of the header of this address file.
- row_size¶
The size (in bytes) of each row of this address file.
Methods Documentation
- static compute_header_size(int_size: int) int ¶
Return the size (in bytes) of the header of an address file.
- static compute_row_size(int_size: int, n_addresses: int) int ¶
Return the size (in bytes) of each row of an address file.
- find(key: UUID) AddressRow ¶
Read the row for the given UUID.
- Parameters:
- key
uuid.UUID
UUID to find.
- key
- Returns:
- row
AddressRow
Addresses for the given UUID.
- row
- classmethod from_stream(stream: IO[bytes], page_size: int, start_index: int = 0) AddressReader ¶
Construct from a stream by reading the header.
- classmethod open_in_zip(zf: zipfile.ZipFile, name: str, page_size: int, int_size: int | None = None, start_index: int = 0) Iterator[AddressReader] ¶
Make a reader for an address file in a zip archive.
- Parameters:
- zf
zipfile.ZipFile
Zip archive to read the file from.
- name
str
Base name for the address file; an extension will be added.
- page_size
int
Approximate number of bytes to read at a time when searching for an address.
- int_size
int
, optional Number of bytes to use for all integers. This is checked against the size embedded in the file.
- start_index
int
, optional Value of the first index in the file.
- zf
- Returns:
- reader
contextlib.AbstractContextManager
[AddressReader
] Context manager that returns a reader when entered.
- reader
- read_all() dict[uuid.UUID, lsst.pipe.base.quantum_graph._multiblock.AddressRow] ¶
Read all addresses in the file.
- Returns:
- rows
dict
[uuid.UUID
,AddressRow
] Mapping of loaded address rows, keyed by UUID.
- rows