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¶
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 |
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
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)¶
One field of a
Slicer, iterable and comparable.Iterating yields the field’s decoded scalar values. Comparisons and the
isin/isna/notna/betweenhelpers, plus the.strliteral matchers, build aSlicerMaskfor use as a slicer index key.- Parameters:
- 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:
- isna()¶
Match records whose field value is null.
- Returns:
A mask matching null field values.
- Return type:
- notna()¶
Match records whose field value is not null.
- Returns:
A mask matching non-null field values.
- Return type:
- 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:
- property str: _SlicerStr¶
The literal string-matching accessor for this column.
- Returns:
The
contains/startswith/endswithaccessor.- 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
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.