Index

Handle for an index attached to a NDArray.

Index objects are returned by NDArray indexing APIs such as blosc2.NDArray.create_index(), blosc2.NDArray.index(), and blosc2.NDArray.indexes. 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.

For table indexes, blosc2.ctable.CTableIndex plays the same user-facing role for CTable objects. It is documented in the CTable reference because table indexes can target columns and table expressions.

class blosc2.Index(array: NDArray, token: str)[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. They expose descriptor metadata and convenience methods for dropping, rebuilding, or compacting the underlying index. blosc2.ctable.CTableIndex plays the same user-facing role for blosc2.CTable indexes. Users should not instantiate either class directly.

Attributes:
cbytes

Total compressed size in bytes for this index payload.

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, as an blosc2.IndexKind.

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 this handle.

drop()

Drop this index and delete its sidecar payloads.

get(k[,d])

items()

keys()

rebuild()

Rebuild this index and return this handle.

values()

Index.descriptor

Copy of the index descriptor dictionary.

Index.kind

Kind of index, as an blosc2.IndexKind.

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.drop() None[source]

Drop this index and delete its sidecar payloads.

Index.rebuild() Index[source]

Rebuild this index and return this handle.

Index.compact() Index[source]

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