httk.optimade.backend.memory_store¶
A generic in-memory store implementing the httk store/searcher protocols.
Rows are plain dicts keyed by backend record keys, and search expressions
evaluate as predicates over those rows. It is the reference
Store implementation: it backs the
example demo server and is what
adapter_from_providers() loads an
EntryProvider’s records into.
Set operations evaluate exactly here — has_any/has_only are plain set
predicates over the row’s list value, and ~ negates them directly. The SQL
backend needs an aggregate rendering and a second (HAVING) evaluation position
to say the same thing, but that is entirely its own business: the neutral
protocol only ever hands a store one expression per searcher.add call.
String matching is literal here too (contains/startswith/endswith
are plain str operations), which is exactly what the neutral protocol
promises — no pattern language is involved at any point.
Iteration yields SearchResult values, one entry in
values per MemorySearcher.output() call: a variable output yields the
whole row dict, a field output the row’s value for that field.
Attributes¶
Classes¶
A query variable over one table of rows; attribute access yields fields. |
|
A store over dict rows: |
Module Contents¶
- class httk.optimade.backend.memory_store.MemoryField(name: str)[source]¶
-
- startswith(other: str) MemoryExpression[source]¶
- endswith(other: str) MemoryExpression[source]¶
- contains(other: str) MemoryExpression[source]¶
- has_any(*values: Any) MemoryExpression[source]¶
- has_only(*values: Any) MemoryExpression[source]¶
- class httk.optimade.backend.memory_store.MemoryVariable(target: str)[source]¶
A query variable over one table of rows; attribute access yields fields.
always_true/always_falseare real methods, declared before the catch-all__getattr__so they win over it — they are reserved names that never resolve to a row key.- always_true() MemoryExpression[source]¶
- always_false() MemoryExpression[source]¶
- class httk.optimade.backend.memory_store.MemorySearcher(tables: dict[str, list[Row]])[source]¶
-
- variable(target: Any) MemoryVariable[source]¶
- output(variable: MemoryVariable | MemoryField, name: str) None[source]¶
Append an output: a variable (yields the whole row) or a field (its value).
- add(expression: MemoryExpression) None[source]¶
- add_sort(field: MemoryField, descending: bool) None[source]¶