Spaces:
Build error
Build error
File size: 1,611 Bytes
84d2a97 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
use std::num::NonZeroU64;
use segment::types::{Distance, MultiVectorConfig, QuantizationConfig};
use crate::operations::config_diff::HnswConfigDiff;
use crate::operations::types::{Datatype, VectorParams};
pub struct VectorParamsBuilder {
vector_params: VectorParams,
}
impl VectorParamsBuilder {
pub fn new(size: u64, distance: Distance) -> Self {
VectorParamsBuilder {
vector_params: VectorParams {
size: NonZeroU64::new(size).unwrap(),
distance,
hnsw_config: None,
quantization_config: None,
on_disk: None,
datatype: None,
multivector_config: None,
},
}
}
pub fn with_hnsw_config(mut self, hnsw_config: HnswConfigDiff) -> Self {
self.vector_params.hnsw_config = Some(hnsw_config);
self
}
pub fn with_quantization_config(mut self, quantization_config: QuantizationConfig) -> Self {
self.vector_params.quantization_config = Some(quantization_config);
self
}
pub fn with_on_disk(mut self, on_disk: bool) -> Self {
self.vector_params.on_disk = Some(on_disk);
self
}
pub fn with_datatype(mut self, datatype: Datatype) -> Self {
self.vector_params.datatype = Some(datatype);
self
}
pub fn with_multivector_config(mut self, multivector_config: MultiVectorConfig) -> Self {
self.vector_params.multivector_config = Some(multivector_config);
self
}
pub fn build(self) -> VectorParams {
self.vector_params
}
}
|