MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / seal

Method seal

nodedb-vector/src/collection/lifecycle.rs:155–191  ·  view source on GitHub ↗

Seal the growing segment and return a build request.

(&mut self, key: &str)

Source from the content-addressed store, hash-verified

153
154 /// Seal the growing segment and return a build request.
155 pub fn seal(&mut self, key: &str) -> Option<BuildRequest> {
156 if self.growing.is_empty() {
157 return None;
158 }
159
160 let segment_id = self.next_segment_id;
161 self.next_segment_id += 1;
162
163 let count = self.growing.len();
164 let mut vectors = Vec::with_capacity(count);
165 for i in 0..count as u32 {
166 if let Some(v) = self.growing.get_vector(i) {
167 vectors.push(v.to_vec());
168 }
169 }
170
171 let old_growing = std::mem::replace(
172 &mut self.growing,
173 FlatIndex::new(self.dim, self.params.metric),
174 );
175 let old_base = self.growing_base_id;
176 self.growing_base_id = self.next_id;
177
178 self.building.push(BuildingSegment {
179 flat: old_growing,
180 base_id: old_base,
181 segment_id,
182 });
183
184 Some(BuildRequest {
185 key: key.to_string(),
186 segment_id,
187 vectors,
188 dim: self.dim,
189 params: self.params.clone(),
190 })
191 }
192
193 /// Accept a completed HNSW build from the background thread.
194 ///

Calls 7

to_stringMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
get_vectorMethod · 0.45
pushMethod · 0.45
to_vecMethod · 0.45
cloneMethod · 0.45