Update after review

This commit is contained in:
Louis Dureuil 2025-01-13 10:43:26 +01:00
parent 181a01f8d8
commit c66841626e
No known key found for this signature in database
4 changed files with 15 additions and 22 deletions

1
Cargo.lock generated
View File

@ -3602,7 +3602,6 @@ dependencies = [
"indexmap", "indexmap",
"meilisearch-auth", "meilisearch-auth",
"meilisearch-types", "meilisearch-types",
"milli",
"serde", "serde",
"serde_json", "serde_json",
"tempfile", "tempfile",

View File

@ -17,7 +17,6 @@ file-store = { path = "../file-store" }
indexmap = { version = "2.7.0", features = ["serde"] } indexmap = { version = "2.7.0", features = ["serde"] }
meilisearch-auth = { path = "../meilisearch-auth" } meilisearch-auth = { path = "../meilisearch-auth" }
meilisearch-types = { path = "../meilisearch-types" } meilisearch-types = { path = "../meilisearch-types" }
milli = { path = "../milli" }
serde = { version = "1.0.209", features = ["derive"] } serde = { version = "1.0.209", features = ["derive"] }
serde_json = { version = "1.0.133", features = ["preserve_order"] } serde_json = { version = "1.0.133", features = ["preserve_order"] }
tempfile = "3.14.0" tempfile = "3.14.0"

View File

@ -10,10 +10,10 @@ use anyhow::Context;
use file_store::FileStore; use file_store::FileStore;
use indexmap::IndexMap; use indexmap::IndexMap;
use meilisearch_types::milli::documents::DocumentsBatchReader; use meilisearch_types::milli::documents::DocumentsBatchReader;
use milli::heed::types::{SerdeJson, Str}; use meilisearch_types::milli::heed::types::{SerdeJson, Str};
use milli::heed::{Database, EnvOpenOptions, RoTxn, RwTxn}; use meilisearch_types::milli::heed::{Database, EnvOpenOptions, RoTxn, RwTxn};
use milli::progress::Step; use meilisearch_types::milli::progress::Step;
use milli::{FieldDistribution, Index}; use meilisearch_types::milli::{FieldDistribution, Index};
use serde::Serialize; use serde::Serialize;
use serde_json::value::RawValue; use serde_json::value::RawValue;
use tempfile::NamedTempFile; 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))) .map(|res| res.map(|(uid, uuid)| (uid.to_owned(), uuid)))
.collect(); .collect();
let progress = milli::progress::Progress::default(); let progress = meilisearch_types::milli::progress::Progress::default();
let finished = AtomicBool::new(false); let finished = AtomicBool::new(false);
std::thread::scope(|scope| { std::thread::scope(|scope| {
@ -173,14 +173,18 @@ fn rebuild_field_distribution(db_path: &Path) -> anyhow::Result<()> {
println!("\t- Rebuilding field distribution"); println!("\t- Rebuilding field distribution");
let index = let index = meilisearch_types::milli::Index::new(EnvOpenOptions::new(), &index_path)
milli::Index::new(EnvOpenOptions::new(), &index_path).with_context(|| { .with_context(|| {
format!("while opening index {uid} at '{}'", index_path.display()) format!("while opening index {uid} at '{}'", index_path.display())
})?; })?;
let mut index_txn = index.write_txn()?; let mut index_txn = index.write_txn()?;
milli::update::new::reindex::field_distribution(&index, &mut index_txn, &progress) meilisearch_types::milli::update::new::reindex::field_distribution(
&index,
&mut index_txn,
&progress,
)
.context("while rebuilding field distribution")?; .context("while rebuilding field distribution")?;
let stats = IndexStats::new(&index, &index_txn) let stats = IndexStats::new(&index, &index_txn)
@ -281,7 +285,7 @@ impl IndexStats {
/// # Parameters /// # Parameters
/// ///
/// - rtxn: a RO transaction for the index, obtained from `Index::read_txn()`. /// - rtxn: a RO transaction for the index, obtained from `Index::read_txn()`.
pub fn new(index: &Index, rtxn: &RoTxn) -> milli::Result<Self> { pub fn new(index: &Index, rtxn: &RoTxn) -> meilisearch_types::milli::Result<Self> {
Ok(IndexStats { Ok(IndexStats {
number_of_documents: index.number_of_documents(rtxn)?, number_of_documents: index.number_of_documents(rtxn)?,
database_size: index.on_disk_size()?, database_size: index.on_disk_size()?,

View File

@ -1,7 +1,7 @@
use heed::RwTxn; use heed::RwTxn;
use super::document::{Document, DocumentFromDb}; use super::document::{Document, DocumentFromDb};
use crate::progress::{self, AtomicSubStep, NamedStep, Progress}; use crate::progress::{self, AtomicSubStep, Progress};
use crate::{FieldDistribution, Index, Result}; use crate::{FieldDistribution, Index, Result};
pub fn field_distribution(index: &Index, wtxn: &mut RwTxn<'_>, progress: &Progress) -> 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)?; index.put_field_distribution(wtxn, &distribution)?;
Ok(()) Ok(())
} }
#[derive(Default)]
pub struct FieldDistributionIndexProgress;
impl NamedStep for FieldDistributionIndexProgress {
fn name(&self) -> &'static str {
"documents"
}
}