mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
Debug attribute criterion
* debug folding when initializing iterators
This commit is contained in:
parent
1eee0029a8
commit
b3e2280bb9
@ -51,7 +51,7 @@ impl<'t> Criterion for Attribute<'t> {
|
|||||||
flatten_query_tree(&qt)
|
flatten_query_tree(&qt)
|
||||||
});
|
});
|
||||||
|
|
||||||
let found_candidates = if candidates.len() < 1000 {
|
let found_candidates = if candidates.len() < 1_000 {
|
||||||
let current_buckets = match self.current_buckets.as_mut() {
|
let current_buckets = match self.current_buckets.as_mut() {
|
||||||
Some(current_buckets) => current_buckets,
|
Some(current_buckets) => current_buckets,
|
||||||
None => {
|
None => {
|
||||||
@ -322,10 +322,10 @@ struct Branch<'t, 'q> {
|
|||||||
|
|
||||||
impl<'t, 'q> Branch<'t, 'q> {
|
impl<'t, 'q> Branch<'t, 'q> {
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
fn compute_rank(left: u32, branch_size: u32) -> u32 { left.saturating_sub((1..branch_size).sum()) / branch_size }
|
fn compute_rank(left: u32, branch_size: u32) -> u32 { left.saturating_sub((0..branch_size).sum()) / branch_size }
|
||||||
match (&self.last_result, &other.last_result) {
|
match (&self.last_result, &other.last_result) {
|
||||||
(Some((s_left, _, _)), Some((o_left, _, _))) => {
|
(Some((s_left, _, _)), Some((o_left, _, _))) => {
|
||||||
// we compute a rank form the left interval.
|
// we compute a rank from the left interval.
|
||||||
let self_rank = compute_rank(*s_left, self.branch_size);
|
let self_rank = compute_rank(*s_left, self.branch_size);
|
||||||
let other_rank = compute_rank(*o_left, other.branch_size);
|
let other_rank = compute_rank(*o_left, other.branch_size);
|
||||||
let left_cmp = self_rank.cmp(&other_rank).reverse();
|
let left_cmp = self_rank.cmp(&other_rank).reverse();
|
||||||
@ -371,8 +371,8 @@ fn initialize_query_level_iterators<'t, 'q>(
|
|||||||
let mut positions = BinaryHeap::with_capacity(branches.len());
|
let mut positions = BinaryHeap::with_capacity(branches.len());
|
||||||
for branch in branches {
|
for branch in branches {
|
||||||
let mut branch_positions = Vec::with_capacity(branch.len());
|
let mut branch_positions = Vec::with_capacity(branch.len());
|
||||||
for query in branch {
|
for queries in branch {
|
||||||
match QueryLevelIterator::new(ctx, query, wdcache)? {
|
match QueryLevelIterator::new(ctx, queries, wdcache)? {
|
||||||
Some(qli) => branch_positions.push(qli),
|
Some(qli) => branch_positions.push(qli),
|
||||||
None => {
|
None => {
|
||||||
// the branch seems to be invalid, so we skip it.
|
// the branch seems to be invalid, so we skip it.
|
||||||
@ -386,10 +386,10 @@ fn initialize_query_level_iterators<'t, 'q>(
|
|||||||
let folded_query_level_iterators = branch_positions
|
let folded_query_level_iterators = branch_positions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.rev()
|
.rev()
|
||||||
.fold(None, |fold: Option<QueryLevelIterator>, qli| match fold {
|
.fold(None, |fold: Option<QueryLevelIterator>, mut qli| match fold {
|
||||||
Some(mut fold) => {
|
Some(fold) => {
|
||||||
fold.previous(qli);
|
qli.previous(fold);
|
||||||
Some(fold)
|
Some(qli)
|
||||||
},
|
},
|
||||||
None => Some(qli),
|
None => Some(qli),
|
||||||
});
|
});
|
||||||
@ -418,6 +418,7 @@ fn set_compute_candidates<'t>(
|
|||||||
{
|
{
|
||||||
let mut branches_heap = initialize_query_level_iterators(ctx, branches, wdcache)?;
|
let mut branches_heap = initialize_query_level_iterators(ctx, branches, wdcache)?;
|
||||||
let lowest_level = TreeLevel::min_value();
|
let lowest_level = TreeLevel::min_value();
|
||||||
|
let mut final_candidates = RoaringBitmap::new();
|
||||||
|
|
||||||
while let Some(mut branch) = branches_heap.peek_mut() {
|
while let Some(mut branch) = branches_heap.peek_mut() {
|
||||||
let is_lowest_level = branch.tree_level == lowest_level;
|
let is_lowest_level = branch.tree_level == lowest_level;
|
||||||
@ -426,7 +427,8 @@ fn set_compute_candidates<'t>(
|
|||||||
candidates.intersect_with(&allowed_candidates);
|
candidates.intersect_with(&allowed_candidates);
|
||||||
if candidates.len() > 0 && is_lowest_level {
|
if candidates.len() > 0 && is_lowest_level {
|
||||||
// we have candidates, but we can't dig deeper, return candidates.
|
// we have candidates, but we can't dig deeper, return candidates.
|
||||||
return Ok(std::mem::take(candidates));
|
final_candidates = std::mem::take(candidates);
|
||||||
|
break;
|
||||||
} else if candidates.len() > 0 {
|
} else if candidates.len() > 0 {
|
||||||
// we have candidates, lets dig deeper in levels.
|
// we have candidates, lets dig deeper in levels.
|
||||||
let mut query_level_iterator = branch.query_level_iterator.dig(ctx)?;
|
let mut query_level_iterator = branch.query_level_iterator.dig(ctx)?;
|
||||||
@ -441,12 +443,12 @@ fn set_compute_candidates<'t>(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// None = no candidates to find.
|
// None = no candidates to find.
|
||||||
None => return Ok(RoaringBitmap::new()),
|
None => break,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we made all iterations without finding anything.
|
Ok(final_candidates)
|
||||||
Ok(RoaringBitmap::new())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn linear_compute_candidates(
|
fn linear_compute_candidates(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user