From 83eb0d0cb7ed839f720c206ecef4b16e7e220de1 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Wed, 20 Mar 2019 10:21:15 +0900 Subject: [PATCH] Disabling tests on Android --- .travis.yml | 4 +-- src/core/index.rs | 14 ++++----- src/directory/managed_directory.rs | 2 -- src/directory/mmap_directory.rs | 1 - src/postings/segment_postings.rs | 46 +++++++++++++++--------------- 5 files changed, 31 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea3d037ab..ae81a31f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ addons: matrix: include: # Android - - env: TARGET=aarch64-linux-android + - env: TARGET=aarch64-linux-android DISABLE_TESTS #- env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 #- env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 #- env: TARGET=i686-linux-android DISABLE_TESTS=1 @@ -77,4 +77,4 @@ before_cache: notifications: email: - on_success: never \ No newline at end of file + on_success: never diff --git a/src/core/index.rs b/src/core/index.rs index 5e8e08200..8e1709ce4 100644 --- a/src/core/index.rs +++ b/src/core/index.rs @@ -6,6 +6,8 @@ use core::SegmentId; use core::SegmentMeta; use core::META_FILEPATH; use directory::ManagedDirectory; +#[cfg(feature = "mmap")] +use directory::MmapDirectory; use directory::INDEX_WRITER_LOCK; use directory::{Directory, RAMDirectory}; use error::DataCorruption; @@ -22,15 +24,13 @@ use schema::Schema; use serde_json; use std::borrow::BorrowMut; use std::fmt; +#[cfg(feature = "mmap")] +use std::path::Path; use std::sync::Arc; use tokenizer::BoxedTokenizer; use tokenizer::TokenizerManager; use IndexWriter; use Result; -#[cfg(feature = "mmap")] -use std::path::Path; -#[cfg(feature = "mmap")] -use directory::MmapDirectory; fn load_metas(directory: &Directory) -> Result { let meta_data = directory.atomic_read(&META_FILEPATH)?; @@ -443,13 +443,12 @@ mod tests { test_index_on_commit_reload_policy_aux(field, &mut writer, &reader); } - - #[cfg(feature="mmap")] + #[cfg(feature = "mmap")] mod mmap_specific { + use super::*; use std::path::PathBuf; use tempdir::TempDir; - use super::*; #[test] fn test_index_on_commit_reload_policy_mmap() { @@ -509,7 +508,6 @@ mod tests { } } - fn test_index_on_commit_reload_policy_aux( field: Field, writer: &mut IndexWriter, diff --git a/src/directory/managed_directory.rs b/src/directory/managed_directory.rs index b2f2bfc34..8faef439d 100644 --- a/src/directory/managed_directory.rs +++ b/src/directory/managed_directory.rs @@ -267,7 +267,6 @@ mod tests { use std::path::Path; use tempdir::TempDir; - lazy_static! { static ref TEST_PATH1: &'static Path = Path::new("some_path_for_test"); static ref TEST_PATH2: &'static Path = Path::new("some_path_for_test2"); @@ -353,7 +352,6 @@ mod tests { } } - } } diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 0f1f19384..f8f0810d0 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -36,7 +36,6 @@ use std::sync::Weak; use std::thread; use tempdir::TempDir; - /// Create a default io error given a string. pub(crate) fn make_io_err(msg: String) -> io::Error { io::Error::new(io::ErrorKind::Other, msg) diff --git a/src/postings/segment_postings.rs b/src/postings/segment_postings.rs index 807265348..e6eca614b 100644 --- a/src/postings/segment_postings.rs +++ b/src/postings/segment_postings.rs @@ -153,6 +153,25 @@ fn search_within_block(block_docs: &[u32], target: u32) -> usize { } impl DocSet for SegmentPostings { + // goes to the next element. + // next needs to be called a first time to point to the correct element. + #[inline] + fn advance(&mut self) -> bool { + if self.position_computer.is_some() { + let term_freq = self.term_freq() as usize; + self.position_computer.as_mut().unwrap().add_skip(term_freq); + } + self.cur += 1; + if self.cur >= self.block_cursor.block_len() { + self.cur = 0; + if !self.block_cursor.advance() { + self.cur = COMPRESSION_BLOCK_SIZE; + return false; + } + } + true + } + fn skip_next(&mut self, target: DocId) -> SkipResult { if !self.advance() { return SkipResult::End; @@ -235,29 +254,6 @@ impl DocSet for SegmentPostings { } } - // goes to the next element. - // next needs to be called a first time to point to the correct element. - #[inline] - fn advance(&mut self) -> bool { - if self.position_computer.is_some() { - let term_freq = self.term_freq() as usize; - self.position_computer.as_mut().unwrap().add_skip(term_freq); - } - self.cur += 1; - if self.cur >= self.block_cursor.block_len() { - self.cur = 0; - if !self.block_cursor.advance() { - self.cur = COMPRESSION_BLOCK_SIZE; - return false; - } - } - true - } - - fn size_hint(&self) -> u32 { - self.len() as u32 - } - /// Return the current document's `DocId`. #[inline] fn doc(&self) -> DocId { @@ -269,6 +265,10 @@ impl DocSet for SegmentPostings { docs[self.cur] } + fn size_hint(&self) -> u32 { + self.len() as u32 + } + fn append_to_bitset(&mut self, bitset: &mut BitSet) { // finish the current block if self.advance() {