This commit is contained in:
Paul Masurel
2016-05-05 00:42:23 +09:00
parent 02e7ed0776
commit 0888beb167
4 changed files with 5 additions and 6 deletions
+1
View File
@@ -2,3 +2,4 @@ target
target/debug
target/release
Cargo.lock
.DS_Store
+3 -3
View File
@@ -18,13 +18,13 @@ impl Recorder for NothingRecorder {
NothingRecorder
}
fn record_position(&mut self, position: u32) {
fn record_position(&mut self, _position: u32) {
}
fn close_doc(&mut self,) {
}
fn get_tf_and_posdeltas(&self, i: usize) -> (u32, &[u32]) {
fn get_tf_and_posdeltas(&self, _: usize) -> (u32, &[u32]) {
(0u32, &EMPTY_ARRAY)
}
}
@@ -43,7 +43,7 @@ impl Recorder for TermFrequencyRecorder {
}
}
fn record_position(&mut self, position: u32) {
fn record_position(&mut self, _position: u32) {
self.current_tf += 1;
}
+1 -1
View File
@@ -103,7 +103,7 @@ impl PostingsSerializer {
if self.is_positions_enabled {
self.position_deltas.extend_from_slice(position_deltas);
}
if self.doc_ids.len() == 128 {
if self.doc_ids.len() == NUM_DOCS_PER_BLOCK {
{
// encode the positions
let block_encoded: &[u32] = self.block_encoder.encode_sorted(&self.doc_ids);
-2
View File
@@ -47,11 +47,9 @@ impl<Rec: Recorder> TermPostingsWriter<Rec> {
}
pub fn serialize(&self, serializer: &mut PostingsSerializer) -> io::Result<()> {
let mut positions_idx = 0;
for (i, doc) in self.doc_ids.iter().enumerate() {
let (term_freq, position_deltas) = self.recorder.get_tf_and_posdeltas(i);
try!(serializer.write_doc(doc.clone(), term_freq, position_deltas));
positions_idx += term_freq as usize;
}
Ok(())
}