Index

Handle for an index attached to a NDArray or CTable.

Index objects are returned by NDArray indexing APIs such as blosc2.NDArray.create_index(), blosc2.NDArray.index(), and blosc2.NDArray.indexes, and by the equivalent CTable indexing APIs. Use this handle to inspect index metadata and storage usage, or to drop, rebuild, and compact the index. Users normally do not instantiate Index directly.

class blosc2.Index(array: NDArray | None, token: str, *, table=None, descriptor: dict | None = None)[source]

Handle for an index attached to an blosc2.NDArray.

Index objects are returned by NDArray indexing helpers such as blosc2.NDArray.create_index(), blosc2.NDArray.index(), and blosc2.NDArray.indexes, and by the equivalent blosc2.CTable helpers. They expose descriptor metadata and convenience methods for dropping, rebuilding, or compacting the underlying index. Users should not instantiate this class directly.

Attributes:
cbytes

Total compressed size in bytes for this index payload.

col_name

CTable lookup key for this index target, if this is a table index.

cratio

Compression ratio for this index payload.

descriptor

Copy of the index descriptor dictionary.

field

Structured-array field indexed by this handle, if any.

kind

Kind of index.

name

Optional human-readable name assigned at creation time.

nbytes

Total uncompressed size in bytes for this index payload.

persistent

True when index sidecars are stored persistently on disk.

stale

True if the index needs rebuilding before it can be reused.

target

Descriptor of the indexed target.

Methods

compact()

Compact this index, merging incremental runs, and return the updated handle.

drop()

Drop this index and delete its sidecar payloads.

get(k[,d])

items()

keys()

rebuild()

Rebuild this index and return the updated handle.

storage_stats()

Return (nbytes, cbytes, cratio) when sidecars are directly measurable.

values()

Index.descriptor

Copy of the index descriptor dictionary.

Index.kind

Kind of index.

NDArray indexes return blosc2.IndexKind; table indexes keep the catalog kind string used by CTable descriptors.

Index.col_name

CTable lookup key for this index target, if this is a table index.

Index.field

Structured-array field indexed by this handle, if any.

Index.name

Optional human-readable name assigned at creation time.

Index.target

Descriptor of the indexed target.

Index.persistent

True when index sidecars are stored persistently on disk.

Index.stale

True if the index needs rebuilding before it can be reused.

Index.nbytes

Total uncompressed size in bytes for this index payload.

Index.cbytes

Total compressed size in bytes for this index payload.

Index.cratio

Compression ratio for this index payload.

Index.storage_stats() tuple[int, int, float] | None[source]

Return (nbytes, cbytes, cratio) when sidecars are directly measurable.

Index.__getitem__(key)[source]

Return a descriptor value by key.

Index.__iter__()[source]

Iterate over descriptor keys.

Index.__len__() int[source]

Number of keys in the descriptor mapping.

Index.drop() None[source]

Drop this index and delete its sidecar payloads.

Index.rebuild() Index[source]

Rebuild this index and return the updated handle.

Index.compact() Index[source]

Compact this index, merging incremental runs, and return the updated handle.