mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Fix some of the edition 2024 warnings
This commit is contained in:
parent
2762d5a32a
commit
aa87064a13
82 changed files with 323 additions and 317 deletions
|
@ -272,11 +272,11 @@ impl IndexMapper {
|
|||
if tries >= 100 {
|
||||
panic!("Too many attempts to close index {name} prior to deletion.")
|
||||
}
|
||||
let reopen = if let Some(reopen) = reopen.wait_timeout(Duration::from_secs(6)) {
|
||||
let reopen = match reopen.wait_timeout(Duration::from_secs(6)) { Some(reopen) => {
|
||||
reopen
|
||||
} else {
|
||||
} _ => {
|
||||
continue;
|
||||
};
|
||||
}};
|
||||
reopen.close(&mut self.index_map.write().unwrap());
|
||||
continue;
|
||||
}
|
||||
|
@ -382,11 +382,11 @@ impl IndexMapper {
|
|||
Available(index) => break index,
|
||||
Closing(reopen) => {
|
||||
// Avoiding deadlocks: no lock taken while doing this operation.
|
||||
let reopen = if let Some(reopen) = reopen.wait_timeout(Duration::from_secs(6)) {
|
||||
let reopen = match reopen.wait_timeout(Duration::from_secs(6)) { Some(reopen) => {
|
||||
reopen
|
||||
} else {
|
||||
} _ => {
|
||||
continue;
|
||||
};
|
||||
}};
|
||||
let index_path = self.base_path.join(uuid.to_string());
|
||||
// take the lock to reopen the environment.
|
||||
reopen
|
||||
|
|
|
@ -355,19 +355,19 @@ impl IndexScheduler {
|
|||
}
|
||||
|
||||
fn is_good_heed(tasks_path: &Path, map_size: usize) -> bool {
|
||||
if let Ok(env) = unsafe {
|
||||
match unsafe {
|
||||
heed::EnvOpenOptions::new().map_size(clamp_to_page_size(map_size)).open(tasks_path)
|
||||
} {
|
||||
} { Ok(env) => {
|
||||
env.prepare_for_closing().wait();
|
||||
true
|
||||
} else {
|
||||
} _ => {
|
||||
// We're treating all errors equally here, not only allocation errors.
|
||||
// This means there's a possiblity for the budget to lower due to errors different from allocation errors.
|
||||
// For persistent errors, this is OK as long as the task db is then reopened normally without ignoring the error this time.
|
||||
// For transient errors, this could lead to an instance with too low a budget.
|
||||
// However transient errors are: 1) less likely than persistent errors 2) likely to cause other issues down the line anyway.
|
||||
false
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
pub fn read_txn(&self) -> Result<RoTxn<WithoutTls>> {
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::TaskId;
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! debug_snapshot {
|
||||
($value:expr, @$snapshot:literal) => {{
|
||||
($value:expr_2021, @$snapshot:literal) => {{
|
||||
let value = format!("{:?}", $value);
|
||||
meili_snap::snapshot!(value, @$snapshot);
|
||||
}};
|
||||
|
|
|
@ -499,13 +499,13 @@ impl IndexScheduler {
|
|||
// create the batch directly. Otherwise, get the index name associated with the task
|
||||
// and use the autobatcher to batch the enqueued tasks associated with it
|
||||
|
||||
let index_name = if let Some(&index_name) = task.indexes().first() {
|
||||
let index_name = match task.indexes().first() { Some(&index_name) => {
|
||||
index_name
|
||||
} else {
|
||||
} _ => {
|
||||
assert!(matches!(&task.kind, KindWithContent::IndexSwap { swaps } if swaps.is_empty()));
|
||||
current_batch.processing(Some(&mut task));
|
||||
return Ok(Some((Batch::IndexSwap { task }, current_batch)));
|
||||
};
|
||||
}};
|
||||
|
||||
let index_already_exists = self.index_mapper.exists(rtxn, index_name)?;
|
||||
let mut primary_key = None;
|
||||
|
|
|
@ -47,11 +47,11 @@ impl IndexScheduler {
|
|||
Batch::TaskCancelation { mut task } => {
|
||||
// 1. Retrieve the tasks that matched the query at enqueue-time.
|
||||
let matched_tasks =
|
||||
if let KindWithContent::TaskCancelation { tasks, query: _ } = &task.kind {
|
||||
match &task.kind { KindWithContent::TaskCancelation { tasks, query: _ } => {
|
||||
tasks
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!()
|
||||
};
|
||||
}};
|
||||
|
||||
let rtxn = self.env.read_txn()?;
|
||||
let mut canceled_tasks = self.cancel_matched_tasks(
|
||||
|
@ -83,11 +83,11 @@ impl IndexScheduler {
|
|||
let mut matched_tasks = RoaringBitmap::new();
|
||||
|
||||
for task in tasks.iter() {
|
||||
if let KindWithContent::TaskDeletion { tasks, query: _ } = &task.kind {
|
||||
match &task.kind { KindWithContent::TaskDeletion { tasks, query: _ } => {
|
||||
matched_tasks |= tasks;
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!()
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
let mut wtxn = self.env.write_txn()?;
|
||||
|
@ -279,11 +279,11 @@ impl IndexScheduler {
|
|||
progress.update_progress(SwappingTheIndexes::EnsuringCorrectnessOfTheSwap);
|
||||
|
||||
let mut wtxn = self.env.write_txn()?;
|
||||
let swaps = if let KindWithContent::IndexSwap { swaps } = &task.kind {
|
||||
let swaps = match &task.kind { KindWithContent::IndexSwap { swaps } => {
|
||||
swaps
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!()
|
||||
};
|
||||
}};
|
||||
let mut not_found_indexes = BTreeSet::new();
|
||||
for IndexSwap { indexes: (lhs, rhs) } in swaps {
|
||||
for index in [lhs, rhs] {
|
||||
|
@ -532,7 +532,7 @@ impl IndexScheduler {
|
|||
// We must remove the batch entirely
|
||||
if tasks.is_empty() {
|
||||
if let Some(batch) = self.queue.batches.get_batch(wtxn, batch_id)? {
|
||||
if let Some(BatchEnqueuedAt { earliest, oldest }) = batch.enqueued_at {
|
||||
match batch.enqueued_at { Some(BatchEnqueuedAt { earliest, oldest }) => {
|
||||
remove_task_datetime(
|
||||
wtxn,
|
||||
self.queue.batches.enqueued_at,
|
||||
|
@ -545,7 +545,7 @@ impl IndexScheduler {
|
|||
oldest,
|
||||
batch_id,
|
||||
)?;
|
||||
} else {
|
||||
} _ => {
|
||||
// If we don't have the enqueued at in the batch it means the database comes from the v1.12
|
||||
// and we still need to find the date by scrolling the database
|
||||
remove_n_tasks_datetime_earlier_than(
|
||||
|
@ -555,7 +555,7 @@ impl IndexScheduler {
|
|||
batch.stats.total_nb_tasks.clamp(1, 2) as usize,
|
||||
batch_id,
|
||||
)?;
|
||||
}
|
||||
}}
|
||||
remove_task_datetime(
|
||||
wtxn,
|
||||
self.queue.batches.started_at,
|
||||
|
|
|
@ -26,11 +26,11 @@ impl IndexScheduler {
|
|||
progress.update_progress(DumpCreationProgress::StartTheDumpCreation);
|
||||
let started_at = OffsetDateTime::now_utc();
|
||||
let (keys, instance_uid) =
|
||||
if let KindWithContent::DumpCreation { keys, instance_uid } = &task.kind {
|
||||
match &task.kind { KindWithContent::DumpCreation { keys, instance_uid } => {
|
||||
(keys, instance_uid)
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!();
|
||||
};
|
||||
}};
|
||||
let dump = dump::DumpWriter::new(*instance_uid)?;
|
||||
|
||||
// 1. dump the keys
|
||||
|
@ -206,14 +206,14 @@ impl IndexScheduler {
|
|||
let user_err =
|
||||
milli::Error::UserError(milli::UserError::InvalidVectorsMapType {
|
||||
document_id: {
|
||||
if let Ok(Some(Ok(index))) = index
|
||||
match index
|
||||
.external_id_of(&rtxn, std::iter::once(id))
|
||||
.map(|it| it.into_iter().next())
|
||||
{
|
||||
{ Ok(Some(Ok(index))) => {
|
||||
index
|
||||
} else {
|
||||
} _ => {
|
||||
format!("internal docid={id}")
|
||||
}
|
||||
}}
|
||||
},
|
||||
value: vectors.clone(),
|
||||
});
|
||||
|
|
|
@ -206,17 +206,17 @@ impl IndexScheduler {
|
|||
IndexOperation::DocumentEdition { index_uid, mut task } => {
|
||||
progress.update_progress(DocumentEditionProgress::RetrievingConfig);
|
||||
|
||||
let (filter, code) = if let KindWithContent::DocumentEdition {
|
||||
let (filter, code) = match &task.kind
|
||||
{ KindWithContent::DocumentEdition {
|
||||
filter_expr,
|
||||
context: _,
|
||||
function,
|
||||
..
|
||||
} = &task.kind
|
||||
{
|
||||
} => {
|
||||
(filter_expr, function)
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!()
|
||||
};
|
||||
}};
|
||||
|
||||
let candidates = match filter.as_ref().map(Filter::from_json) {
|
||||
Some(Ok(Some(filter))) => filter
|
||||
|
@ -226,18 +226,18 @@ impl IndexScheduler {
|
|||
Some(Err(e)) => return Err(Error::from_milli(e, Some(index_uid.clone()))),
|
||||
};
|
||||
|
||||
let (original_filter, context, function) = if let Some(Details::DocumentEdition {
|
||||
let (original_filter, context, function) = match task.details
|
||||
{ Some(Details::DocumentEdition {
|
||||
original_filter,
|
||||
context,
|
||||
function,
|
||||
..
|
||||
}) = task.details
|
||||
{
|
||||
}) => {
|
||||
(original_filter, context, function)
|
||||
} else {
|
||||
} _ => {
|
||||
// In the case of a `documentEdition` the details MUST be set
|
||||
unreachable!();
|
||||
};
|
||||
}};
|
||||
|
||||
if candidates.is_empty() {
|
||||
task.status = Status::Succeeded;
|
||||
|
@ -397,16 +397,16 @@ impl IndexScheduler {
|
|||
};
|
||||
}
|
||||
let will_be_removed = to_delete.len() - before;
|
||||
if let Some(Details::DocumentDeletionByFilter {
|
||||
match &mut task.details
|
||||
{ Some(Details::DocumentDeletionByFilter {
|
||||
original_filter: _,
|
||||
deleted_documents,
|
||||
}) = &mut task.details
|
||||
{
|
||||
}) => {
|
||||
*deleted_documents = Some(will_be_removed);
|
||||
} else {
|
||||
} _ => {
|
||||
// In the case of a `documentDeleteByFilter` the details MUST be set
|
||||
unreachable!()
|
||||
}
|
||||
}}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ pub(crate) fn filter_out_references_to_newer_tasks(task: &mut Task) {
|
|||
|
||||
pub(crate) fn check_index_swap_validity(task: &Task) -> Result<()> {
|
||||
let swaps =
|
||||
if let KindWithContent::IndexSwap { swaps } = &task.kind { swaps } else { return Ok(()) };
|
||||
match &task.kind { KindWithContent::IndexSwap { swaps } => { swaps } _ => { return Ok(()) }};
|
||||
let mut all_indexes = HashSet::new();
|
||||
let mut duplicate_indexes = BTreeSet::new();
|
||||
for IndexSwap { indexes: (lhs, rhs) } in swaps {
|
||||
|
@ -501,15 +501,15 @@ impl crate::IndexScheduler {
|
|||
} => {
|
||||
assert_eq!(kind.as_kind(), Kind::DocumentDeletion);
|
||||
let (index_uid, documents_ids) =
|
||||
if let KindWithContent::DocumentDeletion {
|
||||
match kind
|
||||
{ KindWithContent::DocumentDeletion {
|
||||
ref index_uid,
|
||||
ref documents_ids,
|
||||
} = kind
|
||||
{
|
||||
} => {
|
||||
(index_uid, documents_ids)
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!()
|
||||
};
|
||||
}};
|
||||
assert_eq!(&task_index_uid.unwrap(), index_uid);
|
||||
|
||||
match status {
|
||||
|
@ -526,15 +526,15 @@ impl crate::IndexScheduler {
|
|||
}
|
||||
Details::DocumentDeletionByFilter { deleted_documents, original_filter: _ } => {
|
||||
assert_eq!(kind.as_kind(), Kind::DocumentDeletion);
|
||||
let (index_uid, _) = if let KindWithContent::DocumentDeletionByFilter {
|
||||
let (index_uid, _) = match kind
|
||||
{ KindWithContent::DocumentDeletionByFilter {
|
||||
ref index_uid,
|
||||
ref filter_expr,
|
||||
} = kind
|
||||
{
|
||||
} => {
|
||||
(index_uid, filter_expr)
|
||||
} else {
|
||||
} _ => {
|
||||
unreachable!()
|
||||
};
|
||||
}};
|
||||
assert_eq!(&task_index_uid.unwrap(), index_uid);
|
||||
|
||||
match status {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue