Check cancel in multithreaded fuzzy matching (#22525)

For both the strings and paths multithreaded matching it would still
aggregate the response even though it is unneeded. It now checks cancel.

In the paths matcher, cancel is now checked within the loop, since it
was calling `match_candidates` even though no further results would be
computed.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2024-12-31 15:37:41 -07:00 committed by GitHub
parent 6ef5d8f748
commit 51ac2d3667
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 2 deletions

View file

@ -8,7 +8,7 @@ use std::{
cmp::{self, Ordering},
iter,
ops::Range,
sync::atomic::AtomicBool,
sync::atomic::{self, AtomicBool},
};
#[derive(Clone, Debug)]
@ -178,6 +178,10 @@ pub async fn match_strings(
})
.await;
if cancel_flag.load(atomic::Ordering::Relaxed) {
return Vec::new();
}
let mut results = segment_results.concat();
util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results