diff options
author | Paul Masurel <paul.masurel@gmail.com> | 2019-02-05 12:39:30 +0100 |
---|---|---|
committer | Paul Masurel <paul.masurel@gmail.com> | 2019-02-05 12:39:30 +0100 |
commit | 50ed6fb5345303e3aafdd29545d6ce88eb09e3c5 (patch) | |
tree | 4b93cf564ee328dea0fb87b2944cb063b0ed1265 /src | |
parent | 76609deadf4e8eebed4346ba0b1f79bebbe277be (diff) |
Code cleanup
Fixed compilation without the mmap directory
Diffstat (limited to 'src')
-rw-r--r-- | src/core/index.rs | 1 | ||||
-rw-r--r-- | src/positions/reader.rs | 22 | ||||
-rw-r--r-- | src/postings/segment_postings.rs | 6 | ||||
-rw-r--r-- | src/query/boolean_query/mod.rs | 1 |
4 files changed, 13 insertions, 17 deletions
diff --git a/src/core/index.rs b/src/core/index.rs index da3e9f2..338aebb 100644 --- a/src/core/index.rs +++ b/src/core/index.rs @@ -111,7 +111,6 @@ impl Index { } /// Opens or creates a new index in the provided directory - #[cfg(feature = "mmap")] pub fn open_or_create<Dir: Directory>(dir: Dir, schema: Schema) -> Result<Index> { if Index::exists(&dir) { let index = Index::open(dir)?; diff --git a/src/positions/reader.rs b/src/positions/reader.rs index 470abaa..6d2a360 100644 --- a/src/positions/reader.rs +++ b/src/positions/reader.rs @@ -36,22 +36,22 @@ fn read_impl( let mut output_start = 0; let mut output_len = output.len(); let mut ahead = 0; + let bitpacker = BitPacker4x::new(); loop { - let available_len = 128 - inner_offset; + let available_len = COMPRESSION_BLOCK_SIZE - inner_offset; if output_len <= available_len { output[output_start..].copy_from_slice(&buffer[inner_offset..][..output_len]); return ahead; - } else { - output[output_start..][..available_len].copy_from_slice(&buffer[inner_offset..]); - output_len -= available_len; - output_start += available_len; - inner_offset = 0; - let num_bits = num_bits[ahead]; - BitPacker4x::new().decompress(position, &mut buffer[..], num_bits); - let block_len = compressed_block_size(num_bits); - position = &position[block_len..]; - ahead += 1; } + output[output_start..][..available_len].copy_from_slice(&buffer[inner_offset..]); + output_len -= available_len; + output_start += available_len; + inner_offset = 0; + let num_bits = num_bits[ahead]; + bitpacker.decompress(position, &mut buffer[..], num_bits); + let block_len = compressed_block_size(num_bits); + position = &position[block_len..]; + ahead += 1; } } diff --git a/src/postings/segment_postings.rs b/src/postings/segment_postings.rs index a0166d0..a5e2606 100644 --- a/src/postings/segment_postings.rs +++ b/src/postings/segment_postings.rs @@ -124,9 +124,7 @@ impl SegmentPostings { } fn linear_search(arr: &[u32], target: u32) -> usize { - arr.iter() - .map(|&el| if el < target { 1 } else { 0 }) - .sum() + arr.iter().map(|&el| if el < target { 1 } else { 0 }).sum() } fn exponential_search(arr: &[u32], target: u32) -> (usize, usize) { @@ -619,8 +617,8 @@ impl<'b> Streamer<'b> for BlockSegmentPostings { #[cfg(test)] mod tests { - use super::linear_search; use super::exponential_search; + use super::linear_search; use super::search_within_block; use super::BlockSegmentPostings; use super::BlockSegmentPostingsSkipResult; diff --git a/src/query/boolean_query/mod.rs b/src/query/boolean_query/mod.rs index ff31ef0..b450f7f 100644 --- a/src/query/boolean_query/mod.rs +++ b/src/query/boolean_query/mod.rs @@ -8,7 +8,6 @@ mod tests { use super::*; use collector::tests::TestCollector; - use downcast_rs::Downcast; use query::score_combiner::SumWithCoordsCombiner; use query::term_query::TermScorer; use query::Intersection; |