httk.serve.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.serve.optimade.backend.memory_store.MemoryField(name: str)[source]¶
-
- startswith(other: str) MemoryExpression[source]¶
- endswith(other: str) MemoryExpression[source]¶
- contains(other: str) MemoryExpression[source]¶
- is_in(*values: Any) MemoryExpression[source]¶
Match a scalar field against one of the supplied values.
- has(value: Any) MemoryExpression[source]¶
- has_any(*values: Any) MemoryExpression[source]¶
- has_only(*values: Any) MemoryExpression[source]¶
- class httk.serve.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.serve.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]¶
- results(**outputs: Any) httk.data.query.ResultSetLike[source]¶
- class httk.serve.optimade.backend.memory_store.InMemoryStore(tables: dict[str, list[Row]])[source]¶
A store over dict rows:
InMemoryStore({'structures': [ {...}, ... ]}).- searcher() MemorySearcher[source]¶
- class httk.serve.optimade.backend.memory_store.MemoryResultSet(rows: list[Row], outputs: list[tuple[str, MemoryVariable | MemoryField]])[source]¶
- first() httk.data.query.ResultRowLike | None[source]¶
- scalars(name: str | None = None) collections.abc.Iterator[Any][source]¶