httk.store.federated_store¶
Frozen query planning and sequential execution for a federated store.
Federated expressions are deliberately represented by a private, backend-neutral AST. Child searcher expressions are used only while validating that each participating source accepts an operation; every execution replays that AST into fresh child searchers.
Exceptions¶
Report that a federation-level store operation failed. |
|
Report that a named source rejected or failed a federated operation. |
Classes¶
Expose one scalar projection lazily from a federated result set. |
|
Represent a frozen, lazy, re-iterable federated result plan. |
|
Bind one logical target to exact concrete targets for named sources. |
|
Fan out read-only queries over an ordered collection of borrowed stores. |
|
Represent the one root variable supported by a federated query. |
|
Represent a backend-neutral path from a federated root variable. |
|
Represent a federated expression backed by the neutral private AST. |
|
Build and validate one portable, single-root federated query. |
Module Contents¶
- exception httk.store.federated_store.FederatedStoreError[source]¶
Bases:
RuntimeErrorReport that a federation-level store operation failed.
- exception httk.store.federated_store.FederatedSourceError(source, operation)[source]¶
Bases:
FederatedStoreErrorReport that a named source rejected or failed a federated operation.
- Parameters:
- class httk.store.federated_store.FederatedResultColumn(result, index)[source]¶
Expose one scalar projection lazily from a federated result set.
- Parameters:
result (FederatedResultSet) – The result set supplying rows.
index (int) – The zero-based projection index.
- class httk.store.federated_store.FederatedResultSet(store, plan)[source]¶
Represent a frozen, lazy, re-iterable federated result plan.
Results execute source-major in federation source order, preserve duplicate rows, and remain read-only views over the borrowed stores.
- Parameters:
store (FederatedStore) – The federation whose sources execute the plan.
plan (object) – The validated frozen federation plan.
- first()[source]¶
Return the first result row, or
Nonewhen no row matches.- Returns:
The first matching row, or
None.- Return type:
httk.store.query.ResultRow | None
- one()[source]¶
Return the only result row.
- Returns:
The sole matching result row.
- Raises:
httk.store.query.protocols.NoResultError – If no row matches.
httk.store.query.protocols.MultipleResultsError – If more than one row matches.
- Return type:
- scalars(name=None)[source]¶
Iterate over one named projection.
- Parameters:
name (str | None) – The projection name, required when more than one output exists.
- Returns:
An iterator over the selected projection values.
- Raises:
ValueError – If no name is supplied for multiple outputs.
KeyError – If
nameis not a declared output.
- Return type:
- column(name)[source]¶
Return a lazy scalar column by projection name.
- Parameters:
name (str) – The scalar projection name.
- Returns:
A lazy column view over the projection.
- Raises:
- Return type:
- abstractmethod cursor()[source]¶
Reject cursor access because federation cursors are unsupported.
- Returns:
Never returns.
- Raises:
NotImplementedError – Always, because federated cursors are not implemented.
- Return type:
- class httk.store.federated_store.FederatedTarget[source]¶
Bind one logical target to exact concrete targets for named sources.
- Parameters:
name – The nonempty logical target name.
targets – Concrete targets keyed by federation source name.
_owner – The federation that owns this target binding.
- Raises:
TypeError – If
targetsis not a mapping or_owneris not a federation.ValueError – If the name, source set, or source names are invalid.
- targets: collections.abc.Mapping[str, object][source]¶
- class httk.store.federated_store.FederatedStore(sources)[source]¶
Fan out read-only queries over an ordered collection of borrowed stores.
The union is source-major, lazy, and non-deduplicating. Queries require the strict common query surface accepted by every participating source, and counts are exact sums of the unpaged source counts. This live borrowed-store view is distinct from the persisted registry in
httk.store.db.stored_federation.- Parameters:
sources (collections.abc.Mapping[str, httk.store.query.Store]) – Child stores keyed by stable federation source name.
- Raises:
TypeError – If
sourcesis not a mapping.ValueError – If fewer than two sources or an invalid source name is supplied.
- property source_names: tuple[str, Ellipsis][source]¶
Return the immutable source names in constructor iteration order.
- target(name, targets)[source]¶
Create an immutable target mapping for an intentional source subset.
- Parameters:
name (str) – The logical target name.
targets (collections.abc.Mapping[str, object]) – Concrete targets keyed by federation source name.
- Returns:
The validated target binding.
- Raises:
TypeError – If
targetsis not a mapping.ValueError – If a target name or source name is invalid.
- Return type:
- class httk.store.federated_store.FederatedVariable(searcher, variables, targets)[source]¶
Represent the one root variable supported by a federated query.
- Parameters:
searcher (FederatedSearcher) – The owning federated searcher.
variables (collections.abc.Mapping[str, httk.store.query.SearchVariable]) – Child variables keyed by source name.
targets (collections.abc.Mapping[str, object]) – Concrete child targets keyed by source name.
- always_true()[source]¶
Build an expression that matches every federated row.
- Returns:
A federated expression matching every row.
- Return type:
- class httk.store.federated_store.FederatedField(variable, path)[source]¶
Represent a backend-neutral path from a federated root variable.
- Parameters:
variable (FederatedVariable) – The federated root variable owning the path.
path (tuple[str, Ellipsis]) – The field path relative to that variable.
- contains(text)[source]¶
Match literal values containing
text.- Parameters:
text (str) – The literal substring to find.
- Returns:
The resulting federated expression.
- Return type:
- startswith(prefix)[source]¶
Match literal values beginning with
prefix.- Parameters:
prefix (str) – The literal prefix to find.
- Returns:
The resulting federated expression.
- Return type:
- endswith(suffix)[source]¶
Match literal values ending with
suffix.- Parameters:
suffix (str) – The literal suffix to find.
- Returns:
The resulting federated expression.
- Return type:
- has(value)[source]¶
Match a list field containing
value.- Parameters:
value (object) – The list member to match.
- Returns:
The resulting federated expression.
- Return type:
- has_any(*values)[source]¶
Match a list field containing any of
values.- Parameters:
*values (object) – The list members to match.
- Returns:
The resulting federated expression.
- Return type:
- has_only(*values)[source]¶
Match a list field containing no values outside
values.- Parameters:
*values (object) – The complete allowed list-member set.
- Returns:
The resulting federated expression.
- Return type:
- class httk.store.federated_store.FederatedExpression(searcher, ast)[source]¶
Represent a federated expression backed by the neutral private AST.
- Parameters:
searcher (FederatedSearcher) – The owning federated searcher.
ast (object) – The validated private expression tree.
- class httk.store.federated_store.FederatedSearcher(store)[source]¶
Build and validate one portable, single-root federated query.
- Parameters:
store (FederatedStore) – The federation whose child stores provide the query surface.
- variable(target)[source]¶
Bind one shared or explicit target against child searcher prototypes.
- Parameters:
target (object) – A shared child target or a source-specific target binding.
- Returns:
The federated root variable.
- Raises:
httk.store.query.protocols.UnsupportedQueryError – If a second root or foreign target is supplied.
FederatedSourceError – If a source rejects target binding.
- Return type:
- add(expression)[source]¶
Validate and retain a portable condition for the future frozen plan.
- Parameters:
expression (object) – An expression produced by this searcher.
- Returns:
None.
- Raises:
httk.store.query.protocols.UnsupportedQueryError – If the expression belongs to another searcher.
FederatedSourceError – If a source rejects the expression.
- Return type:
None
- output(value, name)[source]¶
Declare a record, scalar field, or origin output for a future plan.
- Parameters:
- Returns:
None.
- Raises:
ValueError – If
nameis empty or already declared.httk.store.query.protocols.UnsupportedQueryError – If
valueis not owned by this searcher.FederatedSourceError – If a source rejects the output.
- Return type:
None
- add_sort(field, descending=False)[source]¶
Reject global sorting until a portable sort-semantics contract exists.
- Parameters:
- Raises:
httk.store.query.protocols.UnsupportedQueryError – Always, because global federation sorting has no portable contract.
- count()[source]¶
Return the exact unpaged count of the current filtered union.
- Returns:
The exact sum of matching rows across participating sources.
- Raises:
httk.store.query.protocols.CountUnavailableError – If a source cannot provide an exact count.
FederatedSourceError – If a source fails while counting.
- Return type:
- add_offset(offset)[source]¶
Add a global source-union offset.
- Parameters:
offset (int) – The nonnegative number of union rows to skip.
- Returns:
None.
- Raises:
TypeError – If
offsetis not an integer.ValueError – If
offsetis negative.
- Return type:
None
- results(**outputs)[source]¶
Freeze a projection plan into a lazy, re-iterable result set.
- Parameters:
**outputs (object) – Optional output names mapped to root variables or fields.
- Returns:
The lazy frozen result set.
- Raises:
ValueError – If no outputs are declared or an output name is invalid.
httk.store.query.protocols.UnsupportedQueryError – If an output does not belong to this searcher.
FederatedSourceError – If a source rejects an output.
- Return type: