Expand description
Predicate pushdown: translate Kit Expr predicates into MongrelDB core
Conditions so the native engine can resolve them via indexes instead of a
full-scan + Rust evaluation (Kit Priority 1).
§Design
The Kit’s query layer materializes every visible row and evaluates
predicates in Rust. This module is the bridge that lets simple, index-
served predicates bypass that full scan. It produces PushdownPlan — a
list of native Conditions that the core engine can resolve via HOT /
bitmap / range indexes, plus a flag indicating whether the translation
covered the entire predicate.
Core’s native Query is a conjunction (AND of conditions) that resolves
to a row-id set. Conditions always return a superset of the matching
rows; the Kit must still re-apply the original Expr filter in Rust on the
survivors unless PushdownPlan::fully_translated is true. This makes
partial translation safe by construction.
§Supported translations
Kit Expr | Core Condition | Requirement |
|---|---|---|
Eq(Column, Literal) on PK | Pk | single-column PK |
Eq(Column, Literal) | BitmapEq | bitmap-indexed column |
In(Column, [literals]) | BitmapIn | bitmap-indexed column |
Lt/Lte/Gt/Gte(Column, Literal) int | Range | int-typed column |
Lt/Lte/Gt/Gte(Column, Literal) float | RangeF64 | float-typed column |
Contains(Column, needle) | FmContains | FM-indexed column (residual re-check) |
Like(Column, pattern) | FmContainsAll | FM-indexed column (residual re-check) |
IsNull / IsNotNull(Column) | IsNull / IsNotNull | page-stat-aware (residual re-check) |
And([sub-exprs]) | recurse each | each part translated independently |
Unsupported (Or, Not, Ne, NotIn, InSubquery, Exists, cross-column
comparisons) are left as residual Rust evaluation — the caller falls back to
a full scan for those branches.
Structs§
- Pushdown
Plan - The result of translating a Kit predicate into core conditions.
Functions§
- pk_
conditions - Build a
Condition::Pk(or bitmap fallback) from a PK value map. Used byget_by_pk_internaland FKparent_exists— the highest-value pushdown targets since they currently do O(N) linear scans with the PK in hand. - translate_
predicate - Attempt to translate
exprinto nativeConditions fortable. ReturnsNonewhen no part of the expression could be translated (caller falls back to a full scan + Rust evaluation).