mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-12-23 08:21:09 +00:00
22 lines
625 B
Rust
22 lines
625 B
Rust
use crate::{
|
|
vector::vector_types::{Vector, VectorType},
|
|
Value,
|
|
};
|
|
|
|
pub fn vector_serialize(x: Vector) -> Value {
|
|
match x.vector_type {
|
|
VectorType::Float32Dense => Value::from_blob(x.bin_eject()),
|
|
VectorType::Float64Dense => {
|
|
let mut data = x.bin_eject();
|
|
data.push(2);
|
|
Value::from_blob(data)
|
|
}
|
|
VectorType::Float32Sparse => {
|
|
let dims = x.dims;
|
|
let mut data = x.bin_eject();
|
|
data.extend_from_slice(&(dims as u32).to_le_bytes());
|
|
data.push(9);
|
|
Value::from_blob(data)
|
|
}
|
|
}
|
|
}
|