Skip to content

Commit

Permalink
Fix initial threashold for k!=10,100,1000
Browse files Browse the repository at this point in the history
  • Loading branch information
amallia committed Oct 24, 2024
1 parent f11f64d commit 5e364b0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/index/posting_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ impl PostingList {
kth_score,
}
}
const fn map_kth_value(value: usize) -> usize {
const fn map_kth_value(value: usize) -> Option<usize> {
match value {
10 => 0,
100 => 1,
1000 => 2,
_ => value, // default case
10 => Some(0),
100 => Some(1),
1000 => Some(2),
_ => None, // default case
}
}

pub fn kth(&self, k: usize) -> u8 {
return self.kth_score[Self::map_kth_value(k)];
if let Some(v) = Self::map_kth_value(k) {
return self.kth_score[v];
}
0
}

pub fn iter(&self, term_id: u32, term_weight: u32) -> PostingListIterator<'_> {
Expand Down

0 comments on commit 5e364b0

Please sign in to comment.