Skip to main content

VectorCoords

Enum VectorCoords 

Source
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 in f32 (10/7/23 mantissa bits, all ⊂ f32), so the packing is lossless and the kernel’s f32 → f64 widen reads the same number the per-Value walk read.
  • Float64 → F64.
  • Int8/Int16/Int32/Int64 → Int: lossless as i64; 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§

§

F32(Arc<[f32]>)

§

F64(Arc<[f64]>)

§

Int(Arc<[i64]>)

Implementations§

Source§

impl VectorCoords

Source

pub fn from_f32(coords: impl Into<Arc<[f32]>>) -> Self

The f32 family: Float16, BFloat16, Float32.

Source

pub fn from_f64(coords: impl Into<Arc<[f64]>>) -> Self

The f64 family: Float64.

Source

pub fn from_int(coords: impl Into<Arc<[i64]>>) -> Self

The integer family: Int8–Int64, held losslessly as i64.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

pub fn byte_len(&self) -> u64

The family’s slice bytes — len × element_bytes().

Source

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.

Source

pub fn arc_strong_count(&self) -> usize

The family buffer’s strong count — the ownership meters’ holders figure, family-agnostic.

Source

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.

Source

pub fn to_f64_vec(&self) -> Vec<f64>

Every coordinate widened to f64 — the query-side and conversion widenings’ one loop.

Source

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).

Source

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.

Source

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.

Source

pub fn iter(&self) -> impl Iterator<Item = Coord> + '_

Every coordinate in order, for encoding walks (serde, wire).

Source

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).

Source

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.

Source

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).

Source

pub fn invariant_violation(&self, coord: VectorCoordKind) -> Result<(), String>

Trait Implementations§

Source§

impl Clone for VectorCoords

Source§

fn clone(&self) -> Self

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 VectorCoords

Source§

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

Formats the value using the given formatter. Read more
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.

Source§

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

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for VectorCoords

§

impl Freeze for VectorCoords
where *const ArcInner<[f32]> is !null: Freeze, PhantomData<ArcInner<[f32]>>: Freeze, *const ArcInner<[f64]> is !null: Freeze, PhantomData<ArcInner<[f64]>>: Freeze, *const ArcInner<[i64]> is !null: Freeze, PhantomData<ArcInner<[i64]>>: Freeze,

§

impl Move for VectorCoords

§

impl RefUnwindSafe for VectorCoords

§

impl Send for VectorCoords
where Arc<[f32]>: Send, Arc<[f64]>: Send, Arc<[i64]>: Send,

§

impl Sync for VectorCoords
where Arc<[f32]>: Sync, Arc<[f64]>: Sync, Arc<[i64]>: Sync,

§

impl Unpin for VectorCoords
where Arc<[f32]>: Unpin, Arc<[f64]>: Unpin, Arc<[i64]>: Unpin,

§

impl UnsafeUnpin for VectorCoords
where *const ArcInner<[f32]> is !null: UnsafeUnpin, PhantomData<ArcInner<[f32]>>: UnsafeUnpin, *const ArcInner<[f64]> is !null: UnsafeUnpin, PhantomData<ArcInner<[f64]>>: UnsafeUnpin, *const ArcInner<[i64]> is !null: UnsafeUnpin, PhantomData<ArcInner<[i64]>>: UnsafeUnpin,

§

impl UnwindSafe for VectorCoords

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.