undo changes to segment_updater.rs

This commit is contained in:
Ming Ying
2024-12-07 16:37:34 -05:00
committed by Stu Hood
parent 3afe3714a2
commit d742d3277a

View File

@@ -264,6 +264,7 @@ pub(crate) struct InnerSegmentUpdater {
//
// This should be up to date as all update happen through
// the unique active `SegmentUpdater`.
active_index_meta: RwLock<Arc<IndexMeta>>,
pool: ThreadPool,
merge_thread_pool: ThreadPool,
@@ -313,6 +314,7 @@ impl SegmentUpdater {
})?;
let index_meta = index.load_metas()?;
Ok(SegmentUpdater(Arc::new(InnerSegmentUpdater {
active_index_meta: RwLock::new(Arc::new(index_meta)),
pool,
merge_thread_pool,
index,
@@ -418,6 +420,7 @@ impl SegmentUpdater {
};
// TODO add context to the error.
save_metas(&index_meta, directory.box_clone().borrow_mut())?;
self.store_meta(&index_meta);
}
Ok(())
}
@@ -458,8 +461,12 @@ impl SegmentUpdater {
})
}
fn store_meta(&self, index_meta: &IndexMeta) {
*self.active_index_meta.write().unwrap() = Arc::new(index_meta.clone());
}
fn load_meta(&self) -> Arc<IndexMeta> {
Arc::new(self.index.load_metas().expect("Failed to load meta"))
self.active_index_meta.read().unwrap().clone()
}
pub(crate) fn make_merge_operation(&self, segment_ids: &[SegmentId]) -> MergeOperation {