mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-02-02 00:23:27 +01:00
fix the field distribution when upgrading from the v1_12
This commit is contained in:
parent
653ae387e4
commit
ccacdf212c
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3776,6 +3776,7 @@ dependencies = [
|
||||
"candle-transformers",
|
||||
"charabia",
|
||||
"concat-arrays",
|
||||
"convert_case 0.6.0",
|
||||
"crossbeam-channel",
|
||||
"csv",
|
||||
"deserr",
|
||||
|
@ -20,6 +20,7 @@ bytemuck = { version = "1.21.0", features = ["extern_crate_alloc"] }
|
||||
byteorder = "1.5.0"
|
||||
charabia = { version = "0.9.2", default-features = false }
|
||||
concat-arrays = "0.1.2"
|
||||
convert_case = "0.6.0"
|
||||
crossbeam-channel = "0.5.14"
|
||||
deserr = "0.6.3"
|
||||
either = { version = "1.13.0", features = ["serde"] }
|
||||
|
@ -89,19 +89,24 @@ impl<Name: NamedStep> Step for AtomicSubStep<Name> {
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub use convert_case as _private_convert_case;
|
||||
#[doc(hidden)]
|
||||
pub use enum_iterator as _private_enum_iterator;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! make_enum_progress {
|
||||
($visibility:vis enum $name:ident { $($variant:ident,)+ }) => {
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Sequence)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, $crate::progress::_private_enum_iterator::Sequence)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
$visibility enum $name {
|
||||
$($variant),+
|
||||
}
|
||||
|
||||
impl Step for $name {
|
||||
fn name(&self) -> Cow<'static, str> {
|
||||
use convert_case::Casing;
|
||||
impl $crate::progress::Step for $name {
|
||||
fn name(&self) -> std::borrow::Cow<'static, str> {
|
||||
use $crate::progress::_private_convert_case::Casing;
|
||||
|
||||
match self {
|
||||
$(
|
||||
@ -115,6 +120,7 @@ macro_rules! make_enum_progress {
|
||||
}
|
||||
|
||||
fn total(&self) -> u32 {
|
||||
use $crate::progress::_private_enum_iterator::Sequence;
|
||||
Self::CARDINALITY as u32
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
mod v1_12;
|
||||
|
||||
use heed::RwTxn;
|
||||
use v1_12::{v1_12_3_to_v1_13, v1_12_to_v1_12_3};
|
||||
|
||||
use crate::progress::{Progress, VariableNameStep};
|
||||
use crate::{Index, InternalError, Result};
|
||||
@ -6,12 +9,21 @@ use crate::{Index, InternalError, Result};
|
||||
/// Return true if the cached stats of the index must be regenerated
|
||||
pub fn upgrade(wtxn: &mut RwTxn, index: &Index, progress: Progress) -> Result<bool> {
|
||||
let from = index.get_version(wtxn)?;
|
||||
let upgrade_functions =
|
||||
[(v1_12_to_v1_13 as fn(&Index, Progress) -> Result<()>, "Upgrading from v1.12 to v1.13")];
|
||||
let upgrade_functions = [
|
||||
(
|
||||
v1_12_to_v1_12_3 as fn(&mut RwTxn, &Index, Progress) -> Result<bool>,
|
||||
"Upgrading from v1.12.(0/1/2) to v1.12.3",
|
||||
),
|
||||
(
|
||||
v1_12_3_to_v1_13 as fn(&mut RwTxn, &Index, Progress) -> Result<bool>,
|
||||
"Upgrading from v1.12.3+ to v1.13",
|
||||
),
|
||||
];
|
||||
|
||||
let (start, regenerate_stats) = match from {
|
||||
let start = match from {
|
||||
// If there was no version it means we're coming from the v1.12
|
||||
None | Some((1, 12, _)) => (0, false),
|
||||
None | Some((1, 12, 0..=2)) => 0,
|
||||
Some((1, 12, 3..)) => 1,
|
||||
// We must handle the current version in the match because in case of a failure some index may have been upgraded but not other.
|
||||
Some((1, 13, _)) => return Ok(false),
|
||||
Some((major, minor, patch)) => {
|
||||
@ -22,18 +34,15 @@ pub fn upgrade(wtxn: &mut RwTxn, index: &Index, progress: Progress) -> Result<bo
|
||||
enum UpgradeVersion {}
|
||||
let upgrade_path = &upgrade_functions[start..];
|
||||
|
||||
let mut regenerate_stats = false;
|
||||
for (i, (upgrade_function, upgrade_msg)) in upgrade_path.iter().enumerate() {
|
||||
progress.update_progress(VariableNameStep::<UpgradeVersion>::new(
|
||||
upgrade_msg.to_string(),
|
||||
i as u32,
|
||||
upgrade_path.len() as u32,
|
||||
));
|
||||
(upgrade_function)(index, progress.clone())?;
|
||||
regenerate_stats |= (upgrade_function)(wtxn, index, progress.clone())?;
|
||||
}
|
||||
|
||||
Ok(regenerate_stats)
|
||||
}
|
||||
|
||||
fn v1_12_to_v1_13(_index: &Index, _progress: Progress) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
29
crates/milli/src/update/upgrade/v1_12.rs
Normal file
29
crates/milli/src/update/upgrade/v1_12.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use heed::RwTxn;
|
||||
|
||||
use crate::{make_enum_progress, Result};
|
||||
|
||||
use crate::{progress::Progress, Index};
|
||||
|
||||
// The field distribution was not computed correctly in the v1.12 until the v1.12.3
|
||||
pub(super) fn v1_12_to_v1_12_3(
|
||||
wtxn: &mut RwTxn,
|
||||
index: &Index,
|
||||
progress: Progress,
|
||||
) -> Result<bool> {
|
||||
make_enum_progress! {
|
||||
enum FieldDistribution {
|
||||
RebuildingFieldDistribution,
|
||||
}
|
||||
};
|
||||
progress.update_progress(FieldDistribution::RebuildingFieldDistribution);
|
||||
crate::update::new::reindex::field_distribution(index, wtxn, &progress)?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
pub(super) fn v1_12_3_to_v1_13(
|
||||
_wtxn: &mut RwTxn,
|
||||
_index: &Index,
|
||||
_progress: Progress,
|
||||
) -> Result<bool> {
|
||||
Ok(false)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user