B2ZNDSource

B2ZNDSource exposes an external NDArray member inside an immutable .b2z archive through ByteRangeNDSource. Chunks and blocks are read directly from the ZIP member using native Blosc2 range reads without decompressing or downloading the archive.

The source is assumed immutable (assume_immutable=True). It requires an explicit dataset path pointing to an uncompressed (ZIP_STORED) external NDArray member. Embedded leaves and CTable columns are not supported.

Install support with pip install "blosc2[fsspec]" plus the protocol driver, such as s3fs for S3.

class blosc2.B2ZNDSource(urlpath, dataset, max_concurrency=8, *, storage_options=None, _filesystem=None, _traffic=None, _archive=None)[source]

Read a stored external NDArray from an immutable B2Z archive via fsspec.

dataset is a logical tree key, e.g. d0/a3, without the member’s .b2nd suffix. Embedded leaves and ZIP-compressed members are unsupported. Opening uses bounded metadata prefetch; native chunks and blocks are fetched on demand. Replacing the archive requires replacing its cache.

Attributes:
attrs

The user attributes of the remote frame.

blocks

The block shape of the source.

chunks

The chunk shape of the source.

cparams

The compression parameters of the source.

dtype

The dtype of the source.

has_vlmetalayers

Whether the underlying frame has variable-length metalayers.

meta

Fixed-length metadata of the remote frame.

shape

The shape of the source.

stamp
vlmeta

Variable-length metadata of the remote frame.

Methods

aget_chunk(nchunk)

Same as get_chunk(), but without blocking the caller's event loop.

block_plan(nchunk, nblocks)

The range reads that cover nblocks, near-adjacent ones merged.

chunk_layout(nchunk)

Read where the blocks of a chunk are: its header, bstarts and extents.

chunk_layouts(nchunks)

chunk_layout() for several chunks, in as few requests as they fit.

get_chunk(nchunk)

Return the compressed chunk in self.

invalidate_index()

Forget where the chunks and blocks are, so the next read looks again.

read_range(offset, size)

The bytes at [offset, offset + size) of the frame.

read_ranges(spans)

The bytes of every (offset, size) in spans, in that order.

wants_blocks(nchunk, nwanted[, wave, nruns])

Whether fetching nwanted blocks of a chunk beats fetching all of it.

written_chunks()

Which chunks of the frame hold content, as a boolean per chunk.

__init__(urlpath, dataset, max_concurrency=8, *, storage_options=None, _filesystem=None, _traffic=None, _archive=None)[source]