write most of the run loop

This commit is contained in:
Tamo 2022-09-16 01:58:08 +02:00 committed by Clément Renault
parent 4846a7c501
commit 1ea9c0b4c0
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
3 changed files with 80 additions and 35 deletions

View file

@ -1,7 +1,7 @@
use crate::{
autobatcher::BatchKind,
task::{Kind, KindWithContent, Status, Task},
Error, IndexScheduler, Result,
Error, IndexScheduler, Result, TaskId,
};
use index::{Settings, Unchecked};
use milli::{
@ -33,6 +33,26 @@ pub(crate) enum Batch {
},
}
impl Batch {
pub fn ids(&self) -> Vec<TaskId> {
match self {
Batch::Cancel(task) => vec![task.uid],
Batch::Snapshot(tasks) | Batch::Dump(tasks) | Batch::DocumentAddition { tasks, .. } => {
tasks.iter().map(|task| task.uid).collect()
}
Batch::SettingsAndDocumentAddition {
document_addition_tasks,
settings_tasks,
..
} => document_addition_tasks
.iter()
.chain(settings_tasks)
.map(|task| task.uid)
.collect(),
}
}
}
impl IndexScheduler {
pub(crate) fn create_next_batch_index(
&self,