diff --git a/src/datastruct/fstmap.rs b/src/datastruct/fstmap.rs index 428e9b710..adb3e6e35 100644 --- a/src/datastruct/fstmap.rs +++ b/src/datastruct/fstmap.rs @@ -20,7 +20,7 @@ pub struct FstMapBuilder { } impl FstMapBuilder { - + pub fn new(w: W) -> io::Result> { let fst_builder = try!(fst::MapBuilder::new(w).map_err(convert_fst_error)); Ok(FstMapBuilder { @@ -50,6 +50,7 @@ impl FstMapBuilder { Ok(()) } + #[cfg(test)] pub fn insert(&mut self, key: &[u8], value: &V) -> io::Result<()> { try!(self.fst_builder .insert(key, self.data.len() as u64) @@ -146,7 +147,6 @@ mod tests { assert_eq!(keys.next().unwrap(), "abc".as_bytes()); assert_eq!(keys.next().unwrap(), "abcd".as_bytes()); assert_eq!(keys.next(), None); - } } diff --git a/src/postings/recorder.rs b/src/postings/recorder.rs index 94173720b..05586858a 100644 --- a/src/postings/recorder.rs +++ b/src/postings/recorder.rs @@ -26,8 +26,6 @@ pub trait Recorder: HeapAllocable { fn record_position(&mut self, position: u32, heap: &Heap); /// Close the document. It will help record the term frequency. fn close_doc(&mut self, heap: &Heap); - /// Returns the number of document that have been seen so far - fn doc_freq(&self) -> u32; /// Pushes the postings information to the serializer. fn serialize(&self, self_addr: u32, @@ -41,7 +39,6 @@ pub trait Recorder: HeapAllocable { pub struct NothingRecorder { stack: ExpUnrolledLinkedList, current_doc: DocId, - doc_freq: u32, } impl HeapAllocable for NothingRecorder { @@ -49,7 +46,6 @@ impl HeapAllocable for NothingRecorder { NothingRecorder { stack: ExpUnrolledLinkedList::with_addr(addr), current_doc: u32::max_value(), - doc_freq: 0u32, } } } @@ -62,17 +58,12 @@ impl Recorder for NothingRecorder { fn new_doc(&mut self, doc: DocId, heap: &Heap) { self.current_doc = doc; self.stack.push(doc, heap); - self.doc_freq += 1; } fn record_position(&mut self, _position: u32, _heap: &Heap) {} fn close_doc(&mut self, _heap: &Heap) {} - fn doc_freq(&self) -> u32 { - self.doc_freq - } - fn serialize(&self, self_addr: u32, serializer: &mut PostingsSerializer, @@ -91,7 +82,6 @@ pub struct TermFrequencyRecorder { stack: ExpUnrolledLinkedList, current_doc: DocId, current_tf: u32, - doc_freq: u32, } impl HeapAllocable for TermFrequencyRecorder { @@ -100,7 +90,6 @@ impl HeapAllocable for TermFrequencyRecorder { stack: ExpUnrolledLinkedList::with_addr(addr), current_doc: u32::max_value(), current_tf: 0u32, - doc_freq: 0u32, } } } @@ -111,7 +100,6 @@ impl Recorder for TermFrequencyRecorder { } fn new_doc(&mut self, doc: DocId, heap: &Heap) { - self.doc_freq += 1u32; self.current_doc = doc; self.stack.push(doc, heap); } @@ -126,10 +114,6 @@ impl Recorder for TermFrequencyRecorder { self.current_tf = 0; } - fn doc_freq(&self) -> u32 { - self.doc_freq - } - fn serialize(&self, self_addr: u32, serializer: &mut PostingsSerializer, @@ -154,7 +138,6 @@ impl Recorder for TermFrequencyRecorder { pub struct TFAndPositionRecorder { stack: ExpUnrolledLinkedList, current_doc: DocId, - doc_freq: u32, } impl HeapAllocable for TFAndPositionRecorder { @@ -162,7 +145,6 @@ impl HeapAllocable for TFAndPositionRecorder { TFAndPositionRecorder { stack: ExpUnrolledLinkedList::with_addr(addr), current_doc: u32::max_value(), - doc_freq: 0u32, } } } @@ -173,7 +155,6 @@ impl Recorder for TFAndPositionRecorder { } fn new_doc(&mut self, doc: DocId, heap: &Heap) { - self.doc_freq += 1; self.current_doc = doc; self.stack.push(doc, heap); } @@ -186,10 +167,6 @@ impl Recorder for TFAndPositionRecorder { self.stack.push(POSITION_END, heap); } - fn doc_freq(&self) -> u32 { - self.doc_freq - } - fn serialize(&self, self_addr: u32, serializer: &mut PostingsSerializer,