httk.store.query.slicer

A pandas-style [] indexing layer over the store search DSL.

The Slicer compiles bracket indexing into the ordinary Searcher surface — variable, add, output, results and count — and adds no query capability of its own. It is a thin convenience: note = store.searcher().slicer(Note) gives an object where note['title'] iterates one field, note[note['value'] > 10] iterates the matching records, and len(note[mask]) counts them.

Nothing here touches a searcher until it is iterated or measured. A slicer holds only a zero-argument factory that mints a fresh searcher and the target record class; a column holds a field path; a mask holds a small immutable op tree (the private _Cmp/_And/_Or/_Not nodes). Backend search expressions are bound to one searcher’s variable and add() mutates that searcher, so every terminal operation runs against its own fresh searcher and compiles the op tree against that searcher’s variable. Two slicer operations therefore never share filter state.

No sorting is offered: some conforming stores (the federation) reject it.

Classes

Slicer

A pandas-style indexing view over one record class in a store.

SlicerColumn

One field of a Slicer, iterable and comparable.

SlicerMask

A boolean predicate over a Slicer, combinable with & | ^ ~.

SlicerSelection

The records of a Slicer matching a SlicerMask.

Module Contents

class httk.store.query.slicer.Slicer(make_searcher, target)

A pandas-style indexing view over one record class in a store.

Index it with a field-name string to iterate that field’s values, or with a boolean SlicerMask to iterate the matching records. Iterating the slicer itself yields every record; len() counts them. Each operation runs against its own fresh searcher, so operations never share filter state.

Parameters:
  • make_searcher (collections.abc.Callable[[], Any]) – A zero-argument callable returning a fresh searcher.

  • target (Any) – The stored record class this slicer indexes.

class httk.store.query.slicer.SlicerColumn(slicer, path)

One field of a Slicer, iterable and comparable.

Iterating yields the field’s decoded scalar values. Comparisons and the isin/isna/notna/between helpers, plus the .str literal matchers, build a SlicerMask for use as a slicer index key.

Parameters:
  • slicer (Slicer) – The owning slicer.

  • path (tuple[str, Ellipsis]) – The attribute names from the query variable to this field.

isin(values)

Match records whose field value is one of values.

Parameters:

values (collections.abc.Iterable[Any]) – The membership set.

Returns:

A mask matching records in the set.

Return type:

SlicerMask

isna()

Match records whose field value is null.

Returns:

A mask matching null field values.

Return type:

SlicerMask

notna()

Match records whose field value is not null.

Returns:

A mask matching non-null field values.

Return type:

SlicerMask

between(low, high)

Match records whose field value lies in [low, high] inclusive.

Parameters:
  • low (Any) – The inclusive lower bound.

  • high (Any) – The inclusive upper bound.

Returns:

A mask matching the closed interval.

Return type:

SlicerMask

property str: _SlicerStr

The literal string-matching accessor for this column.

Returns:

The contains/startswith/endswith accessor.

Return type:

_SlicerStr

class httk.store.query.slicer.SlicerMask(slicer, ast)

A boolean predicate over a Slicer, combinable with & | ^ ~.

A mask is not iterable and has no comparison operators; it is used only as a slicer index key or combined with another mask from the same slicer.

Parameters:
  • slicer (Slicer) – The owning slicer.

  • ast (_Node) – The op tree the mask describes.

class httk.store.query.slicer.SlicerSelection(slicer, ast)

The records of a Slicer matching a SlicerMask.

Iterating yields the reconstructed records; len() counts them. Each runs against its own fresh searcher.

Parameters:
  • slicer (Slicer) – The owning slicer.

  • ast (_Node) – The op tree selecting the records.