Update index-scheduler/src/batch.rs

Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
Clément Renault 2023-09-27 16:41:22 +02:00 committed by Kerollmops
parent 1b8871a585
commit 055ca3935b
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -17,10 +17,9 @@ tasks individally, but should be much faster since we are only performing
one indexing operation.
*/
use core::fmt;
use std::borrow::Cow;
use std::collections::{BTreeSet, HashSet};
use std::ffi::OsStr;
use std::fmt;
use std::fs::{self, File};
use std::io::BufWriter;
@ -206,20 +205,20 @@ impl fmt::Display for Batch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let index_uid = self.index_uid();
let tasks = self.ids();
let task = match self {
Batch::TaskCancelation { .. } => Cow::Borrowed("TaskCancelation"),
Batch::TaskDeletion(_) => Cow::Borrowed("TaskDeletion"),
Batch::SnapshotCreation(_) => Cow::Borrowed("SnapshotCreation"),
Batch::Dump(_) => Cow::Borrowed("Dump"),
Batch::IndexOperation { op, .. } => Cow::Owned(op.to_string()),
Batch::IndexCreation { .. } => Cow::Borrowed("IndexCreation"),
Batch::IndexUpdate { .. } => Cow::Borrowed("IndexUpdate"),
Batch::IndexDeletion { .. } => Cow::Borrowed("IndexDeletion"),
Batch::IndexSwap { .. } => Cow::Borrowed("IndexSwap"),
match self {
Batch::TaskCancelation { .. } => f.write_str("TaskCancelation")?,
Batch::TaskDeletion(_) => f.write_str("TaskDeletion")?,
Batch::SnapshotCreation(_) => f.write_str("SnapshotCreation")?,
Batch::Dump(_) => f.write_str("Dump")?,
Batch::IndexOperation { op, .. } => write!(f, "{op}")?,
Batch::IndexCreation { .. } => f.write_str("IndexCreation")?,
Batch::IndexUpdate { .. } => f.write_str("IndexUpdate")?,
Batch::IndexDeletion { .. } => f.write_str("IndexDeletion")?,
Batch::IndexSwap { .. } => f.write_str("IndexSwap")?,
};
match index_uid {
Some(name) => f.write_fmt(format_args!("{task} on {name:?} from tasks: {tasks:?}")),
None => f.write_fmt(format_args!("{task} from tasks: {tasks:?}")),
Some(name) => f.write_fmt(format_args!(" on {name:?} from tasks: {tasks:?}")),
None => f.write_fmt(format_args!(" from tasks: {tasks:?}")),
}
}
}