Skip to main content

IndexVerify

Struct IndexVerify 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: u64

Entries 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: u64

Approximate 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: u64

Rows 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: u64

Rows 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: u64

Rows 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: u64

Prefix 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: u64

Rows 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: u64

Distinct 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: u64

Entries 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: u64

Entries 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

Source

pub fn new(name: impl Into<Vec<u8>>) -> IndexVerify

All-zero counters for compiled index name.

assert_eq!(kevy_index::IndexVerify::new("t.x").checked, 0);

Trait Implementations§

Source§

impl Clone for IndexVerify

Source§

fn clone(&self) -> IndexVerify

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IndexVerify

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for IndexVerify

Source§

fn default() -> IndexVerify

Returns the “default value” for a type. Read more
Source§

impl Eq for IndexVerify

Source§

impl Hash for IndexVerify

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for IndexVerify

Source§

fn eq(&self, other: &IndexVerify) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IndexVerify

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.