Lazy loading¶
The ZarrVectorStore class provides a lazy, level-of-detail-aware
interface for reading ZVF stores without loading all data into memory.
It is the recommended interface for remote stores, large datasets, and
interactive applications.
Lazy zarr vectors store access.
Opens a store without reading data. All vertex, attribute, and object
access is deferred until .compute() is called, optionally using
Dask for parallel I/O.
Usage:
from zarr_vectors.lazy import open_zv
zv = open_zv("scan.zarrvectors")
zv[0].vertices.compute() # materialise all level-0 vertices
zv[0].vertices[0, 0, 0].compute() # single chunk
zv[0].attributes["intensity"].compute()
- class zarr_vectors.lazy.ZVPolylineCollection(group, ndim=3)[source]¶
Bases:
objectLazy collection of polylines accessible by object ID.
Each polyline is reconstructed by following its object_index manifest and concatenating vertex groups from the relevant chunks.
- class zarr_vectors.lazy.ZVStore(root, meta)[source]¶
Bases:
objectLazy handle to a zarr vectors store.
Attributes are read from
.zattrson first access and cached. Resolution levels are accessed by integer index via__getitem__.- Parameters:
root (Group) – An open
FsGroupfor the store root.meta (RootMetadata) – Parsed
RootMetadata.
- property headers: dict[str, dict[str, Any]]¶
Dict of stored format headers, keyed by format name.
- Returns:
{format_name: header_dict}for each stored header. Empty dict if no headers are stored. Typed deserialisation of header dicts is handled by the format package.
- object_levels(oid)[source]¶
Monotonically-increasing list of levels at which
oidis present.For an ID-preserving pyramid, this is the set of LODs a viewer can pick for the object — the object’s OID is stable across levels and the object is present at level $L$ iff its manifest at level $L$ is non-empty.
Returns
[]if the object is absent from every level.
- set_backend(backend, **backend_kwargs)[source]¶
Swap the underlying storage backend in place (no data movement).
Useful for switching driver (e.g.
"fsspec"→"obstore") or credentials on a store you already have open. Any cached level / array handles are invalidated and will be rebuilt on the next access using the new backend.- Parameters:
backend (str | StorageBackend) – Backend name string or a pre-built
StorageBackendalready pointed at the same URL.**backend_kwargs (Any) – Forwarded to the backend constructor when
backendis a string.
- Return type:
None
- class zarr_vectors.lazy.ZVView(group, root_meta, level_meta, all_chunk_keys, spec)[source]¶
Bases:
objectA filtered lazy view of a resolution level.
Created by calling
.filter()on aZVLevelor anotherZVView. Each filter narrows the read plan; data is only loaded on.compute().- Parameters:
- filter(*, bbox=None, object_ids=None, group_ids=None)[source]¶
Apply additional filter constraints, returning a new view.
- Parameters:
- Returns:
A new
ZVViewwith the intersection of all constraints.- Return type:
- property vertices: _FilteredVertices¶
Lazy filtered vertex accessor.
- zarr_vectors.lazy.open_zv(path, *, backend=None, **backend_kwargs)[source]¶
Open a zarr vectors store lazily.
Reads only root metadata (a few KB). No vertex data is loaded.
- Parameters:
- Returns:
A
ZVStorehandle for lazy access.- Return type: