Fix group offset computing

This commit is contained in:
Clément Renault 2019-12-31 13:07:05 +01:00
parent 670e80c151
commit 856c5c4214

View File

@ -548,15 +548,16 @@ fn fetch_matches<'txn, 'tag>(
for group in postings_list_view.linear_group_by_key(|di| di.document_id) { for group in postings_list_view.linear_group_by_key(|di| di.document_id) {
let document_id = group[0].document_id; let document_id = group[0].document_id;
if query_index != 0 { if query_index != 0 && !documents_ids.contains(&document_id) {
if !documents_ids.contains(&document_id) { continue } offset += group.len();
} else { continue
documents_ids.insert(document_id);
} }
documents_ids.insert(document_id);
postings_lists_length += group.len(); postings_lists_length += group.len();
let posting_list_index = arena.add(postings_list_view.range(offset, group.len())); let range = postings_list_view.range(offset, group.len());
let posting_list_index = arena.add(range);
let bare_match = BareMatch { let bare_match = BareMatch {
document_id, document_id,
query_index: query_index as u16, query_index: query_index as u16,
@ -565,6 +566,7 @@ fn fetch_matches<'txn, 'tag>(
postings_list: posting_list_index, postings_list: posting_list_index,
}; };
total_postings_lists.push(bare_match); total_postings_lists.push(bare_match);
offset += group.len(); offset += group.len();
} }
@ -611,15 +613,16 @@ fn fetch_matches<'txn, 'tag>(
for group in postings_list_view.linear_group_by_key(|di| di.document_id) { for group in postings_list_view.linear_group_by_key(|di| di.document_id) {
let document_id = group[0].document_id; let document_id = group[0].document_id;
if query_index != 0 { if query_index != 0 && !documents_ids.contains(&document_id) {
if !documents_ids.contains(&document_id) { continue } offset += group.len();
} else { continue
documents_ids.insert(document_id);
} }
documents_ids.insert(document_id);
postings_lists_length += group.len(); postings_lists_length += group.len();
let posting_list_index = arena.add(postings_list_view.range(offset, group.len())); let range = postings_list_view.range(offset, group.len());
let posting_list_index = arena.add(range);
let bare_match = BareMatch { let bare_match = BareMatch {
document_id, document_id,
query_index: query_index as u16, query_index: query_index as u16,