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

Method replace_segments

nodedb/src/engine/array/store/catalog.rs:161–184  ·  view source on GitHub ↗

Remove segments from the manifest and drop their handles. The underlying file is deleted only after the manifest is persisted (caller's responsibility — see [`ArrayStore::unlink_segment`]).

(
        &mut self,
        removed: &[String],
        added: Vec<SegmentRef>,
    )

Source from the content-addressed store, hash-verified

159 /// underlying file is deleted only after the manifest is persisted
160 /// (caller's responsibility — see [`ArrayStore::unlink_segment`]).
161 pub fn replace_segments(
162 &mut self,
163 removed: &[String],
164 added: Vec<SegmentRef>,
165 ) -> Result<(), ArrayStoreError> {
166 let mut new_handles = Vec::with_capacity(added.len());
167 for seg in &added {
168 let h = SegmentHandle::open(
169 &segment_path(&self.root, &seg.id),
170 seg.id.clone(),
171 self.schema_hash,
172 self.kek.as_ref(),
173 )?;
174 new_handles.push(h);
175 }
176 self.manifest.replace(removed, added);
177 for id in removed {
178 self.segments.remove(id);
179 }
180 for h in new_handles {
181 self.segments.insert(h.id().to_string(), h);
182 }
183 Ok(())
184 }
185
186 pub fn persist_manifest(&self) -> Result<(), ArrayStoreError> {
187 self.manifest.persist(&self.root)?;

Callers 3

maybe_compactMethod · 0.80
rewrite_segmentFunction · 0.80
remove_segmentFunction · 0.80

Calls 11

replaceMethod · 0.80
to_stringMethod · 0.80
idMethod · 0.80
segment_pathFunction · 0.70
openFunction · 0.50
lenMethod · 0.45
cloneMethod · 0.45
as_refMethod · 0.45
pushMethod · 0.45
removeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected