Diagnostic API for B-tree structural integrity checking.
Similar to PostgreSQL's amcheck or SQLite's PRAGMA integrity_check, this namespace provides functions to validate the internal structure of persistent sorted sets.
Use validate for quick structural checks, validate-full to also
verify subtree counts and measures, and validate-content to run
user-defined content checks on leaf data (e.g., for Datahike index
consistency verification).
Diagnostic API for B-tree structural integrity checking. Similar to PostgreSQL's amcheck or SQLite's PRAGMA integrity_check, this namespace provides functions to validate the internal structure of persistent sorted sets. Use `validate` for quick structural checks, `validate-full` to also verify subtree counts and measures, and `validate-content` to run user-defined content checks on leaf data (e.g., for Datahike index consistency verification).
(tree-stats set)Returns diagnostic statistics about the tree structure: {:depth N, :branch-count N, :leaf-count N, :element-count N, :min-fill-ratio F, :avg-fill-ratio F, :max-fill-ratio F, :fill-histogram {:min F :p25 F :p50 F :p75 F :p90 F :max F}, :leaf-fill-histogram {...}, :branch-fill-histogram {...}, :counts-known? bool, :measure-known? bool}
Returns diagnostic statistics about the tree structure:
{:depth N, :branch-count N, :leaf-count N, :element-count N,
:min-fill-ratio F, :avg-fill-ratio F, :max-fill-ratio F,
:fill-histogram {:min F :p25 F :p50 F :p75 F :p90 F :max F},
:leaf-fill-histogram {...}, :branch-fill-histogram {...},
:counts-known? bool, :measure-known? bool}(validate set)Quick structural integrity check. Returns true if valid, throws with structured error data if any invariant is violated.
Checks: balance, node sizes, key ordering, separator keys, levels, sibling ordering, root shape.
Quick structural integrity check. Returns true if valid, throws with structured error data if any invariant is violated. Checks: balance, node sizes, key ordering, separator keys, levels, sibling ordering, root shape.
(validate-content set content-fn)Full integrity check with content verification. Calls (content-fn keys) for each leaf's key array, where content-fn should return nil if valid or a map describing the error. For Datahike: verify each datom exists in the expected table/index.
Runs validate-full first, then walks all leaves.
Full integrity check with content verification. Calls (content-fn keys) for each leaf's key array, where content-fn should return nil if valid or a map describing the error. For Datahike: verify each datom exists in the expected table/index. Runs validate-full first, then walks all leaves.
(validate-counts-known set)Verify every branch in the tree has a known subtree count (>= 0). For fresh (non-restored) trees, counts should never be -1. Returns true if valid, throws with error data.
Verify every branch in the tree has a known subtree count (>= 0). For fresh (non-restored) trees, counts should never be -1. Returns true if valid, throws with error data.
(validate-full set)Full integrity check including subtree counts, measures, and element-wise navigation. Every key in the tree is re-looked up from the root to verify search paths are correct. Catches separator key corruption, comparator bugs, and any issue where elements are structurally present but unreachable. Returns true if valid, throws with structured error data.
Full integrity check including subtree counts, measures, and element-wise navigation. Every key in the tree is re-looked up from the root to verify search paths are correct. Catches separator key corruption, comparator bugs, and any issue where elements are structurally present but unreachable. Returns true if valid, throws with structured error data.
(validate-measures-known set)Verify every node in the tree has a known measure (non-nil). Only meaningful when the set was created with a measure function. Returns true if valid, throws with error data.
Verify every node in the tree has a known measure (non-nil). Only meaningful when the set was created with a measure function. Returns true if valid, throws with error data.
(validate-navigation set)Root-descend verification: re-looks up every element from the root to verify the search path is correct. Catches subtle comparator bugs, collation changes after restore, and navigation corruption that structural checks miss.
O(n log n) — diagnostic, not a hot path. Returns true if valid, throws with structured error data if any key cannot be found via lookup.
Root-descend verification: re-looks up every element from the root to verify the search path is correct. Catches subtle comparator bugs, collation changes after restore, and navigation corruption that structural checks miss. O(n log n) — diagnostic, not a hot path. Returns true if valid, throws with structured error data if any key cannot be found via lookup.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |