You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OrdinalDB validates dimensions, bit widths, finite inputs, mask lengths, and candidate IDs before calling ordvec. Today those invariants are embedded in constructors and methods as assert!/assert_eq!, so downstreams must duplicate the same rules to avoid panics.
#86 tracks broader Result-returning try_* APIs. This issue is narrower and complementary: expose validation helpers for static/index-shape invariants so DBs and bindings can preflight user input and produce their own error types without constructing temporary indexes or duplicating rules.
Evidence
RankQuant::new enforces bits {1,2,4}, dim >= 2, dim <= u16::MAX, dim % (8 / bits) == 0, and dim % (1 << bits) == 0: src/quant.rs:150-174.
Bitmap::new enforces dim % 64 == 0, dim <= MAX_DIM, and 0 < n_top < dim: src/bitmap.rs:50-65.
SignBitmap::new enforces nonzero dim, dim % 64 == 0, and dim <= MAX_SIGN_BITMAP_DIM: src/sign_bitmap.rs:60-67.
RankQuant::add validates row-major length and finite inputs: src/quant.rs:194-203.
RankQuant::search_asymmetric_subset validates query length, finite inputs, and candidate bounds with panics/asserts: src/quant.rs:547-564.
Context
OrdinalDB validates dimensions, bit widths, finite inputs, mask lengths, and candidate IDs before calling ordvec. Today those invariants are embedded in constructors and methods as
assert!/assert_eq!, so downstreams must duplicate the same rules to avoid panics.#86 tracks broader
Result-returningtry_*APIs. This issue is narrower and complementary: expose validation helpers for static/index-shape invariants so DBs and bindings can preflight user input and produce their own error types without constructing temporary indexes or duplicating rules.Evidence
RankQuant::newenforces bits{1,2,4},dim >= 2,dim <= u16::MAX,dim % (8 / bits) == 0, anddim % (1 << bits) == 0:src/quant.rs:150-174.Bitmap::newenforcesdim % 64 == 0,dim <= MAX_DIM, and0 < n_top < dim:src/bitmap.rs:50-65.SignBitmap::newenforces nonzerodim,dim % 64 == 0, anddim <= MAX_SIGN_BITMAP_DIM:src/sign_bitmap.rs:60-67.RankQuant::addvalidates row-major length and finite inputs:src/quant.rs:194-203.RankQuant::search_asymmetric_subsetvalidates query length, finite inputs, and candidate bounds with panics/asserts:src/quant.rs:547-564.Proposed Shape
Sketch only:
Equivalent method placement is fine, e.g. associated
RankQuant::validate_params.Acceptance Criteria
RankQuant,Bitmap, andSignBitmap.try_*APIs from Result-returning try_add / try_search* (parallel to the panicking API) #86 can delegate to the same helpers.Non-goals