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. note[mask]['title'] iterates that field over the matching records, and note[mask][['title', 'value']] iterates named rows (.title/.value) projected through the searcher’s native results().

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.

SlicerProjection

Named rows of a SlicerSelection, projected to chosen fields.

Module Contents

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

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, ast=None)[source]

One field of a Slicer, iterable and comparable.

Iterating yields the field’s decoded scalar values, across every record of the slicer or, when reached through a SlicerSelection, across only its matching records. 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, ...]) – The attribute names from the query variable to this field.

  • ast (_Node | None) – The owning selection’s op tree to filter by, or None for every record of the slicer.

isin(values)[source]

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

Match records whose field value is null.

Returns:

A mask matching null field values.

Return type:

SlicerMask

notna()[source]

Match records whose field value is not null.

Returns:

A mask matching non-null field values.

Return type:

SlicerMask

between(low, high)[source]

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

class httk.store.query.slicer.SlicerMask(slicer, ast)[source]

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)[source]

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.

class httk.store.query.slicer.SlicerProjection(slicer, ast, names)[source]

Named rows of a SlicerSelection, projected to chosen fields.

Iterating yields the searcher’s own native result rows (from results()), unchanged, each exposing every requested name by attribute or subscript. Each iteration runs against its own fresh searcher, so it never shares filter state with another operation.

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

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

  • names (tuple[str, ...]) – The single-segment field names to project, in order.