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=None, max_concurrency=8, *, path=None, storage_options=None, _filesystem=None, _traffic=None, _archive=None, _seed=None, _source_cache_dir=None)[source]

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

path (or its supported alias 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.

cbytes

Compressed payload bytes recorded in the native frame header.

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
storage_nbytes

Uncompressed stored bytes, including padding, as for SChunk.nbytes.

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.

frame_index_reads()

Yield index ranges for an immutable source; parse on the caller thread.

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=None, max_concurrency=8, *, path=None, storage_options=None, _filesystem=None, _traffic=None, _archive=None, _seed=None, _source_cache_dir=None)[source]