Skip to content

Commit e37a24c

Browse files
authored
[PERF] Use binary search in positional posting list (#2424)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Uses binary search in PPL since entries are ordered, on a dataset of 1107 posting lists with ~450,000 doc ids, the aggregate time spent inserting was taking ~100 seconds. This reduces it to .01 seconds. :) - New functionality - none ## Test plan *How are these changes tested?* - [x] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Documentation Changes None
1 parent 7b3a751 commit e37a24c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rust/worker/src/blockstore/positional_posting_list_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl PositionalPostingList {
2020
}
2121

2222
pub(crate) fn get_positions_for_doc_id(&self, doc_id: i32) -> Option<Int32Array> {
23-
let index = self.doc_ids.iter().position(|x| x == Some(doc_id));
23+
let index = self.doc_ids.values().binary_search(&doc_id).ok();
2424
match index {
2525
Some(index) => {
2626
let target_positions = self.positions.value(index);

0 commit comments

Comments
 (0)