mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 03:54:21 +01:00
20 lines
519 B
Rust
20 lines
519 B
Rust
use crate::{
|
|
vector::vector_types::{Vector, VectorType},
|
|
Value,
|
|
};
|
|
|
|
pub fn vector_serialize(mut x: Vector) -> Value {
|
|
match x.vector_type {
|
|
VectorType::Float32Dense => Value::from_blob(x.data),
|
|
VectorType::Float64Dense => {
|
|
x.data.push(2);
|
|
Value::from_blob(x.data)
|
|
}
|
|
VectorType::Float32Sparse => {
|
|
x.data.extend_from_slice(&(x.dims as u32).to_le_bytes());
|
|
x.data.push(9);
|
|
Value::from_blob(x.data)
|
|
}
|
|
}
|
|
}
|