AddressReader#
- class lsst.pipe.base.quantum_graph.AddressReader(stream: ~typing.IO[bytes], int_size: int, n_rows: int, n_addresses: int, rows_per_page: int, rows: dict[~uuid.UUID, ~lsst.pipe.base.quantum_graph._multiblock.AddressRow] = <factory>, pages: list[~lsst.pipe.base.quantum_graph._multiblock.AddressPage] = <factory>, page_bounds: dict[int, ~lsst.pipe.base.quantum_graph._multiblock.PageBounds] = <factory>)#
Bases:
objectA helper object for reading address files for multi-block files.
Attributes Summary
Size of each integer in bytes.
Number of addresses in each row.
Number of rows in the file.
Mapping from page index to page boundary information.
Descriptions of the file offsets and integer row indexes of pages and flags for whether they have been read already.
The size (in bytes) of each row of this address file.
Rows that have already been read.
Number of addresses in each page.
Stream to read from.
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 or integer index.
from_stream(stream, *, page_size, ...)Construct from a stream by reading the header.
open_in_zip(zf, name, *, page_size, ...)Make a reader for an address file in a zip archive.
read_all()Read all addresses in the file.
Attributes Documentation
- int_size: int = <dataclasses._MISSING_TYPE object>#
Size of each integer in bytes.
- n_addresses: int = <dataclasses._MISSING_TYPE object>#
Number of addresses in each row.
- n_rows: int = <dataclasses._MISSING_TYPE object>#
Number of rows in the file.
- page_bounds: dict[int, PageBounds] = <dataclasses._MISSING_TYPE object>#
Mapping from page index to page boundary information.
- pages: list[AddressPage] = <dataclasses._MISSING_TYPE object>#
Descriptions of the file offsets and integer row indexes of pages and flags for whether they have been read already.
- row_size#
The size (in bytes) of each row of this address file.
- rows: dict[UUID, AddressRow] = <dataclasses._MISSING_TYPE object>#
Rows that have already been read.
- rows_per_page: int = <dataclasses._MISSING_TYPE object>#
Number of addresses in each page.
- stream: IO[bytes] = <dataclasses._MISSING_TYPE object>#
Stream to read from.
Methods Documentation
- static compute_header_size(int_size: int) int#
Return the size (in bytes) of the header of an address file.
Parameters#
- int_size
int Size of each integer in bytes.
Returns#
- size
int Size of the header in bytes.
- int_size
- static compute_row_size(int_size: int, n_addresses: int) int#
Return the size (in bytes) of each row of an address file.
Parameters#
- int_size
int Size of each integer in bytes.
- n_addresses
int Number of addresses in each row.
Returns#
- size
int Size of each row in bytes.
- int_size
- find(key: UUID) AddressRow#
Read the row for the given UUID or integer index.
Parameters#
- key
uuid.UUID UUID to find.
Returns#
- row
AddressRow Addresses for the given UUID.
- key
- classmethod from_stream(stream: IO[bytes], *, page_size: int, n_addresses: int, int_size: int) AddressReader#
Construct from a stream by reading the header.
Parameters#
- stream
typing.IO[bytes] File-like object to read from.
- page_size
int Approximate number of bytes to read at a time when searching for an address.
- n_addresses
int Number of addresses to expect per row. This is checked against the size embedded in the file.
- int_size
int Number of bytes to use for all integers. This is checked against the size embedded in the file.
- stream
- classmethod open_in_zip(zf: zipfile.ZipFile, name: str, *, page_size: int, n_addresses: int, int_size: int) 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.
- n_addresses
int Number of addresses to expect per row. This is checked against the size embedded in the file.
- int_size
int Number of bytes to use for all integers. This is checked against the size embedded in the file.
Returns#
- reader
contextlib.AbstractContextManager[AddressReader] Context manager that returns a reader when entered.
- zf
- read_all() dict[UUID, AddressRow]#
Read all addresses in the file.
Returns#
- rows
dict[uuid.UUID,AddressRow] Mapping of loaded address rows, keyed by UUID.
- rows