diff --git a/crates/dump/src/lib.rs b/crates/dump/src/lib.rs index c33f02422..5f2b63fae 100644 --- a/crates/dump/src/lib.rs +++ b/crates/dump/src/lib.rs @@ -158,7 +158,7 @@ pub enum KindDump { UpgradeDatabase { from: (u32, u32, u32), }, - CompactIndex { + IndexCompaction { index_uid: String, }, } @@ -243,7 +243,9 @@ impl From for KindDump { KindWithContent::UpgradeDatabase { from: version } => { KindDump::UpgradeDatabase { from: version } } - KindWithContent::CompactIndex { index_uid } => KindDump::CompactIndex { index_uid }, + KindWithContent::IndexCompaction { index_uid } => { + KindDump::IndexCompaction { index_uid } + } } } } diff --git a/crates/index-scheduler/src/dump.rs b/crates/index-scheduler/src/dump.rs index b44e62bc9..7cc4b37a2 100644 --- a/crates/index-scheduler/src/dump.rs +++ b/crates/index-scheduler/src/dump.rs @@ -234,7 +234,9 @@ impl<'a> Dump<'a> { } } KindDump::UpgradeDatabase { from } => KindWithContent::UpgradeDatabase { from }, - KindDump::CompactIndex { index_uid } => KindWithContent::CompactIndex { index_uid }, + KindDump::IndexCompaction { index_uid } => { + KindWithContent::IndexCompaction { index_uid } + } }, }; diff --git a/crates/index-scheduler/src/insta_snapshot.rs b/crates/index-scheduler/src/insta_snapshot.rs index d564d8ca8..d44a386be 100644 --- a/crates/index-scheduler/src/insta_snapshot.rs +++ b/crates/index-scheduler/src/insta_snapshot.rs @@ -317,7 +317,7 @@ fn snapshot_details(d: &Details) -> String { Details::UpgradeDatabase { from, to } => { format!("{{ from: {from:?}, to: {to:?} }}") } - Details::CompactIndex { index_uid, pre_compaction_size, post_compaction_size } => { + Details::IndexCompaction { index_uid, pre_compaction_size, post_compaction_size } => { format!("{{ index_uid: {index_uid:?}, pre_compaction_size: {pre_compaction_size:?}, post_compaction_size: {post_compaction_size:?} }}") } } diff --git a/crates/index-scheduler/src/scheduler/autobatcher.rs b/crates/index-scheduler/src/scheduler/autobatcher.rs index ad3ae24e8..94f3e64fc 100644 --- a/crates/index-scheduler/src/scheduler/autobatcher.rs +++ b/crates/index-scheduler/src/scheduler/autobatcher.rs @@ -25,7 +25,7 @@ enum AutobatchKind { IndexDeletion, IndexUpdate, IndexSwap, - CompactIndex, + IndexCompaction, } impl AutobatchKind { @@ -69,7 +69,7 @@ impl From for AutobatchKind { KindWithContent::IndexCreation { .. } => AutobatchKind::IndexCreation, KindWithContent::IndexUpdate { .. } => AutobatchKind::IndexUpdate, KindWithContent::IndexSwap { .. } => AutobatchKind::IndexSwap, - KindWithContent::CompactIndex { .. } => AutobatchKind::CompactIndex, + KindWithContent::IndexCompaction { .. } => AutobatchKind::IndexCompaction, KindWithContent::TaskCancelation { .. } | KindWithContent::TaskDeletion { .. } | KindWithContent::DumpCreation { .. } @@ -120,7 +120,7 @@ pub enum BatchKind { IndexSwap { id: TaskId, }, - CompactIndex { + IndexCompaction { id: TaskId, }, } @@ -188,9 +188,9 @@ impl BatchKind { )), false, ), - K::CompactIndex => ( + K::IndexCompaction => ( Break(( - BatchKind::CompactIndex { id: task_id }, + BatchKind::IndexCompaction { id: task_id }, BatchStopReason::TaskCannotBeBatched { kind, id: task_id }, )), false, @@ -300,7 +300,7 @@ impl BatchKind { match (self, autobatch_kind) { // We don't batch any of these operations - (this, K::IndexCreation | K::IndexUpdate | K::IndexSwap | K::DocumentEdition | K::CompactIndex) => { + (this, K::IndexCreation | K::IndexUpdate | K::IndexSwap | K::DocumentEdition | K::IndexCompaction) => { Break((this, BatchStopReason::TaskCannotBeBatched { kind, id })) }, // We must not batch tasks that don't have the same index creation rights if the index doesn't already exists. @@ -497,7 +497,7 @@ impl BatchKind { | BatchKind::IndexDeletion { .. } | BatchKind::IndexUpdate { .. } | BatchKind::IndexSwap { .. } - | BatchKind::CompactIndex { .. } + | BatchKind::IndexCompaction { .. } | BatchKind::DocumentEdition { .. }, _, ) => { diff --git a/crates/index-scheduler/src/scheduler/create_batch.rs b/crates/index-scheduler/src/scheduler/create_batch.rs index ecfb2c779..06d796548 100644 --- a/crates/index-scheduler/src/scheduler/create_batch.rs +++ b/crates/index-scheduler/src/scheduler/create_batch.rs @@ -55,7 +55,7 @@ pub(crate) enum Batch { UpgradeDatabase { tasks: Vec, }, - CompactIndex { + IndexCompaction { index_uid: String, task: Task, }, @@ -115,7 +115,7 @@ impl Batch { | Batch::IndexCreation { task, .. } | Batch::Export { task } | Batch::IndexUpdate { task, .. } - | Batch::CompactIndex { task, .. } => { + | Batch::IndexCompaction { task, .. } => { RoaringBitmap::from_sorted_iter(std::iter::once(task.uid)).unwrap() } Batch::SnapshotCreation(tasks) @@ -161,7 +161,7 @@ impl Batch { IndexCreation { index_uid, .. } | IndexUpdate { index_uid, .. } | IndexDeletion { index_uid, .. } - | CompactIndex { index_uid, .. } => Some(index_uid), + | IndexCompaction { index_uid, .. } => Some(index_uid), } } } @@ -181,7 +181,7 @@ impl fmt::Display for Batch { Batch::IndexUpdate { .. } => f.write_str("IndexUpdate")?, Batch::IndexDeletion { .. } => f.write_str("IndexDeletion")?, Batch::IndexSwap { .. } => f.write_str("IndexSwap")?, - Batch::CompactIndex { .. } => f.write_str("CompactIndex")?, + Batch::IndexCompaction { .. } => f.write_str("IndexCompaction")?, Batch::Export { .. } => f.write_str("Export")?, Batch::UpgradeDatabase { .. } => f.write_str("UpgradeDatabase")?, }; @@ -437,11 +437,11 @@ impl IndexScheduler { current_batch.processing(Some(&mut task)); Ok(Some(Batch::IndexSwap { task })) } - BatchKind::CompactIndex { id } => { + BatchKind::IndexCompaction { id } => { let mut task = self.queue.tasks.get_task(rtxn, id)?.ok_or(Error::CorruptedTaskQueue)?; current_batch.processing(Some(&mut task)); - Ok(Some(Batch::CompactIndex { index_uid, task })) + Ok(Some(Batch::IndexCompaction { index_uid, task })) } } } diff --git a/crates/index-scheduler/src/scheduler/process_batch.rs b/crates/index-scheduler/src/scheduler/process_batch.rs index b306d2bd4..b76fa250c 100644 --- a/crates/index-scheduler/src/scheduler/process_batch.rs +++ b/crates/index-scheduler/src/scheduler/process_batch.rs @@ -418,8 +418,8 @@ impl IndexScheduler { task.status = Status::Succeeded; Ok((vec![task], ProcessBatchInfo::default())) } - Batch::CompactIndex { index_uid, mut task } => { - todo!("Implement compact index") + Batch::IndexCompaction { index_uid, mut task } => { + todo!("Implement index compaction") } Batch::Export { mut task } => { let KindWithContent::Export { url, api_key, payload_size, indexes } = &task.kind diff --git a/crates/index-scheduler/src/utils.rs b/crates/index-scheduler/src/utils.rs index 3dc74d0a3..776e50548 100644 --- a/crates/index-scheduler/src/utils.rs +++ b/crates/index-scheduler/src/utils.rs @@ -264,7 +264,7 @@ pub fn swap_index_uid_in_task(task: &mut Task, swap: (&str, &str)) { | K::SettingsUpdate { index_uid, .. } | K::IndexDeletion { index_uid } | K::IndexCreation { index_uid, .. } - | K::CompactIndex { index_uid, .. } => index_uids.push(index_uid), + | K::IndexCompaction { index_uid, .. } => index_uids.push(index_uid), K::IndexUpdate { index_uid, new_index_uid, .. } => { index_uids.push(index_uid); if let Some(new_uid) = new_index_uid { @@ -619,12 +619,12 @@ impl crate::IndexScheduler { Details::UpgradeDatabase { from: _, to: _ } => { assert_eq!(kind.as_kind(), Kind::UpgradeDatabase); } - Details::CompactIndex { + Details::IndexCompaction { index_uid: _, pre_compaction_size: _, post_compaction_size: _, } => { - assert_eq!(kind.as_kind(), Kind::CompactIndex); + assert_eq!(kind.as_kind(), Kind::IndexCompaction); } } } diff --git a/crates/meilisearch-types/src/task_view.rs b/crates/meilisearch-types/src/task_view.rs index ea6dc4988..b856989c1 100644 --- a/crates/meilisearch-types/src/task_view.rs +++ b/crates/meilisearch-types/src/task_view.rs @@ -438,7 +438,7 @@ impl From
for DetailsView { upgrade_to: Some(format!("v{}.{}.{}", to.0, to.1, to.2)), ..Default::default() }, - Details::CompactIndex { pre_compaction_size, post_compaction_size, .. } => { + Details::IndexCompaction { pre_compaction_size, post_compaction_size, .. } => { DetailsView { pre_compaction_size: pre_compaction_size .map(|size| size.get_appropriate_unit(UnitType::Both).to_string()), diff --git a/crates/meilisearch-types/src/tasks.rs b/crates/meilisearch-types/src/tasks.rs index c1794fe6a..2a6ef698a 100644 --- a/crates/meilisearch-types/src/tasks.rs +++ b/crates/meilisearch-types/src/tasks.rs @@ -68,7 +68,7 @@ impl Task { | IndexCreation { index_uid, .. } | IndexUpdate { index_uid, .. } | IndexDeletion { index_uid } - | CompactIndex { index_uid } => Some(index_uid), + | IndexCompaction { index_uid } => Some(index_uid), } } @@ -96,7 +96,7 @@ impl Task { | KindWithContent::SnapshotCreation | KindWithContent::Export { .. } | KindWithContent::UpgradeDatabase { .. } - | KindWithContent::CompactIndex { .. } => None, + | KindWithContent::IndexCompaction { .. } => None, } } } @@ -172,7 +172,7 @@ pub enum KindWithContent { UpgradeDatabase { from: (u32, u32, u32), }, - CompactIndex { + IndexCompaction { index_uid: String, }, } @@ -211,7 +211,7 @@ impl KindWithContent { KindWithContent::SnapshotCreation => Kind::SnapshotCreation, KindWithContent::Export { .. } => Kind::Export, KindWithContent::UpgradeDatabase { .. } => Kind::UpgradeDatabase, - KindWithContent::CompactIndex { .. } => Kind::CompactIndex, + KindWithContent::IndexCompaction { .. } => Kind::IndexCompaction, } } @@ -233,7 +233,7 @@ impl KindWithContent { | SettingsUpdate { index_uid, .. } | IndexCreation { index_uid, .. } | IndexDeletion { index_uid } - | CompactIndex { index_uid } => vec![index_uid], + | IndexCompaction { index_uid } => vec![index_uid], IndexUpdate { index_uid, new_index_uid, .. } => { let mut indexes = vec![index_uid.as_str()]; if let Some(new_uid) = new_index_uid { @@ -332,7 +332,7 @@ impl KindWithContent { versioning::VERSION_PATCH, ), }), - KindWithContent::CompactIndex { index_uid } => Some(Details::CompactIndex { + KindWithContent::IndexCompaction { index_uid } => Some(Details::IndexCompaction { index_uid: index_uid.clone(), pre_compaction_size: None, post_compaction_size: None, @@ -419,7 +419,7 @@ impl KindWithContent { versioning::VERSION_PATCH, ), }), - KindWithContent::CompactIndex { index_uid } => Some(Details::CompactIndex { + KindWithContent::IndexCompaction { index_uid } => Some(Details::IndexCompaction { index_uid: index_uid.clone(), pre_compaction_size: None, post_compaction_size: None, @@ -486,7 +486,7 @@ impl From<&KindWithContent> for Option
{ versioning::VERSION_PATCH, ), }), - KindWithContent::CompactIndex { index_uid } => Some(Details::CompactIndex { + KindWithContent::IndexCompaction { index_uid } => Some(Details::IndexCompaction { index_uid: index_uid.clone(), pre_compaction_size: None, post_compaction_size: None, @@ -601,7 +601,7 @@ pub enum Kind { SnapshotCreation, Export, UpgradeDatabase, - CompactIndex, + IndexCompaction, } impl Kind { @@ -614,7 +614,7 @@ impl Kind { | Kind::IndexCreation | Kind::IndexDeletion | Kind::IndexUpdate - | Kind::CompactIndex => true, + | Kind::IndexCompaction => true, Kind::IndexSwap | Kind::TaskCancelation | Kind::TaskDeletion @@ -642,7 +642,7 @@ impl Display for Kind { Kind::SnapshotCreation => write!(f, "snapshotCreation"), Kind::Export => write!(f, "export"), Kind::UpgradeDatabase => write!(f, "upgradeDatabase"), - Kind::CompactIndex => write!(f, "compactIndex"), + Kind::IndexCompaction => write!(f, "IndexCompaction"), } } } @@ -678,8 +678,8 @@ impl FromStr for Kind { Ok(Kind::Export) } else if kind.eq_ignore_ascii_case("upgradeDatabase") { Ok(Kind::UpgradeDatabase) - } else if kind.eq_ignore_ascii_case("compactIndex") { - Ok(Kind::CompactIndex) + } else if kind.eq_ignore_ascii_case("IndexCompaction") { + Ok(Kind::IndexCompaction) } else { Err(ParseTaskKindError(kind.to_owned())) } @@ -765,7 +765,7 @@ pub enum Details { from: (u32, u32, u32), to: (u32, u32, u32), }, - CompactIndex { + IndexCompaction { index_uid: String, pre_compaction_size: Option, post_compaction_size: Option, @@ -832,7 +832,7 @@ impl Details { Self::ClearAll { deleted_documents } => *deleted_documents = Some(0), Self::TaskCancelation { canceled_tasks, .. } => *canceled_tasks = Some(0), Self::TaskDeletion { deleted_tasks, .. } => *deleted_tasks = Some(0), - Self::CompactIndex { pre_compaction_size, post_compaction_size, .. } => { + Self::IndexCompaction { pre_compaction_size, post_compaction_size, .. } => { *pre_compaction_size = None; *post_compaction_size = None; } diff --git a/crates/meilisearch/src/routes/indexes/compact.rs b/crates/meilisearch/src/routes/indexes/compact.rs index 07f6d5ae4..07cd3b037 100644 --- a/crates/meilisearch/src/routes/indexes/compact.rs +++ b/crates/meilisearch/src/routes/indexes/compact.rs @@ -68,7 +68,7 @@ pub async fn compact( analytics.publish(IndexCompacted::default(), &req); - let task = KindWithContent::CompactIndex { index_uid: index_uid.to_string() }; + let task = KindWithContent::IndexCompaction { index_uid: index_uid.to_string() }; let task = match tokio::task::spawn_blocking(move || index_scheduler.register(task, None, false)) .await? diff --git a/crates/meilitool/src/main.rs b/crates/meilitool/src/main.rs index e4f23a7c4..acf960e70 100644 --- a/crates/meilitool/src/main.rs +++ b/crates/meilitool/src/main.rs @@ -126,7 +126,7 @@ enum Command { /// before running the copy and compaction. This way the current indexation must finish before /// the compaction operation can start. Once the compaction is done, the big index is replaced /// by the compacted one and the mutable transaction is released. - CompactIndex { index_name: String }, + IndexCompaction { index_name: String }, /// Uses the hair dryer the dedicate pages hot in cache /// @@ -165,7 +165,7 @@ fn main() -> anyhow::Result<()> { let target_version = parse_version(&target_version).context("While parsing `--target-version`. Make sure `--target-version` is in the format MAJOR.MINOR.PATCH")?; OfflineUpgrade { db_path, current_version: detected_version, target_version }.upgrade() } - Command::CompactIndex { index_name } => compact_index(db_path, &index_name), + Command::IndexCompaction { index_name } => compact_index(db_path, &index_name), Command::HairDryer { index_name, index_part } => { hair_dryer(db_path, &index_name, &index_part) }