From 9e8242c57d3748037527f14d1767687eb671da8d Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Mon, 3 Oct 2022 16:33:50 +0200 Subject: [PATCH] Remove the IndexRename operation --- index-scheduler/src/autobatcher.rs | 18 +++--------------- index-scheduler/src/batch.rs | 1 - index-scheduler/src/task.rs | 15 +-------------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/index-scheduler/src/autobatcher.rs b/index-scheduler/src/autobatcher.rs index aedf31559..d2f71d4ce 100644 --- a/index-scheduler/src/autobatcher.rs +++ b/index-scheduler/src/autobatcher.rs @@ -36,9 +36,6 @@ pub enum BatchKind { IndexUpdate { id: TaskId, }, - IndexRename { - id: TaskId, - }, IndexSwap { id: TaskId, }, @@ -51,7 +48,6 @@ impl BatchKind { Kind::IndexCreation => (BatchKind::IndexCreation { id: task_id }, true), Kind::IndexDeletion => (BatchKind::IndexDeletion { ids: vec![task_id] }, true), Kind::IndexUpdate => (BatchKind::IndexUpdate { id: task_id }, true), - Kind::IndexRename => (BatchKind::IndexRename { id: task_id }, true), Kind::IndexSwap => (BatchKind::IndexSwap { id: task_id }, true), Kind::DocumentClear => (BatchKind::DocumentClear { ids: vec![task_id] }, false), Kind::DocumentAddition => ( @@ -89,10 +85,9 @@ impl BatchKind { fn accumulate(self, id: TaskId, kind: Kind) -> ControlFlow { match (self, kind) { // We don't batch any of these operations - ( - this, - Kind::IndexCreation | Kind::IndexRename | Kind::IndexUpdate | Kind::IndexSwap, - ) => ControlFlow::Break(this), + (this, Kind::IndexCreation | Kind::IndexUpdate | Kind::IndexSwap) => { + ControlFlow::Break(this) + } // The index deletion can batch with everything but must stop after ( BatchKind::DocumentClear { mut ids } @@ -335,7 +330,6 @@ impl BatchKind { BatchKind::IndexCreation { .. } | BatchKind::IndexDeletion { .. } | BatchKind::IndexUpdate { .. } - | BatchKind::IndexRename { .. } | BatchKind::IndexSwap { .. }, _, ) => { @@ -414,10 +408,6 @@ mod tests { assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, IndexUpdate]), @"Some(DocumentImport { method: UpdateDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentDeletion, IndexUpdate]), @"Some(DocumentDeletion { deletion_ids: [0] })"); - assert_smol_debug_snapshot!(autobatch_from([DocumentAddition, IndexRename]), @"Some(DocumentImport { method: ReplaceDocuments, import_ids: [0] })"); - assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, IndexRename]), @"Some(DocumentImport { method: UpdateDocuments, import_ids: [0] })"); - assert_smol_debug_snapshot!(autobatch_from([DocumentDeletion, IndexRename]), @"Some(DocumentDeletion { deletion_ids: [0] })"); - assert_smol_debug_snapshot!(autobatch_from([DocumentAddition, IndexSwap]), @"Some(DocumentImport { method: ReplaceDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, IndexSwap]), @"Some(DocumentImport { method: UpdateDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentDeletion, IndexSwap]), @"Some(DocumentDeletion { deletion_ids: [0] })"); @@ -446,8 +436,6 @@ mod tests { assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, Settings, IndexCreation]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: UpdateDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentAddition, Settings, IndexUpdate]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: ReplaceDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, Settings, IndexUpdate]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: UpdateDocuments, import_ids: [0] })"); - assert_smol_debug_snapshot!(autobatch_from([DocumentAddition, Settings, IndexRename]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: ReplaceDocuments, import_ids: [0] })"); - assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, Settings, IndexRename]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: UpdateDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentAddition, Settings, IndexSwap]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: ReplaceDocuments, import_ids: [0] })"); assert_smol_debug_snapshot!(autobatch_from([DocumentUpdate, Settings, IndexSwap]), @"Some(SettingsAndDocumentImport { settings_ids: [1], method: UpdateDocuments, import_ids: [0] })"); } diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index 58c48f2ec..473919857 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -304,7 +304,6 @@ impl IndexScheduler { tasks: self.get_existing_tasks(rtxn, ids)?, })), BatchKind::IndexSwap { id: _ } => todo!(), - BatchKind::IndexRename { id: _ } => todo!(), } } diff --git a/index-scheduler/src/task.rs b/index-scheduler/src/task.rs index 6552c2ce0..28432b7e2 100644 --- a/index-scheduler/src/task.rs +++ b/index-scheduler/src/task.rs @@ -158,10 +158,6 @@ pub enum KindWithContent { index_uid: String, primary_key: Option, }, - IndexRename { - index_uid: String, - new_name: String, - }, IndexSwap { lhs: String, rhs: String, @@ -193,7 +189,6 @@ impl KindWithContent { KindWithContent::IndexCreation { .. } => Kind::IndexCreation, KindWithContent::IndexDeletion { .. } => Kind::IndexDeletion, KindWithContent::IndexUpdate { .. } => Kind::IndexUpdate, - KindWithContent::IndexRename { .. } => Kind::IndexRename, KindWithContent::IndexSwap { .. } => Kind::IndexSwap, KindWithContent::CancelTask { .. } => Kind::CancelTask, KindWithContent::DumpExport { .. } => Kind::DumpExport, @@ -216,7 +211,6 @@ impl KindWithContent { | IndexCreation { .. } | IndexDeletion { .. } | IndexUpdate { .. } - | IndexRename { .. } | IndexSwap { .. } | CancelTask { .. } | DumpExport { .. } @@ -239,7 +233,6 @@ impl KindWithContent { | Settings { .. } | IndexDeletion { .. } | IndexUpdate { .. } - | IndexRename { .. } | IndexSwap { .. } | CancelTask { .. } | DumpExport { .. } @@ -259,11 +252,7 @@ impl KindWithContent { | IndexCreation { index_uid, .. } | IndexUpdate { index_uid, .. } | IndexDeletion { index_uid } => Some(vec![index_uid]), - IndexRename { - index_uid: lhs, - new_name: rhs, - } - | IndexSwap { lhs, rhs } => Some(vec![lhs, rhs]), + IndexSwap { lhs, rhs } => Some(vec![lhs, rhs]), } } } @@ -279,7 +268,6 @@ pub enum Kind { IndexCreation, IndexDeletion, IndexUpdate, - IndexRename, IndexSwap, CancelTask, DumpExport, @@ -299,7 +287,6 @@ impl FromStr for Kind { "index_creation" => Ok(Kind::IndexCreation), "index_deletion" => Ok(Kind::IndexDeletion), "index_update" => Ok(Kind::IndexUpdate), - "index_rename" => Ok(Kind::IndexRename), "index_swap" => Ok(Kind::IndexSwap), "cancel_task" => Ok(Kind::CancelTask), "dump_export" => Ok(Kind::DumpExport),