Expand description
Secondary indexes (L6) — index B+trees layered over the M4 B+tree.
M7 adds secondary indexes: per-collection B+trees keyed by an
order-preserving encoding of one or more document fields, valued
by the document’s Id. See docs/format.md
§ Indexes for the authoritative on-disk layout.
Each declared index lives in its own B+tree (M4 — no new on-disk
page types). The index’s root page-id is persisted inside the
owning CollectionDescriptor
as an IndexDescriptor entry
(M5 reserved the field; M7 fills it).
§Module split
spec— runtime declaration shapes:IndexKind,IndexSpec, constructors. The descriptor on-disk shape lives incrate::catalogbecause the catalog owns the wire row.key— order-preserving byte encoding forDynamicvalues plus the composite envelope. The encoding contract is documented indocs/format.md§ Index key encoding.
§Power-of-ten posture
- Rule 1. No recursion: the encoder walks the input
&[Dynamic]with a single boundedforloop. - Rule 2. Per-encode loops are bounded by the input slice
length, which the caller has already validated against
IndexSpec::key_paths.len(). - Rule 5. Field count is checked against
IndexSpec’skey_pathsat the encode-time runtime boundary; type-level invariants (kind enum, non-emptykey_pathsfor composite, single-field forEach) sit on the constructors. - Rule 7. No
unwrap/expecton the production path. The encoder returnsErr(Error::Codec)onStringfields that contain an embedded0x00(the terminator would split the key — seedocs/format.md). - Rule 9. All dispatch is static —
IndexKindis an enum matched at every call site; nodyn, no macro generation.
Re-exports§
pub use crate::index::extract::extract_index_keys;pub use crate::index::extract::MAX_EACH_ENTRIES;pub use crate::index::key::encode_field;pub use crate::index::key::encode_index_key;pub use crate::index::key::encode_index_key_parts;pub use crate::index::key::encoded_id_suffix_len;pub use crate::index::key::EncodedIndexKey;pub use crate::index::key::COMPOSITE_TAG;pub use crate::index::spec::IndexKind;pub use crate::index::spec::IndexSpec;