mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 09:04:59 +08:00
Prefer summing the attribute
This commit is contained in:
parent
86ee0cbd6e
commit
d75339a271
@ -1,4 +1,4 @@
|
|||||||
use std::cmp::{self, Ordering};
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use compact_arena::SmallArena;
|
use compact_arena::SmallArena;
|
||||||
use slice_group_by::GroupBy;
|
use slice_group_by::GroupBy;
|
||||||
@ -32,16 +32,16 @@ impl Criterion for Attribute {
|
|||||||
) -> Ordering
|
) -> Ordering
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn best_attribute(matches: &[SimpleMatch]) -> u16 {
|
fn sum_of_attribute(matches: &[SimpleMatch]) -> usize {
|
||||||
let mut best_attribute = u16::max_value();
|
let mut sum_of_attribute = 0;
|
||||||
for group in matches.linear_group_by_key(|bm| bm.query_index) {
|
for group in matches.linear_group_by_key(|bm| bm.query_index) {
|
||||||
best_attribute = cmp::min(best_attribute, group[0].attribute);
|
sum_of_attribute += group[0].attribute as usize;
|
||||||
}
|
}
|
||||||
best_attribute
|
sum_of_attribute
|
||||||
}
|
}
|
||||||
|
|
||||||
let lhs = best_attribute(&lhs.processed_matches);
|
let lhs = sum_of_attribute(&lhs.processed_matches);
|
||||||
let rhs = best_attribute(&rhs.processed_matches);
|
let rhs = sum_of_attribute(&rhs.processed_matches);
|
||||||
|
|
||||||
lhs.cmp(&rhs)
|
lhs.cmp(&rhs)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user