Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add has_merging_threads function to IndexWriter #2553

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/indexer/index_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ impl<D: Document> IndexWriter<D> {
&self.index
}

/// Check if there are any merging threads
/// Does not block
pub fn has_merging_threads(&self) -> bool {
self.segment_updater.has_merging_threads()
}

/// If there are some merging threads, blocks until they all finish their work and
/// then drop the `IndexWriter`.
pub fn wait_merging_threads(mut self) -> crate::Result<()> {
Expand Down
5 changes: 5 additions & 0 deletions src/indexer/segment_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,11 @@ impl SegmentUpdater {
Ok(after_merge_segment_meta)
}

/// Check if there are still pending merges without blocking
pub fn has_merging_threads(&self) -> bool {
self.merge_operations.len() > 0
}

/// Wait for current merging threads.
///
/// Upon termination of the current merging threads,
Expand Down
Loading