From c66841626efb3009124b72a10317b33436947fcd Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 13 Jan 2025 10:43:26 +0100 Subject: [PATCH] Update after review --- Cargo.lock | 1 - crates/meilitool/Cargo.toml | 1 - crates/meilitool/src/upgrade/v1_12.rs | 24 ++++++++++++++---------- crates/milli/src/update/new/reindex.rs | 11 +---------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f971d900..8166bd090 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3602,7 +3602,6 @@ dependencies = [ "indexmap", "meilisearch-auth", "meilisearch-types", - "milli", "serde", "serde_json", "tempfile", diff --git a/crates/meilitool/Cargo.toml b/crates/meilitool/Cargo.toml index 4824fe935..52651a449 100644 --- a/crates/meilitool/Cargo.toml +++ b/crates/meilitool/Cargo.toml @@ -17,7 +17,6 @@ file-store = { path = "../file-store" } indexmap = { version = "2.7.0", features = ["serde"] } meilisearch-auth = { path = "../meilisearch-auth" } meilisearch-types = { path = "../meilisearch-types" } -milli = { path = "../milli" } serde = { version = "1.0.209", features = ["derive"] } serde_json = { version = "1.0.133", features = ["preserve_order"] } tempfile = "3.14.0" diff --git a/crates/meilitool/src/upgrade/v1_12.rs b/crates/meilitool/src/upgrade/v1_12.rs index c5463f0b5..593fb833c 100644 --- a/crates/meilitool/src/upgrade/v1_12.rs +++ b/crates/meilitool/src/upgrade/v1_12.rs @@ -10,10 +10,10 @@ use anyhow::Context; use file_store::FileStore; use indexmap::IndexMap; use meilisearch_types::milli::documents::DocumentsBatchReader; -use milli::heed::types::{SerdeJson, Str}; -use milli::heed::{Database, EnvOpenOptions, RoTxn, RwTxn}; -use milli::progress::Step; -use milli::{FieldDistribution, Index}; +use meilisearch_types::milli::heed::types::{SerdeJson, Str}; +use meilisearch_types::milli::heed::{Database, EnvOpenOptions, RoTxn, RwTxn}; +use meilisearch_types::milli::progress::Step; +use meilisearch_types::milli::{FieldDistribution, Index}; use serde::Serialize; use serde_json::value::RawValue; use tempfile::NamedTempFile; @@ -138,7 +138,7 @@ fn rebuild_field_distribution(db_path: &Path) -> anyhow::Result<()> { .map(|res| res.map(|(uid, uuid)| (uid.to_owned(), uuid))) .collect(); - let progress = milli::progress::Progress::default(); + let progress = meilisearch_types::milli::progress::Progress::default(); let finished = AtomicBool::new(false); std::thread::scope(|scope| { @@ -173,15 +173,19 @@ fn rebuild_field_distribution(db_path: &Path) -> anyhow::Result<()> { println!("\t- Rebuilding field distribution"); - let index = - milli::Index::new(EnvOpenOptions::new(), &index_path).with_context(|| { + let index = meilisearch_types::milli::Index::new(EnvOpenOptions::new(), &index_path) + .with_context(|| { format!("while opening index {uid} at '{}'", index_path.display()) })?; let mut index_txn = index.write_txn()?; - milli::update::new::reindex::field_distribution(&index, &mut index_txn, &progress) - .context("while rebuilding field distribution")?; + meilisearch_types::milli::update::new::reindex::field_distribution( + &index, + &mut index_txn, + &progress, + ) + .context("while rebuilding field distribution")?; let stats = IndexStats::new(&index, &index_txn) .with_context(|| format!("computing stats for index `{uid}`"))?; @@ -281,7 +285,7 @@ impl IndexStats { /// # Parameters /// /// - rtxn: a RO transaction for the index, obtained from `Index::read_txn()`. - pub fn new(index: &Index, rtxn: &RoTxn) -> milli::Result { + pub fn new(index: &Index, rtxn: &RoTxn) -> meilisearch_types::milli::Result { Ok(IndexStats { number_of_documents: index.number_of_documents(rtxn)?, database_size: index.on_disk_size()?, diff --git a/crates/milli/src/update/new/reindex.rs b/crates/milli/src/update/new/reindex.rs index b5b7f3cf7..6bfeb123e 100644 --- a/crates/milli/src/update/new/reindex.rs +++ b/crates/milli/src/update/new/reindex.rs @@ -1,7 +1,7 @@ use heed::RwTxn; use super::document::{Document, DocumentFromDb}; -use crate::progress::{self, AtomicSubStep, NamedStep, Progress}; +use crate::progress::{self, AtomicSubStep, Progress}; use crate::{FieldDistribution, Index, Result}; pub fn field_distribution(index: &Index, wtxn: &mut RwTxn<'_>, progress: &Progress) -> Result<()> { @@ -36,12 +36,3 @@ pub fn field_distribution(index: &Index, wtxn: &mut RwTxn<'_>, progress: &Progre index.put_field_distribution(wtxn, &distribution)?; Ok(()) } - -#[derive(Default)] -pub struct FieldDistributionIndexProgress; - -impl NamedStep for FieldDistributionIndexProgress { - fn name(&self) -> &'static str { - "documents" - } -}