fix scoring of new items

This commit is contained in:
Pascal Kuthe 2023-08-08 17:32:29 +02:00
parent 1756e47f44
commit 9c4b71027f
No known key found for this signature in database
GPG Key ID: D715E8655AE166A6

View File

@ -89,10 +89,9 @@ impl<T: Sync + Send + 'static> Worker<T> {
let Some(item) = self.items.get(idx) else { let Some(item) = self.items.get(idx) else {
return true; return true;
}; };
let Some(score) = pattern.score(item.matcher_columns, matchers.get()) else { if let Some(score) = pattern.score(item.matcher_columns, matchers.get()) {
return false;
};
self.matches.push(Match { score, idx }); self.matches.push(Match { score, idx });
};
false false
}); });
let new_snapshot = self.items.par_snapshot(self.last_snapshot); let new_snapshot = self.items.par_snapshot(self.last_snapshot);
@ -170,8 +169,6 @@ impl<T: Sync + Send + 'static> Worker<T> {
return; return;
} }
let mut unmatched = AtomicU32::new(0);
self.process_new_items(&unmatched);
if pattern_status == pattern::Status::Rescore { if pattern_status == pattern::Status::Rescore {
self.matches.clear(); self.matches.clear();
self.matches self.matches
@ -179,9 +176,11 @@ impl<T: Sync + Send + 'static> Worker<T> {
self.remove_in_flight_matches(); self.remove_in_flight_matches();
} }
let mut unmatched = AtomicU32::new(0);
if pattern_status != pattern::Status::Unchanged && !self.matches.is_empty() {
self.process_new_items_trivial();
let matchers = &self.matchers; let matchers = &self.matchers;
let pattern = &self.pattern; let pattern = &self.pattern;
if pattern_status != pattern::Status::Unchanged && !self.matches.is_empty() {
self.matches self.matches
.par_iter_mut() .par_iter_mut()
.take_any_while(|_| !self.canceled.load(atomic::Ordering::Relaxed)) .take_any_while(|_| !self.canceled.load(atomic::Ordering::Relaxed))
@ -201,6 +200,8 @@ impl<T: Sync + Send + 'static> Worker<T> {
match_.idx = u32::MAX; match_.idx = u32::MAX;
} }
}); });
} else {
self.process_new_items(&unmatched);
} }
let canceled = par_quicksort( let canceled = par_quicksort(