Skip to main content

Crate kevy_index

Crate kevy_index 

Source
Expand description

kevy-index — declarative secondary indexes over prefix domains (RFC 2026-07-04, LOCKED).

Pure logic crate: Catalog holds the index declarations and a compiled prefix matcher; Segment holds one shard’s slice of one index (entries follow the indexed key’s shard — index-follows-key). The embedding runtime calls Segment::apply synchronously with every write in the index’s domain (derived-by-construction: the index can never drift from the data, and Segment::verify_entry makes that falsifiable), and serves queries by fanning Segment::range / Segment::eq across shards and merging.

No I/O, no threads, no runtime types — everything here is deterministic and unit-testable in isolation.

Structs§

AggSegment
One shard’s aggregate segment.
AggStats
Sizing counters (memory formula / IDX.LIST).
AnnSpec
v2.8 — HNSW declaration (immutable once created; RFC D2).
Catalog
The registry. The runtime holds one per process behind an RCU-style swap; shards read their clone lock-free.
Cursor
Opaque pagination cursor: the last (value, key) served. Encoded by the runtime into the wire cursor; None = start.
GroupStats
One group’s live statistics.
IndexSpec
One declared index.
Leaf
One leaf: a declared index + the shape it contributes.
MaterializedSet
One shard’s materialized result set: ordered (order_value, key) members with the bounded top-K discipline (keep K + Δ where Δ = K/4; underflow requests a local rebuild from the base indexes — RFC §2).
Segment
One shard’s slice of one index.
SegmentStats
Sizing + health counters (IDX.LIST / memory formula).
ViewCatalog
The view registry (mirrors crate::Catalog): named specs + sidecar text round-trip. Cap 64.
ViewSpec
A declared view.

Enums§

AggBy
Ranking metric for AggSegment::top_groups.
IndexKind
Index kind (KIND range|unique).
IndexState
Lifecycle state (RFC D5).
IndexValue
One indexed scalar. Ordering is total within a type; the catalog guarantees a segment only ever holds one variant.
Tree
The composition tree. Depth ≤ 3, leaves ≤ 4 (declarative caps, enforced at CREATE).
ValType
Declared scalar type of an index (TYPE i64|f64|str).
ViewMode
View mode.

Constants§

MAX_TREE_DEPTH
Declarative caps (RFC §1).
MAX_TREE_LEAVES
Max leaves per tree.
MAX_VIEWS
Hard cap on declared views.

Functions§

eval_tree
Evaluate tree against one shard’s segments: seg resolves an index name to its Segment (None = unknown index → empty leaf — the runtime validates names at CREATE, so this is defensive). Returns the member keys (unordered set semantics).
key_in_tree
Re-evaluate ONE key’s membership (the materialized write hook): every leaf is a point probe via the segment’s reverse map.
key_in_tree_vals
key_in_tree variant over PRE-FETCHED per-index values — the write hook probes each referenced index ONCE per key and evaluates every view against the same small table (bounds compares only; no per-view re-hashing).
merge_group
Merge shard partials for one group (reduce side): counts/sums add, min/max take extremes.
sort_groups
Shared ranking order (per-shard AND at the reduce after merging shard partials — one definition, no drift).