mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-06 20:56:31 +00:00
First version of Hannoy dumpless upgrade
This commit is contained in:
@ -3,15 +3,18 @@ mod v1_13;
|
||||
mod v1_14;
|
||||
mod v1_15;
|
||||
mod v1_16;
|
||||
mod v1_18;
|
||||
|
||||
use heed::RwTxn;
|
||||
use v1_12::{V1_12_3_To_V1_13_0, V1_12_To_V1_12_3};
|
||||
use v1_13::{V1_13_0_To_V1_13_1, V1_13_1_To_Latest_V1_13};
|
||||
use v1_14::Latest_V1_13_To_Latest_V1_14;
|
||||
use v1_15::Latest_V1_14_To_Latest_V1_15;
|
||||
use v1_16::Latest_V1_15_To_V1_16_0;
|
||||
use v1_18::Latest_V1_17_To_V1_18_0;
|
||||
|
||||
use crate::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH};
|
||||
use crate::progress::{Progress, VariableNameStep};
|
||||
use crate::update::upgrade::v1_16::Latest_V1_15_To_V1_16_0;
|
||||
use crate::{Index, InternalError, Result};
|
||||
|
||||
trait UpgradeIndex {
|
||||
@ -34,6 +37,8 @@ const UPGRADE_FUNCTIONS: &[&dyn UpgradeIndex] = &[
|
||||
&Latest_V1_13_To_Latest_V1_14 {},
|
||||
&Latest_V1_14_To_Latest_V1_15 {},
|
||||
&Latest_V1_15_To_V1_16_0 {},
|
||||
&ToTargetNoOp { target: (1, 17, 0) },
|
||||
&Latest_V1_17_To_V1_18_0 {},
|
||||
// This is the last upgrade function, it will be called when the index is up to date.
|
||||
// any other upgrade function should be added before this one.
|
||||
&ToCurrentNoOp {},
|
||||
@ -62,9 +67,9 @@ const fn start(from: (u32, u32, u32)) -> Option<usize> {
|
||||
// We must handle the current version in the match because in case of a failure some index may have been upgraded but not other.
|
||||
(1, 15, _) => function_index!(6),
|
||||
(1, 16, _) => function_index!(7),
|
||||
(1, 17, _) => function_index!(7),
|
||||
(1, 18, _) => function_index!(7),
|
||||
(1, 19, _) => function_index!(7),
|
||||
(1, 17, _) => function_index!(8),
|
||||
(1, 18, _) => function_index!(9),
|
||||
(1, 19, _) => function_index!(9),
|
||||
// We deliberately don't add a placeholder with (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) here to force manually
|
||||
// considering dumpless upgrade.
|
||||
(_major, _minor, _patch) => return None,
|
||||
@ -147,3 +152,25 @@ impl UpgradeIndex for ToCurrentNoOp {
|
||||
(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform no operation during the upgrade except changing to the specified target version.
|
||||
#[allow(non_camel_case_types)]
|
||||
struct ToTargetNoOp {
|
||||
pub target: (u32, u32, u32),
|
||||
}
|
||||
|
||||
impl UpgradeIndex for ToTargetNoOp {
|
||||
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) {
|
||||
self.target
|
||||
}
|
||||
}
|
||||
|
34
crates/milli/src/update/upgrade/v1_18.rs
Normal file
34
crates/milli/src/update/upgrade/v1_18.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use heed::RwTxn;
|
||||
|
||||
use super::UpgradeIndex;
|
||||
use crate::progress::Progress;
|
||||
use crate::vector::VectorStore;
|
||||
use crate::{Index, Result};
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub(super) struct Latest_V1_17_To_V1_18_0();
|
||||
|
||||
impl UpgradeIndex for Latest_V1_17_To_V1_18_0 {
|
||||
fn upgrade(
|
||||
&self,
|
||||
wtxn: &mut RwTxn,
|
||||
index: &Index,
|
||||
_original: (u32, u32, u32),
|
||||
_progress: Progress,
|
||||
) -> Result<bool> {
|
||||
let embedding_configs = index.embedding_configs();
|
||||
for config in embedding_configs.embedding_configs(wtxn)? {
|
||||
// TODO use the embedder name to display progress
|
||||
let quantized = config.config.quantized();
|
||||
let embedder_id = embedding_configs.embedder_id(wtxn, &config.name)?.unwrap();
|
||||
let vector_store = VectorStore::new(index.vector_store, embedder_id, quantized);
|
||||
vector_store.convert_from_arroy(wtxn)?;
|
||||
}
|
||||
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn target_version(&self) -> (u32, u32, u32) {
|
||||
(1, 18, 0)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user