Search indexes#
Read-side wrappers over the index datasets stored under a table’s
SEARCH_INDEXES group. They are returned by
Table.build_index,
Table.search_indexes, and
Column.search_indexes; the
search indexes chapter explains the three families
and the validity protocol.
- class h5col.SearchIndex(dataset: Any, table: Table, column_ds: Any = None)[source]#
One search-index dataset of a table, wrapping its HDF5 dataset.
A wrapper obtained through a column (
Column.search_indexes) is bound to that column; one obtained table-wide (Table.search_indexes) resolves its column by scanningSEARCH_INDEX_LISTattributes, the only linkage the spec defines. Binding matters on non-conformant files where two columns claim the same index: the bound wrapper still answers for its own column, while the scan refuses to pick one.
- class h5col.ChunkMinMaxIndex(dataset: Any, table: Table, column_ds: Any = None)[source]#
Bases:
SearchIndexA
CHUNK_MINMAXzone map: per-chunk min/max plus missing counts.- entries() ndarray[source]#
The index entries for the data-bearing chunks (tail residue clipped).
- Raises:
SchemaError – If this is an unbound wrapper whose column cannot be resolved from any
SEARCH_INDEX_LIST.
- chunk_row_range(chunk_id: int) tuple[int, int][source]#
Row interval
[start, stop)that chunk chunk_id covers.- Raises:
IndexError – If chunk_id is not a data-bearing chunk (outside
[0, NROWS)).
- prune(op: str, value: Any) ndarray[source]#
Candidate chunk ids that may hold a non-missing match for the predicate.
The Layer-1 primitive: returns a superset of the chunks containing rows whose (non-missing) value satisfies
op value— every returned chunk must still be read and verified, but no matching chunk is ever excluded.opis one of< <= > >= == between(betweentakes an inclusive(low, high)pair). Chunks with no orderable, non-missing element carry placeholder bounds and are never candidates; missing rows never match a value predicate (query them withColumn.is_missing(), not with an index).- Raises:
StaleIndexError – If the validity check fails.
ConformanceError – If a token-valid index does not cover every data-bearing chunk (a rule-9 violation a consumer must not silently clip, because the uncovered chunks could hold matches).
SchemaError – If op is unknown or value is not a valid query value for the column’s datatype.
- class h5col.SortedRowsIndex(dataset: Any, table: Table, column_ds: Any = None)[source]#
Bases:
SearchIndexA
SORTED_ROWSpermutation: row positions in sorted-value order.- property fill_tail_length: int | None#
Missing (non-NaN fill) rows, immediately before the NaN tail.
- rows(op: str, value: Any) ndarray[source]#
Row positions whose (non-missing) value satisfies
op value.Exact, not a superset: binary search over the sorted body — reading O(log NROWS) individual column elements, never the full column — then one contiguous permutation slice. The rows come back in sorted-value rank order, not row order (sort them before a chunked read).
opis one of< <= > >= == between(betweentakes an inclusive(low, high)pair). Missing rows and NaN rows live in the tails and never match (query them withColumn.is_missing()).- Raises:
StaleIndexError – If the validity check fails.
ConformanceError – For structural violations a consumer must not paper over (undersized dataset, bad tail attributes,
orderednot true).SchemaError – If op is unknown or value is not a valid query value for the column’s datatype.
- class h5col.BitmapIndex(dataset: Any, table: Table, column_ds: Any = None)[source]#
Bases:
SearchIndexA
BITMAP: per-value packed row bitmaps for equality predicates.- property exhaustive: bool#
Whether the enumeration provably covers every non-missing value.
False when the attribute is false, absent, or malformed — exactly the cases where the spec forbids treating an enumeration miss as proof of absence.
- values() ndarray[source]#
The indexed values, in enumeration (bitmap row) order.
- Raises:
ConformanceError – If the BITMAP has no usable values dataset.
- rows(value: Any) ndarray | None[source]#
Row positions equal to value, or None when the index cannot say.
Exact when it answers: the union of the bitmap rows whose indexed value equals value (row order, ascending). Returns an empty array when the value is missing from an
exhaustiveenumeration (provably zero rows) and None when it is missing from a partial one — the caller must fall back to a scan. On a categorical column, astrvalue is first encoded to its category code; an unknown label provably matches zero rows. Missing rows never match a value predicate, so a query equal to the column’s fill value returns an empty array.- Raises:
StaleIndexError – If the validity check fails.
ConformanceError – If the bitmap is not a 2-D
uint8dataset, is too narrow forNROWS, or has no usable values dataset.SchemaError – If value is not a valid query value for the column’s datatype.
- isin(values: Any) ndarray | None[source]#
Row positions equal to any of values (row order, ascending).
None when any value is missing from a non-exhaustive enumeration — the union cannot be proven complete and the caller must scan.
- Raises:
StaleIndexError, ConformanceError, SchemaError – Whatever
rows()raises for a value (it is called per value).