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¶
A pandas-style indexing view over one record class in a store. |
|
One field of a |
|
A boolean predicate over a |
|
The records of a |
|
Named rows of a |
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
SlicerMaskto 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 theisin/isna/notna/betweenhelpers, plus the.strliteral matchers, build aSlicerMaskfor use as a slicer index key.- Parameters:
- 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:
- isna()[source]¶
Match records whose field value is null.
- Returns:
A mask matching null field values.
- Return type:
- notna()[source]¶
Match records whose field value is not null.
- Returns:
A mask matching non-null field values.
- Return type:
- 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
Slicermatching aSlicerMask.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.