httk.store.mongo.mapping¶
Pure MongoDB physical mapping derived from the schema intermediate form.
Attributes¶
Classes¶
Describe one field's location and embedded value shape in |
|
Describe one MongoDB index without performing any I/O. |
Functions¶
|
Return the deterministic reserved dispatch collection name. |
|
Return the collection name for a resolved schema. |
|
Derive the user-field document plan under the |
|
Derive all record-collection indexes from the schema IR. |
|
Build the writer-owned |
|
Build the validator for one entry-family dispatch collection. |
|
Derive the unique |
|
Atomically allocate the next integer sid from the counters collection. |
Module Contents¶
- class httk.store.mongo.mapping.DocumentFieldSpec[source]¶
Describe one field’s location and embedded value shape in
f.- Parameters:
field – The logical schema field name.
role – The schema field role.
keys – Parent document keys used by non-child fields.
element_keys – Keys used by one embedded child element.
optional – Whether an absent key represents
None.shape – The schema shape marker, when present.
- property key: str[source]¶
Return the single parent key for this field.
- Returns:
The parent key.
- Raises:
ValueError – If the field has multiple or no parent keys.
- Return type:
- class httk.store.mongo.mapping.IndexSpec[source]¶
Describe one MongoDB index without performing any I/O.
- Parameters:
keys – Ordered dotted field paths and ascending/descending directions.
name – Deterministic index name.
unique – Whether duplicate keys are rejected.
partial_filter_expression – Optional MongoDB partial-index predicate.
- httk.store.mongo.mapping.entry_dispatch_table_name(family_name)[source]¶
Return the deterministic reserved dispatch collection name.
- httk.store.mongo.mapping.collection_name_for(schema)[source]¶
Return the collection name for a resolved schema.
- Parameters:
schema (httk.store.db.schema.TableSchema) – Resolved storable schema.
- Returns:
The schema’s physical collection name.
- Raises:
ValueError – If the name uses the reserved
_httk_prefix.- Return type:
- httk.store.mongo.mapping.document_fields_for(schema)[source]¶
Derive the user-field document plan under the
fsubdocument.- Parameters:
schema (httk.store.db.schema.TableSchema) – Resolved storable schema.
- Returns:
One immutable document-field plan per stored schema field.
- Return type:
tuple[DocumentFieldSpec, Ellipsis]
- httk.store.mongo.mapping.index_specs_for(schema)[source]¶
Derive all record-collection indexes from the schema IR.
- Parameters:
schema (httk.store.db.schema.TableSchema) – Resolved storable schema.
- Returns:
Deterministically ordered index specifications.
- Return type:
- httk.store.mongo.mapping.validator_for(schema)[source]¶
Build the writer-owned
$jsonSchemavalidator for a record collection.- Parameters:
schema (httk.store.db.schema.TableSchema) – Resolved storable schema.
- Returns:
A MongoDB collection validator command fragment.
- Return type:
- httk.store.mongo.mapping.dispatch_validator_for(family)[source]¶
Build the validator for one entry-family dispatch collection.
- Parameters:
family (httk.store.storage_layout.EntryFamilyLayout) – Normalized entry-family layout.
- Returns:
A MongoDB collection validator command fragment.
- Return type:
- httk.store.mongo.mapping.dispatch_index_specs(family)[source]¶
Derive the unique
(record, sid)dispatch index.- Parameters:
family (httk.store.storage_layout.EntryFamilyLayout) – Normalized multi-record entry-family layout.
- Returns:
The dispatch collection’s index specification.
- Raises:
ValueError – If the family has fewer than two backing records.
- Return type: