Continue implementation of task deletion

1. Matched tasks are a roaring bitmap
2. Start implementation in meilisearch-http
3. Snapshots use meili-snap
4. Rename to TaskDeletion
This commit is contained in:
Loïc Lecrenier 2022-10-13 11:09:00 +02:00 committed by Clément Renault
parent e4d461ecba
commit 9522b75454
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
27 changed files with 290 additions and 456 deletions

View file

@ -8,10 +8,11 @@ edition = "2021"
actix-web = { version = "4.2.1", default-features = false }
csv = "1.1.6"
either = { version = "1.6.1", features = ["serde"] }
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.33.4", default-features = false }
milli = { git = "https://github.com/meilisearch/milli.git", branch = "indexation-abortion", default-features = false }
enum-iterator = "0.7.0"
proptest = { version = "1.0.0", optional = true }
proptest-derive = { version = "0.3.0", optional = true }
roaring = { version = "0.10.0", features = ["serde"] }
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.85"
time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsing", "macros"] }

View file

@ -224,6 +224,8 @@ pub enum Action {
IndexesDelete,
#[serde(rename = "tasks.*")]
TasksAll,
#[serde(rename = "tasks.*")]
TasksDelete,
#[serde(rename = "tasks.get")]
TasksGet,
#[serde(rename = "settings.*")]
@ -311,6 +313,7 @@ pub mod actions {
pub const INDEXES_UPDATE: u8 = IndexesUpdate.repr();
pub const INDEXES_DELETE: u8 = IndexesDelete.repr();
pub const TASKS_ALL: u8 = TasksAll.repr();
pub const TASKS_DELETE: u8 = TasksDelete.repr();
pub const TASKS_GET: u8 = TasksGet.repr();
pub const SETTINGS_ALL: u8 = SettingsAll.repr();
pub const SETTINGS_GET: u8 = SettingsGet.repr();

View file

@ -1,4 +1,5 @@
use milli::update::IndexDocumentsMethod;
use roaring::RoaringBitmap;
use serde::{Deserialize, Serialize, Serializer};
use std::{
fmt::{Display, Write},
@ -42,7 +43,7 @@ impl Task {
DumpExport { .. }
| Snapshot
| CancelTask { .. }
| DeleteTasks { .. }
| TaskDeletion { .. }
| IndexSwap { .. } => None,
DocumentImport { index_uid, .. }
| DocumentDeletion { index_uid, .. }
@ -59,7 +60,7 @@ impl Task {
use KindWithContent::*;
match &self.kind {
DumpExport { .. } | Snapshot | CancelTask { .. } | DeleteTasks { .. } => None,
DumpExport { .. } | Snapshot | CancelTask { .. } | TaskDeletion { .. } => None,
DocumentImport { index_uid, .. }
| DocumentDeletion { index_uid, .. }
| DocumentClear { index_uid }
@ -114,9 +115,9 @@ pub enum KindWithContent {
CancelTask {
tasks: Vec<TaskId>,
},
DeleteTasks {
TaskDeletion {
query: String,
tasks: Vec<TaskId>,
tasks: RoaringBitmap,
},
DumpExport {
output: PathBuf,
@ -136,7 +137,7 @@ impl KindWithContent {
KindWithContent::IndexUpdate { .. } => Kind::IndexUpdate,
KindWithContent::IndexSwap { .. } => Kind::IndexSwap,
KindWithContent::CancelTask { .. } => Kind::CancelTask,
KindWithContent::DeleteTasks { .. } => Kind::DeleteTasks,
KindWithContent::TaskDeletion { .. } => Kind::TaskDeletion,
KindWithContent::DumpExport { .. } => Kind::DumpExport,
KindWithContent::Snapshot => Kind::Snapshot,
}
@ -146,7 +147,7 @@ impl KindWithContent {
use KindWithContent::*;
match self {
DumpExport { .. } | Snapshot | CancelTask { .. } | DeleteTasks { .. } => None,
DumpExport { .. } | Snapshot | CancelTask { .. } | TaskDeletion { .. } => None,
DocumentImport { index_uid, .. }
| DocumentDeletion { index_uid, .. }
| DocumentClear { index_uid }
@ -192,8 +193,8 @@ impl KindWithContent {
KindWithContent::CancelTask { .. } => {
None // TODO: check correctness of this return value
}
KindWithContent::DeleteTasks { query, tasks } => Some(Details::DeleteTasks {
matched_tasks: tasks.len(),
KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion {
matched_tasks: tasks.len() as usize,
deleted_tasks: None,
original_query: query.clone(),
}),
@ -203,7 +204,7 @@ impl KindWithContent {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Status {
Enqueued,
@ -240,7 +241,7 @@ impl FromStr for Status {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Kind {
DocumentImport,
@ -252,7 +253,7 @@ pub enum Kind {
IndexUpdate,
IndexSwap,
CancelTask,
DeleteTasks,
TaskDeletion,
DumpExport,
Snapshot,
}
@ -272,7 +273,7 @@ impl FromStr for Kind {
"index_update" => Ok(Kind::IndexUpdate),
"index_swap" => Ok(Kind::IndexSwap),
"cancel_task" => Ok(Kind::CancelTask),
"delete_tasks" => Ok(Kind::DeleteTasks),
"task_deletion" => Ok(Kind::TaskDeletion),
"dump_export" => Ok(Kind::DumpExport),
"snapshot" => Ok(Kind::Snapshot),
s => Err(ResponseError::from_msg(
@ -304,7 +305,7 @@ pub enum Details {
ClearAll {
deleted_documents: Option<u64>,
},
DeleteTasks {
TaskDeletion {
matched_tasks: usize,
deleted_tasks: Option<usize>,
original_query: String,
@ -373,7 +374,7 @@ mod tests {
#[test]
fn bad_deser() {
let details = Details::DeleteTasks {
let details = Details::TaskDeletion {
matched_tasks: 1,
deleted_tasks: None,
original_query: "hello".to_owned(),