#[non_exhaustive]pub struct IndexVerify {
pub name: Vec<u8>,
pub entries: u64,
pub approx_bytes: u64,
pub coerce_failures: u64,
pub excluded: u64,
pub absent: u64,
pub rows: u64,
pub missing: u64,
pub duplicates: u64,
pub drift: u64,
pub checked: u64,
}Expand description
Per-index verification counters, one row of TABLE.VERIFY.
let mut v = kevy_index::IndexVerify::new("t.at");
v.entries = 3;
assert_eq!((v.name.as_slice(), v.entries, v.drift), (&b"t.at"[..], 3, 0));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: Vec<u8>Compiled index name (<table>.<column-or-orderpath>).
use kevy_index::{IndexVerify, parse_table_declare};
let t = parse_table_declare(&[
b"TABLE.DECLARE", b"t", b"PREFIX", b"t:", b"PK", b"id", b"COLUMN", b"id", b"i64",
b"COLUMN", b"at", b"i64", b"INDEX", b"at", b"range",
])?;
// a verifier opens one row per compiled index, under the compiled name
let rows: Vec<IndexVerify> = t.compile()?.iter().map(|i| IndexVerify::new(i.name())).collect();
assert_eq!(rows[0].name, b"t.at");entries: u64Entries currently held by the index.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.rows, v.entries, v.absent) = (5, 4, 1);
// every walked row that derives a value is held
assert_eq!(v.rows - v.absent - v.coerce_failures - v.excluded - v.missing, v.entries);approx_bytes: u64Approximate resident bytes of the index structure.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.entries, v.approx_bytes) = (1_000, 48_000);
assert_eq!(v.approx_bytes / v.entries, 48, "resident bytes per entry");coerce_failures: u64Rows whose driving column is present but fails to coerce to the declared type. Recomputed fresh on every call — the 4.0 counter of this name was a lifetime tally that also swallowed absent-column rows, which is how a healthy migration once read as 30 152 live failures.
use kevy_index::{IndexValue, ValType};
let mut v = kevy_index::IndexVerify::new("t.at");
// the rows hold `at` = "12" and `at` = "soon"; only the second fails to coerce
for raw in [&b"12"[..], b"soon"] {
if IndexValue::coerce(ValType::I64, raw).is_none() {
v.coerce_failures += 1;
}
}
assert_eq!(v.coerce_failures, 1);excluded: u64Rows excluded because a string component exceeded the composite
bound (MAX_STR_COMPONENT). Fresh. The counter that turns a
silent two-row entries gap into a named number.
let mut v = kevy_index::IndexVerify::new("t.by_name");
(v.rows, v.entries, v.excluded) = (10, 8, 2);
// the two-row gap between rows and entries has a name
assert_eq!(v.rows - v.entries, v.excluded);absent: u64Rows whose driving column is absent — NULL semantics, excluded by design and not a failure. Fresh; named so absence can never again masquerade as coercion failure.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.rows, v.entries, v.absent) = (5, 3, 2);
// rows without the column are excluded by design, not failures
assert_eq!((v.rows - v.entries, v.coerce_failures), (v.absent, 0));rows: u64Prefix rows this verify walked for the row→index direction.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.rows, v.entries) = (4, 4);
assert_eq!(v.rows, v.entries, "every walked row is indexed");missing: u64Rows that derive a value yet have no entry in the index — the “writer forgot this path” class a drift walk structurally cannot see, because it iterates entries and a missing entry is not there to iterate. Fresh.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.rows, v.entries, v.checked, v.missing) = (4, 3, 3, 1);
// an entry that was never written is invisible to `drift`, visible here
assert_eq!((v.drift, v.missing), (0, 1));duplicates: u64Distinct sort keys held by more than one row. Non-zero means the sort is not a total order — a paged reader can skip or repeat rows at page boundaries. Add a bounded tie-break column.
use kevy_index::{ValType, order_key};
let mut v = kevy_index::IndexVerify::new("t.at");
// two rows share the sort key 7: the order between them is not defined
let keys = [order_key(ValType::I64, b"7"), order_key(ValType::I64, b"7"), order_key(ValType::I64, b"9")];
v.duplicates = (1..keys.len()).filter(|&i| keys[i] == keys[i - 1]).count() as u64;
assert_eq!(v.duplicates, 1);drift: u64Entries whose held value disagrees with re-deriving from the row right now. Recomputed fresh on every call.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.checked, v.drift) = (100, 0);
assert_eq!(v.drift, 0, "every checked entry matches its row");checked: u64Entries the drift recheck examined this call.
let mut v = kevy_index::IndexVerify::new("t.at");
(v.entries, v.checked, v.drift) = (100, 100, 2);
assert_eq!(v.drift * 100 / v.checked, 2, "percent of this pass that drifted");Implementations§
Source§impl IndexVerify
impl IndexVerify
Trait Implementations§
Source§impl Clone for IndexVerify
impl Clone for IndexVerify
Source§fn clone(&self) -> IndexVerify
fn clone(&self) -> IndexVerify
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more