Blosc
blosc
Partial decoding of Blosc-1 frames: read only the blocks covering a byte range.
A Blosc-1 frame is header(16 B) | bstarts(int32 * nblocks) | block payloads
where every block except the last holds blocksize uncompressed bytes and is
compressed independently (shuffle is applied per block). Given the header and
the offsets table, a contiguous run of blocks can be fetched with one HTTP range
request and re-framed into a smaller valid Blosc frame that the regular
decoder (numcodecs) decompresses. Format reference: c-blosc README_HEADER.
BloscHeader
dataclass
Blosc-1 frame header with the start and end offset of every block.
Source code in packages/barograph-met/src/baro/met/blosc.py
header_size
property
Bytes of header plus block-offset table.
nblocks
property
Number of compressed blocks.
block_span(i)
blocks_for(start, stop)
Decodable inclusive block range covering uncompressed bytes [start, stop).
A trailing partial ("leftover") block is decoded with different split
rules than a full block, and a frame whose nbytes is below its
blocksize is rejected by the decoder. A run made of the leftover
block alone is therefore widened to include the preceding block.
Source code in packages/barograph-met/src/baro/met/blosc.py
compressed_span(first, last)
Smallest compressed byte span [start, stop) holding blocks first..last.
Multi-threaded compressors may store blocks out of order; the span is then a covering range that can include unrelated blocks (still valid).
Source code in packages/barograph-met/src/baro/met/blosc.py
UnsupportedFrameError
decode_run(header, first, last, payload)
Decode blocks first..last from their compressed payload.
payload must be exactly frame[compressed_span(first, last)]. Returns
the uncompressed bytes frame_uncompressed[block_span(first)[0]:block_span(last)[1]].
Source code in packages/barograph-met/src/baro/met/blosc.py
header_prefix_size(first16)
Total header size (header + offsets) announced by the first 16 bytes.
Source code in packages/barograph-met/src/baro/met/blosc.py
parse_header(prefix)
Parse a Blosc-1 header and its block-offset table from a frame prefix.