Rename operation to IndexCompaction

This commit is contained in:
Kerollmops
2025-10-06 16:19:04 +02:00
parent f95398420b
commit 3877e0043c
11 changed files with 45 additions and 41 deletions

View File

@@ -158,7 +158,7 @@ pub enum KindDump {
UpgradeDatabase {
from: (u32, u32, u32),
},
CompactIndex {
IndexCompaction {
index_uid: String,
},
}
@@ -243,7 +243,9 @@ impl From<KindWithContent> 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 }
}
}
}
}

View File

@@ -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 }
}
},
};

View File

@@ -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:?} }}")
}
}

View File

@@ -25,7 +25,7 @@ enum AutobatchKind {
IndexDeletion,
IndexUpdate,
IndexSwap,
CompactIndex,
IndexCompaction,
}
impl AutobatchKind {
@@ -69,7 +69,7 @@ impl From<KindWithContent> 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 { .. },
_,
) => {

View File

@@ -55,7 +55,7 @@ pub(crate) enum Batch {
UpgradeDatabase {
tasks: Vec<Task>,
},
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 }))
}
}
}

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -438,7 +438,7 @@ impl From<Details> 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()),

View File

@@ -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<Details> {
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<Byte>,
post_compaction_size: Option<Byte>,
@@ -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;
}

View File

@@ -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?

View File

@@ -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)
}