mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-20 10:10:42 +00:00
take in account doc_freq for the docid buffer.
This commit is contained in:
@@ -95,7 +95,7 @@ impl<'a> PostingsMerger<'a> {
|
||||
{
|
||||
let offset = self.doc_offsets[heap_item.segment_ord];
|
||||
let reader = &self.readers[heap_item.segment_ord];
|
||||
for doc_id in reader.read_postings(heap_item.term_info.postings_offset) {
|
||||
for doc_id in reader.read_postings(&heap_item.term_info) {
|
||||
self.doc_ids.push(offset + doc_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ impl SegmentPostings {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_data(data: &[u8]) -> SegmentPostings {
|
||||
pub fn from_data(doc_freq: DocId, data: &[u8]) -> SegmentPostings {
|
||||
let mut cursor = Cursor::new(data);
|
||||
let data: Vec<u32> = Vec::deserialize(&mut cursor).unwrap();
|
||||
let mut doc_ids: Vec<u32> = (0u32..data.len() as u32 + 1_000 as u32).collect();
|
||||
let mut doc_ids: Vec<u32> = (0u32..doc_freq).collect();
|
||||
let decoder = Decoder::new();
|
||||
let num_doc_ids = decoder.decode_sorted(&data, &mut doc_ids);
|
||||
doc_ids.truncate(num_doc_ids);
|
||||
@@ -153,9 +153,10 @@ impl SegmentReader {
|
||||
self.fast_fields_reader.get_field(u32_field)
|
||||
}
|
||||
|
||||
pub fn read_postings(&self, offset: u32) -> SegmentPostings {
|
||||
let postings_data = &self.postings_data.as_slice()[(offset as usize)..];
|
||||
SegmentPostings::from_data(&postings_data)
|
||||
pub fn read_postings(&self, term_info: &TermInfo) -> SegmentPostings {
|
||||
let offset = term_info.postings_offset as usize;
|
||||
let postings_data = &self.postings_data.as_slice()[offset..];
|
||||
SegmentPostings::from_data(term_info.doc_freq, &postings_data)
|
||||
}
|
||||
|
||||
fn get_term<'a>(&'a self, term: &Term) -> Option<TermInfo> {
|
||||
@@ -170,7 +171,7 @@ impl SegmentReader {
|
||||
for term in terms.iter() {
|
||||
match self.get_term(term) {
|
||||
Some(term_info) => {
|
||||
let segment_posting = self.read_postings(term_info.postings_offset);
|
||||
let segment_posting = self.read_postings(&term_info);
|
||||
segment_postings.push(segment_posting);
|
||||
}
|
||||
None => {
|
||||
|
||||
@@ -76,7 +76,6 @@ impl IndexWriter {
|
||||
segment_writer.finalize().unwrap();
|
||||
index_clone.sync(&segment).unwrap();
|
||||
index_clone.publish_segment(&segment).unwrap();
|
||||
// segment_writer.commit().unwrap();
|
||||
}
|
||||
})
|
||||
}).collect();
|
||||
@@ -107,7 +106,7 @@ impl IndexWriter {
|
||||
}
|
||||
|
||||
pub fn add_document(&mut self, doc: Document) -> io::Result<()> {
|
||||
let arc_doc = ArcDoc::new(doc);
|
||||
let arc_doc = ArcDoc::new(doc);
|
||||
try!(
|
||||
self.queue_input.send(arc_doc)
|
||||
.map_err(|e| io::Error::new(ErrorKind::Other, e))
|
||||
|
||||
@@ -30,6 +30,8 @@ extern crate num_cpus;
|
||||
|
||||
mod core;
|
||||
|
||||
pub use core::directory::Directory;
|
||||
pub use core::searcher::Searcher;
|
||||
pub use core::index::Index;
|
||||
pub use core::schema;
|
||||
pub use core::schema::Term;
|
||||
|
||||
Reference in New Issue
Block a user