Add index rename feature

This commit is contained in:
Quentin de Quelen
2025-08-01 23:17:19 +02:00
committed by Tamo
parent 3240d89e81
commit 0f1c78b185
6 changed files with 100 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ enum AutobatchKind {
IndexCreation,
IndexDeletion,
IndexUpdate,
IndexRename,
IndexSwap,
}
@@ -67,6 +68,7 @@ impl From<KindWithContent> for AutobatchKind {
KindWithContent::IndexDeletion { .. } => AutobatchKind::IndexDeletion,
KindWithContent::IndexCreation { .. } => AutobatchKind::IndexCreation,
KindWithContent::IndexUpdate { .. } => AutobatchKind::IndexUpdate,
KindWithContent::IndexRename { .. } => AutobatchKind::IndexRename,
KindWithContent::IndexSwap { .. } => AutobatchKind::IndexSwap,
KindWithContent::TaskCancelation { .. }
| KindWithContent::TaskDeletion { .. }
@@ -115,6 +117,9 @@ pub enum BatchKind {
IndexUpdate {
id: TaskId,
},
IndexRename {
id: TaskId,
},
IndexSwap {
id: TaskId,
},
@@ -176,6 +181,13 @@ impl BatchKind {
)),
false,
),
K::IndexRename => (
Break((
BatchKind::IndexRename { id: task_id },
BatchStopReason::TaskCannotBeBatched { kind, id: task_id },
)),
false,
),
K::IndexSwap => (
Break((
BatchKind::IndexSwap { id: task_id },
@@ -288,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) => Break((this, BatchStopReason::TaskCannotBeBatched { kind, id })),
(this, K::IndexCreation | K::IndexUpdate | K::IndexRename | K::IndexSwap | K::DocumentEdition) => 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.
(this, kind) if !index_already_exists && this.allow_index_creation() == Some(false) && kind.allow_index_creation() == Some(true) => {
Break((this, BatchStopReason::IndexCreationMismatch { id }))