mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-09 18:42:54 +00:00
Merge pull request #941 from tantivy-search/revert-940-guilload--move-list-files-to-index
Revert "Move `SegmentUpdater::list_files()` to `Index`"
This commit is contained in:
@@ -233,20 +233,6 @@ impl Index {
|
||||
self.inventory.all()
|
||||
}
|
||||
|
||||
/// List the files that are useful to the index.
|
||||
///
|
||||
/// This does not include lock files, or files that are obsolete
|
||||
/// but have not yet been deleted by the garbage collector.
|
||||
pub fn list_files(&self) -> HashSet<PathBuf> {
|
||||
let mut files: HashSet<PathBuf> = self
|
||||
.list_all_segment_metas()
|
||||
.into_iter()
|
||||
.flat_map(|segment_meta| segment_meta.list_files())
|
||||
.collect();
|
||||
files.insert(META_FILEPATH.to_path_buf());
|
||||
files
|
||||
}
|
||||
|
||||
/// Creates a new segment_meta (Advanced user only).
|
||||
///
|
||||
/// As long as the `SegmentMeta` lives, the files associated with the
|
||||
|
||||
@@ -27,6 +27,7 @@ use std::borrow::BorrowMut;
|
||||
use std::collections::HashSet;
|
||||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::RwLock;
|
||||
@@ -98,8 +99,9 @@ async fn garbage_collect_files(
|
||||
) -> crate::Result<GarbageCollectionResult> {
|
||||
info!("Running garbage collection");
|
||||
let mut index = segment_updater.index.clone();
|
||||
let files = index.list_files();
|
||||
index.directory_mut().garbage_collect(move || files)
|
||||
index
|
||||
.directory_mut()
|
||||
.garbage_collect(move || segment_updater.list_files())
|
||||
}
|
||||
|
||||
/// Merges a list of segments the list of segment givens in the `segment_entries`.
|
||||
@@ -310,6 +312,21 @@ impl SegmentUpdater {
|
||||
self.schedule_future(garbage_collect_future)
|
||||
}
|
||||
|
||||
/// List the files that are useful to the index.
|
||||
///
|
||||
/// This does not include lock files, or files that are obsolete
|
||||
/// but have not yet been deleted by the garbage collector.
|
||||
fn list_files(&self) -> HashSet<PathBuf> {
|
||||
let mut files: HashSet<PathBuf> = self
|
||||
.index
|
||||
.list_all_segment_metas()
|
||||
.into_iter()
|
||||
.flat_map(|segment_meta| segment_meta.list_files())
|
||||
.collect();
|
||||
files.insert(META_FILEPATH.to_path_buf());
|
||||
files
|
||||
}
|
||||
|
||||
pub fn schedule_commit(
|
||||
&self,
|
||||
opstamp: Opstamp,
|
||||
|
||||
Reference in New Issue
Block a user