mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
introduce a trait to upgrade the indexes
This commit is contained in:
parent
fd5649091d
commit
c27c923439
4 changed files with 104 additions and 46 deletions
|
@ -1,28 +1,56 @@
|
|||
use heed::RwTxn;
|
||||
|
||||
use crate::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH};
|
||||
use crate::progress::Progress;
|
||||
use crate::{make_enum_progress, Index, Result};
|
||||
|
||||
// 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)
|
||||
use super::UpgradeIndex;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub(super) struct V1_12_To_V1_12_3 {}
|
||||
|
||||
impl UpgradeIndex for V1_12_To_V1_12_3 {
|
||||
fn upgrade(
|
||||
&self,
|
||||
wtxn: &mut RwTxn,
|
||||
index: &Index,
|
||||
_original: (u32, u32, u32),
|
||||
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)
|
||||
}
|
||||
|
||||
fn target_version(&self) -> (u32, u32, u32) {
|
||||
(1, 12, 3)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn v1_12_3_to_v1_13(
|
||||
_wtxn: &mut RwTxn,
|
||||
_index: &Index,
|
||||
_progress: Progress,
|
||||
) -> Result<bool> {
|
||||
Ok(false)
|
||||
#[allow(non_camel_case_types)]
|
||||
pub(super) struct V1_12_3_To_Current();
|
||||
|
||||
impl UpgradeIndex for V1_12_3_To_Current {
|
||||
fn upgrade(
|
||||
&self,
|
||||
_wtxn: &mut RwTxn,
|
||||
_index: &Index,
|
||||
_original: (u32, u32, u32),
|
||||
_progress: Progress,
|
||||
) -> Result<bool> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn target_version(&self) -> (u32, u32, u32) {
|
||||
(
|
||||
VERSION_MAJOR.parse().unwrap(),
|
||||
VERSION_MINOR.parse().unwrap(),
|
||||
VERSION_PATCH.parse().unwrap(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue