Exposed API to create a new Segment.

This commit is contained in:
Paul Masurel
2017-05-13 15:15:35 +09:00
parent 574feb8026
commit d07e896a2f
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -356,6 +356,11 @@ impl IndexWriter {
result
}
#[doc(hidden)]
pub fn new_segment(&self) -> Segment {
self.segment_updater.new_segment()
}
/// Spawns a new worker thread for indexing.
/// The thread consumes documents from the pipeline.
///
@@ -429,6 +434,12 @@ impl IndexWriter {
Ok(())
}
pub fn add_segment(&mut self, segment_meta: SegmentMeta) {
let delete_cursor = self.delete_queue.cursor();
let segment_entry = SegmentEntry::new(segment_meta, delete_cursor, None);
self.segment_updater.add_segment(self.generation, segment_entry);
}
/// Detects and removes the files that
/// are not used by the index anymore.
pub fn garbage_collect_files(&mut self) -> Result<()> {
+1 -1
View File
@@ -120,7 +120,7 @@ pub mod fastfield;
pub use directory::Directory;
pub use core::{Index, Segment, SegmentId, SegmentMeta, Searcher};
pub use core::{Index, Segment, SegmentComponent, SegmentId, SegmentMeta, Searcher};
pub use indexer::IndexWriter;
pub use schema::{Term, Document};
pub use core::SegmentReader;