qdrant_edge/edge/builders/
edge_config.rs1use std::collections::HashMap;
8
9use crate::segment::types::{HnswConfig, QuantizationConfig, VectorNameBuf};
10use crate::wal::WalOptions;
11
12use crate::edge::config::optimizers::EdgeOptimizersConfig;
13use crate::edge::config::shard::EdgeConfig;
14use crate::edge::config::vectors::{EdgeSparseVectorParams, EdgeVectorParams};
15
16#[derive(Debug, Default)]
23pub struct EdgeConfigBuilder {
24 on_disk_payload: Option<bool>,
25 vectors: HashMap<VectorNameBuf, EdgeVectorParams>,
26 sparse_vectors: HashMap<VectorNameBuf, EdgeSparseVectorParams>,
27 hnsw_config: Option<HnswConfig>,
28 quantization_config: Option<QuantizationConfig>,
29 optimizers: Option<EdgeOptimizersConfig>,
30 wal_options: Option<WalOptions>,
31 max_search_threads: Option<usize>,
32 search_pool_core: Option<usize>,
33}
34
35impl EdgeConfigBuilder {
36 pub fn new() -> Self {
37 Self::default()
38 }
39
40 pub fn vector(mut self, name: impl Into<VectorNameBuf>, params: EdgeVectorParams) -> Self {
43 self.vectors.insert(name.into(), params);
44 self
45 }
46
47 pub fn vectors(mut self, vectors: HashMap<VectorNameBuf, EdgeVectorParams>) -> Self {
49 self.vectors = vectors;
50 self
51 }
52
53 pub fn sparse_vector(
56 mut self,
57 name: impl Into<VectorNameBuf>,
58 params: EdgeSparseVectorParams,
59 ) -> Self {
60 self.sparse_vectors.insert(name.into(), params);
61 self
62 }
63
64 pub fn sparse_vectors(
66 mut self,
67 sparse_vectors: HashMap<VectorNameBuf, EdgeSparseVectorParams>,
68 ) -> Self {
69 self.sparse_vectors = sparse_vectors;
70 self
71 }
72
73 pub fn on_disk_payload(mut self, on_disk_payload: bool) -> Self {
74 self.on_disk_payload = Some(on_disk_payload);
75 self
76 }
77
78 pub fn hnsw_config(mut self, hnsw_config: HnswConfig) -> Self {
79 self.hnsw_config = Some(hnsw_config);
80 self
81 }
82
83 pub fn quantization_config(mut self, quantization_config: QuantizationConfig) -> Self {
84 self.quantization_config = Some(quantization_config);
85 self
86 }
87
88 pub fn optimizers(mut self, optimizers: EdgeOptimizersConfig) -> Self {
89 self.optimizers = Some(optimizers);
90 self
91 }
92
93 pub fn wal_options(mut self, wal_options: WalOptions) -> Self {
94 self.wal_options = Some(wal_options);
95 self
96 }
97
98 pub fn max_search_threads(mut self, max_search_threads: usize) -> Self {
101 self.max_search_threads = Some(max_search_threads);
102 self
103 }
104
105 pub fn search_pool_core(mut self, core: usize) -> Self {
108 self.search_pool_core = Some(core);
109 self
110 }
111
112 pub fn build(self) -> EdgeConfig {
113 let Self {
116 on_disk_payload,
117 vectors,
118 sparse_vectors,
119 hnsw_config,
120 quantization_config,
121 optimizers,
122 wal_options,
123 max_search_threads,
124 search_pool_core,
125 } = self;
126 EdgeConfig {
127 on_disk_payload,
128 vectors,
129 sparse_vectors,
130 hnsw_config,
131 quantization_config,
132 optimizers,
133 wal_options,
134 max_search_threads,
135 search_pool_core,
136 }
137 }
138}