mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 00:34:26 +01:00
create the end Batch type for all Index* operations
This commit is contained in:
parent
925971809a
commit
e547552702
@ -69,19 +69,36 @@ pub(crate) enum Batch {
|
|||||||
settings: Vec<(bool, Settings<Unchecked>)>,
|
settings: Vec<(bool, Settings<Unchecked>)>,
|
||||||
settings_tasks: Vec<Task>,
|
settings_tasks: Vec<Task>,
|
||||||
},
|
},
|
||||||
|
IndexCreation {
|
||||||
|
index_uid: String,
|
||||||
|
primary_key: Option<String>,
|
||||||
|
task: Task,
|
||||||
|
},
|
||||||
|
IndexUpdate {
|
||||||
|
index_uid: String,
|
||||||
|
primary_key: Option<String>,
|
||||||
|
task: Task,
|
||||||
|
},
|
||||||
|
IndexDeletion {
|
||||||
|
index_uid: String,
|
||||||
|
tasks: Vec<Task>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Batch {
|
impl Batch {
|
||||||
pub fn ids(&self) -> Vec<TaskId> {
|
pub fn ids(&self) -> Vec<TaskId> {
|
||||||
match self {
|
match self {
|
||||||
Batch::Cancel(task) => vec![task.uid],
|
Batch::Cancel(task)
|
||||||
|
| Batch::IndexCreation { task, .. }
|
||||||
|
| Batch::IndexUpdate { task, .. } => vec![task.uid],
|
||||||
Batch::Snapshot(tasks)
|
Batch::Snapshot(tasks)
|
||||||
| Batch::Dump(tasks)
|
| Batch::Dump(tasks)
|
||||||
| Batch::DocumentAddition { tasks, .. }
|
| Batch::DocumentAddition { tasks, .. }
|
||||||
| Batch::DocumentUpdate { tasks, .. }
|
| Batch::DocumentUpdate { tasks, .. }
|
||||||
| Batch::DocumentDeletion { tasks, .. }
|
| Batch::DocumentDeletion { tasks, .. }
|
||||||
| Batch::Settings { tasks, .. }
|
| Batch::Settings { tasks, .. }
|
||||||
| Batch::DocumentClear { tasks, .. } => tasks.iter().map(|task| task.uid).collect(),
|
| Batch::DocumentClear { tasks, .. }
|
||||||
|
| Batch::IndexDeletion { tasks, .. } => tasks.iter().map(|task| task.uid).collect(),
|
||||||
Batch::SettingsAndDocumentAddition {
|
Batch::SettingsAndDocumentAddition {
|
||||||
document_addition_tasks: tasks,
|
document_addition_tasks: tasks,
|
||||||
settings_tasks: other,
|
settings_tasks: other,
|
||||||
@ -311,9 +328,37 @@ impl IndexScheduler {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BatchKind::IndexCreation { id: _ } => todo!(),
|
BatchKind::IndexCreation { id } => {
|
||||||
BatchKind::IndexDeletion { ids: _ } => todo!(),
|
let task = self.get_task(rtxn, id)?.ok_or(Error::CorruptedTaskQueue)?;
|
||||||
BatchKind::IndexUpdate { id: _ } => todo!(),
|
let (index_uid, primary_key) = match &task.kind {
|
||||||
|
KindWithContent::IndexCreation {
|
||||||
|
index_uid,
|
||||||
|
primary_key,
|
||||||
|
} => (index_uid.clone(), primary_key.clone()),
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
Ok(Some(Batch::IndexCreation {
|
||||||
|
index_uid,
|
||||||
|
primary_key,
|
||||||
|
task,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
BatchKind::IndexUpdate { id } => {
|
||||||
|
let task = self.get_task(rtxn, id)?.ok_or(Error::CorruptedTaskQueue)?;
|
||||||
|
let primary_key = match &task.kind {
|
||||||
|
KindWithContent::IndexUpdate { primary_key, .. } => primary_key.clone(),
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
Ok(Some(Batch::IndexUpdate {
|
||||||
|
index_uid,
|
||||||
|
primary_key,
|
||||||
|
task,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
BatchKind::IndexDeletion { ids } => Ok(Some(Batch::IndexDeletion {
|
||||||
|
index_uid,
|
||||||
|
tasks: self.get_existing_tasks(rtxn, ids)?,
|
||||||
|
})),
|
||||||
BatchKind::IndexSwap { id: _ } => todo!(),
|
BatchKind::IndexSwap { id: _ } => todo!(),
|
||||||
BatchKind::IndexRename { id: _ } => todo!(),
|
BatchKind::IndexRename { id: _ } => todo!(),
|
||||||
}
|
}
|
||||||
@ -471,6 +516,17 @@ impl IndexScheduler {
|
|||||||
settings,
|
settings,
|
||||||
settings_tasks,
|
settings_tasks,
|
||||||
} => todo!(),
|
} => todo!(),
|
||||||
|
Batch::IndexCreation {
|
||||||
|
index_uid,
|
||||||
|
primary_key,
|
||||||
|
task,
|
||||||
|
} => todo!(),
|
||||||
|
Batch::IndexUpdate {
|
||||||
|
index_uid,
|
||||||
|
primary_key,
|
||||||
|
task,
|
||||||
|
} => todo!(),
|
||||||
|
Batch::IndexDeletion { index_uid, tasks } => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user