managed for small batch size edge case in semantic search

This commit is contained in:
KCaverly 2023-07-26 16:56:41 -04:00
parent 89bbcdfa4f
commit 5c48729c7c

View file

@ -721,7 +721,12 @@ impl SemanticIndex {
)?; )?;
let batch_n = cx.background().num_cpus(); let batch_n = cx.background().num_cpus();
let batch_size = file_ids.clone().len() / batch_n; let ids_len = file_ids.clone().len();
let batch_size = if ids_len <= batch_n {
ids_len
} else {
ids_len / batch_n
};
let mut result_tasks = Vec::new(); let mut result_tasks = Vec::new();
for batch in file_ids.chunks(batch_size) { for batch in file_ids.chunks(batch_size) {