Removed access to index in IndexReader

This commit is contained in:
Paul Masurel
2019-12-31 12:16:44 +09:00
parent c0ec7ebf38
commit d13d5b8662
2 changed files with 19 additions and 11 deletions

View File

@@ -471,7 +471,7 @@ mod tests {
.try_into()
.unwrap();
assert_eq!(reader.searcher().num_docs(), 0);
test_index_on_commit_reload_policy_aux(field, &index, &reader);
test_index_on_commit_reload_policy_aux(field, index.clone(), &index, &reader);
}
#[cfg(feature = "mmap")]
@@ -495,7 +495,7 @@ mod tests {
.try_into()
.unwrap();
assert_eq!(reader.searcher().num_docs(), 0);
test_index_on_commit_reload_policy_aux(field, &index, &reader);
test_index_on_commit_reload_policy_aux(field, index.clone(), &index, &reader);
}
#[test]
@@ -537,12 +537,11 @@ mod tests {
.try_into()
.unwrap();
assert_eq!(reader.searcher().num_docs(), 0);
test_index_on_commit_reload_policy_aux(field, &write_index, &reader);
test_index_on_commit_reload_policy_aux(field, read_index, &write_index, &reader);
}
}
fn test_index_on_commit_reload_policy_aux(field: Field, index: &Index, reader: &IndexReader) {
let mut reader_index = reader.index();
fn test_index_on_commit_reload_policy_aux(field: Field, mut reader_index: Index, index: &Index, reader: &IndexReader) {
let (sender, receiver) = crossbeam::channel::unbounded();
let _watch_handle = reader_index.directory_mut().watch(Box::new(move || {
let _ = sender.send(());

View File

@@ -10,7 +10,21 @@ use crate::Index;
use crate::Result;
use crate::Searcher;
use crate::SegmentReader;
use std::sync::Arc;
use std::sync::{Arc, RwLock};
//
//enum SegmentSource {
// FromMetaFile,
// FromWriter(Arc<RwLock<SegmentRegisters>>),
//}
//
//impl SegmentSource {
// fn from_meta_file() -> SegmentSource {
//
// }
//
//}
/// Defines when a new version of the index should be reloaded.
///
@@ -171,11 +185,6 @@ pub struct IndexReader {
}
impl IndexReader {
#[cfg(test)]
pub(crate) fn index(&self) -> Index {
self.inner.index.clone()
}
/// Update searchers so that they reflect the state of the last
/// `.commit()`.
///