Large API Change in the Directory API. (#901)

Tantivy used to assume that all files could be somehow memory mapped. After this change, Directory return a `FileSlice` that can be reduced and eventually read into an `OwnedBytes` object. Long and blocking io operation are still required by they do not span over the entire file.
This commit is contained in:
Paul Masurel
2020-10-08 16:36:51 +09:00
committed by GitHub
parent 579e3d1ed8
commit c23a03ad81
58 changed files with 1497 additions and 1117 deletions

View File

@@ -9,8 +9,8 @@ use crate::directory::META_LOCK;
use crate::Index;
use crate::Searcher;
use crate::SegmentReader;
use std::convert::TryInto;
use std::sync::Arc;
use std::{convert::TryInto, io};
/// Defines when a new version of the index should be reloaded.
///
@@ -138,11 +138,11 @@ impl InnerIndexReader {
.collect::<crate::Result<_>>()?
};
let schema = self.index.schema();
let searchers = std::iter::repeat_with(|| {
let searchers: Vec<Searcher> = std::iter::repeat_with(|| {
Searcher::new(schema.clone(), self.index.clone(), segment_readers.clone())
})
.take(self.num_searchers)
.collect();
.collect::<io::Result<_>>()?;
self.searcher_pool.publish_new_generation(searchers);
Ok(())
}