Added fill_buffer in DocSet

This commit is contained in:
Paul Masurel
2017-06-14 18:28:30 +09:00
parent e51feea574
commit 09e27740e2
4 changed files with 17 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ use std::ops::Deref;
/// reasons, we want to ensure that a value spawns over at most 8 bytes
/// of aligns bytes.
///
/// Spawning over 9 bytes is possible for instance, if we do
/// Spanning over 9 bytes is possible for instance, if we do
/// bitpacking with an amplitude of 63 bits.
/// In this case, the second int will start on bit
/// 63 (which belongs to byte 7) and ends at byte 15;

View File

@@ -1,20 +1,17 @@
use std::io;
use std::collections::HashMap;
use directory::ReadOnlySource;
use common::BinarySerializable;
use common::{self, BinarySerializable};
use common::bitpacker::{compute_num_bits, BitUnpacker};
use DocId;
use schema::{Field, SchemaBuilder};
use std::path::Path;
use schema::FAST;
use directory::{WritePtr, RAMDirectory, Directory};
use fastfield::FastFieldSerializer;
use fastfield::FastFieldsWriter;
use common::bitpacker::compute_num_bits;
use common::bitpacker::BitUnpacker;
use fastfield::{FastFieldSerializer, FastFieldsWriter};
use schema::FieldType;
use error::ResultExt;
use std::mem;
use common;
use owning_ref::OwningRef;
/// Trait for accessing a fastfield.
@@ -212,7 +209,7 @@ impl FastFieldReader for I64FastFieldReader {
let output_u64: &mut [u64] = unsafe { mem::transmute(output) };
self.underlying.get_range(start, output_u64);
for mut_val in output_u64.iter_mut() {
*mut_val ^= 1 << 63;
*mut_val = common::u64_to_i64(*mut_val as u64) as u64;
}
}

View File

@@ -52,6 +52,18 @@ pub trait DocSet {
}
}
fn fill_buffer(&mut self, buffer: &mut [DocId]) -> bool {
for buffer_val in buffer.iter_mut() {
if self.advance() {
*buffer_val = self.doc();
}
else {
return false;
}
}
return true;
}
/// Returns the current document
fn doc(&self) -> DocId;

View File

@@ -58,10 +58,8 @@ pub trait Query: fmt::Debug {
/// - iterate throw the matched documents and push them to the collector.
///
fn search(&self, searcher: &Searcher, collector: &mut Collector) -> Result<TimerTree> {
let mut timer_tree = TimerTree::default();
let weight = try!(self.weight(searcher));
{
let mut search_timer = timer_tree.open("search");
for (segment_ord, segment_reader) in searcher.segment_readers().iter().enumerate() {