From fac0013454302208e9abff2660c506e1d5c2ff80 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Thu, 4 Apr 2019 09:36:06 +0900 Subject: [PATCH] Added flush --- src/directory/directory.rs | 8 ++++++++ src/indexer/segment_updater.rs | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/directory/directory.rs b/src/directory/directory.rs index 943998e2d..9c2af62e2 100644 --- a/src/directory/directory.rs +++ b/src/directory/directory.rs @@ -205,6 +205,14 @@ pub trait Directory: DirectoryClone + fmt::Debug + Send + Sync + 'static { /// `OnCommit` `ReloadPolicy`. Not implementing watch in a `Directory` only prevents the /// `OnCommit` `ReloadPolicy` to work properly. fn watch(&self, watch_callback: WatchCallback) -> WatchHandle; + + /// Ensure that all volatile files reach are persisted (in directory where that makes sense.) + /// + /// In order to make Near Real Time efficient, tantivy introduced the notion of soft_commit vs + /// commit. Commit will call `.flush()`, while softcommit won't. + fn flush(&self) -> io::Result<()> { + Ok(()) + } } /// DirectoryClone diff --git a/src/indexer/segment_updater.rs b/src/indexer/segment_updater.rs index b5132dfd3..257cc1ff5 100644 --- a/src/indexer/segment_updater.rs +++ b/src/indexer/segment_updater.rs @@ -296,14 +296,16 @@ impl SegmentUpdater { // segment. However, we do not want to mark them as committed, and we want // to keep the current set of committed segment. segment_updater.0.segment_manager.soft_commit(opstamp, segment_entries); - // ... obviously we do not save the meta file. + // ... We do not save the meta file. } else { // Hard_commit. We register the new segment entries as committed. segment_updater .0 .segment_manager .commit(opstamp, segment_entries); + // TODO error handling. segment_updater.save_metas(opstamp, payload); + segment_updater.0.index.directory().flush().unwrap(); } segment_updater.garbage_collect_files_exec(); segment_updater.consider_merge_options();