pub enum VectorCoords {
F32(Arc<[f32]>),
F64(Arc<[f64]>),
Int(Arc<[i64]>),
}Expand description
A vector’s coordinates, packed per coordinate family (ADR-0706):
Float16/BFloat16/Float32→F32: every value of those kinds is exactly representable inf32(10/7/23 mantissa bits, all ⊂f32), so the packing is lossless and the kernel’sf32 → f64widen reads the same number the per-Valuewalk read.Float64→F64.Int8/Int16/Int32/Int64→Int: lossless asi64; the kind’s width was validated when the coordinates were coerced.
Replaces Vec<CypherValue> (48 bytes per coordinate) at 4/8/8 bytes
per coordinate — the value is the packed form, so nothing scan-side
copies or invalidates it: a rewrite swaps the Arc, and the MVCC
version chain hands every reader the exact buffer its snapshot should
see.
Variants§
Implementations§
Source§impl VectorCoords
impl VectorCoords
Sourcepub fn from_f32(coords: impl Into<Arc<[f32]>>) -> Self
pub fn from_f32(coords: impl Into<Arc<[f32]>>) -> Self
The f32 family: Float16, BFloat16, Float32.
Sourcepub fn from_int(coords: impl Into<Arc<[i64]>>) -> Self
pub fn from_int(coords: impl Into<Arc<[i64]>>) -> Self
The integer family: Int8–Int64, held losslessly as i64.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn element_bytes(&self) -> u64
pub fn element_bytes(&self) -> u64
The family’s element width in bytes — the one width table the memory charges read, never re-spelled 4/8/8 at a use site.
Sourcepub fn arc_id(&self) -> *const u8
pub fn arc_id(&self) -> *const u8
The family buffer’s address — the dedup meters’ identity key, family-agnostic so no meter enumerates the three arms.
Sourcepub fn arc_strong_count(&self) -> usize
pub fn arc_strong_count(&self) -> usize
The family buffer’s strong count — the ownership meters’ holders figure, family-agnostic.
Sourcepub fn is_unique(&self) -> bool
pub fn is_unique(&self) -> bool
Whether this value is the family buffer’s sole owner — the unique-heap meters’ one test, over the one holders figure.
Sourcepub fn to_f64_vec(&self) -> Vec<f64>
pub fn to_f64_vec(&self) -> Vec<f64>
Every coordinate widened to f64 — the query-side and conversion
widenings’ one loop.
Sourcepub fn numeric_eq(&self, other: &VectorCoords) -> bool
pub fn numeric_eq(&self, other: &VectorCoords) -> bool
The elementwise numeric equality — Coord::numeric_eq over the
two buffers, gated on length. The one vector-equality policy,
shared by CypherValue::eq and the core value’s eq_non_null
(and by PartialEq).
Sourcepub fn coord_at(&self, i: usize) -> Coord
pub fn coord_at(&self, i: usize) -> Coord
The ith coordinate, for display and encoding. Panics only when
out of bounds — callers bound by VectorCoords::len.
Sourcepub fn coord_f64(&self, i: usize) -> f64
pub fn coord_f64(&self, i: usize) -> f64
The ith coordinate widened to f64 — the similarity kernels’
one read. The per-Value walk this replaces could return None
for a non-number coordinate; the packed form is homogeneous and
numeric by construction, so the skip contract it fed cannot arise.
Panics only when out of bounds.
Sourcepub fn iter(&self) -> impl Iterator<Item = Coord> + '_
pub fn iter(&self) -> impl Iterator<Item = Coord> + '_
Every coordinate in order, for encoding walks (serde, wire).
Sourcepub fn from_coords(
coord: VectorCoordKind,
coords: impl Iterator<Item = Coord>,
) -> Option<VectorCoords>
pub fn from_coords( coord: VectorCoordKind, coords: impl Iterator<Item = Coord>, ) -> Option<VectorCoords>
Decoded or coerced coordinates packed per family — the ONE
family-selection policy (ADR-0706): every bridge that holds
already-converted coordinates (the serde decoder, the core JSON
codecs, the FFI parameter bridge, vector()’s coercion) classifies
its elements and lands here, so the family mapping, the empty
vector, and the one-family-per-vector rule have one spelling.
None when an element does not conform to the kind or the
coordinates mix families (the caller maps that to its own typed
error); the canonical constructors re-assert the invariant
regardless.
The Coord::I token under a float kind packs as the Int family
at full i64 range (its equality with the float spelling is the
exact numeric rule, which widening would round away past 2^53).
Sourcepub fn from_cypher_values(
coord: VectorCoordKind,
values: &[CypherValue],
) -> Option<VectorCoords>
pub fn from_cypher_values( coord: VectorCoordKind, values: &[CypherValue], ) -> Option<VectorCoords>
from_coords over already-coerced
CypherValues — the FFI parameter bridge’s thin adapter. A
non-number element rejects directly (None), never through a
sentinel the policy would have to reject incidentally.
Sourcepub fn assert_conforms(&self, coord: VectorCoordKind)
pub fn assert_conforms(&self, coord: VectorCoordKind)
The family/kind pairing and per-coordinate exactness invariant the
canonical constructors assert (ADR-0706) — one spelling shared by
the model and core constructors. Err carries the invariant
message; user-input rejection stays typed at the coercion
boundaries, so this firing is an engine bug, not a data condition.
The Int family is legal under every kind, not only the integer
kinds: a float-kind vector may carry integer coordinates (the
decoded form of integers a persisted store held), and its equality
with the float-family vector of the same numbers is the exact
numeric elementwise rule (eq_i64_f64), which widening a large
i64 to f64 would round away. Range is still the kind’s own
(holds_int).
Assert this buffer conforms to coord — the constructors’ one
panicking invariant check (the data-side rejection shape is
VectorCoords::from_coords’s Option, the only fallible form).
pub fn invariant_violation(&self, coord: VectorCoordKind) -> Result<(), String>
Trait Implementations§
Source§impl Clone for VectorCoords
impl Clone for VectorCoords
Source§impl Debug for VectorCoords
impl Debug for VectorCoords
Source§impl PartialEq for VectorCoords
The one equality: VectorCoords::numeric_eq — the elementwise
numeric rule every value type’s vector comparison already applies, so
the derived variant-strict form cannot disagree with it anywhere.
impl PartialEq for VectorCoords
The one equality: VectorCoords::numeric_eq — the elementwise
numeric rule every value type’s vector comparison already applies, so
the derived variant-strict form cannot disagree with it anywhere.