Skip to main content

Module vector

Module vector 

Source
Expand description

First-class VECTOR value type.

LoraDB VECTOR values are fixed-dimension, typed numeric coordinate collections. A LoraVector can be stored directly as a node or relationship property, returned through every binding, compared for equality, and used as input to the built-in vector math functions (vector.similarity.cosine, vector.similarity.euclidean, vector_distance, vector_norm, vector_dimension_count, toIntegerList, toFloatList).

Vector indexes and approximate kNN are intentionally out of scope for this pass — exhaustive search via ORDER BY vector.similarity.*(…) LIMIT k works today; an index-backed variant is future work.

Structs§

LoraVector
A first-class VECTOR value.

Enums§

RawCoordinate
Raw numeric input for one coordinate before it has been coerced into the destination coordinate type. Executors / binding layers feed values through this enum so the coercion rules live in one place.
VectorBuildError
Error returned by LoraVector::try_new. Kept as a concrete enum so the executor can render a single-line error message without inspecting the underlying cause.
VectorCoordinateType
Canonical coordinate type for a vector.
VectorValues
Internal storage for a vector. One variant per supported coordinate type; dimension is implicit in the inner Vec’s length.

Constants§

MAX_VECTOR_DIMENSION
Maximum dimension accepted by LoraDB’s vector(...) constructor.

Functions§

cosine_similarity_bounded
Cosine similarity squashed into [0, 1]. Matches the documented vector.similarity.cosine behaviour.
cosine_similarity_raw
Raw cosine similarity in the range [-1, 1]. Returns None when either vector has zero norm, since cosine is undefined in that case.
dot_product
Dot product (f32 arithmetic, widened back to f64).
euclidean_distance
Euclidean (L2) distance.
euclidean_distance_squared
Squared Euclidean distance (sum of squared differences). Uses f32 arithmetic to match LoraDB’s vector function implementation.
euclidean_norm
Euclidean (L2) norm.
euclidean_similarity
Similarity score derived from squared Euclidean distance: 1 / (1 + d²). For the documented example where distance² == 22, this yields 1 / 23 ≈ 0.043478.
hamming_distance
Hamming distance: count of positions where the two vectors differ.
manhattan_distance
Manhattan (L1) distance.
manhattan_norm
Manhattan (L1) norm.
parse_string_values
Parse a string-form coordinate list, e.g. "[1.05e+00, 0.123, 5]". Used by vector() when vectorValue is a STRING.