mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 16:06:31 +00:00 
			
		
		
		
	Update after review
This commit is contained in:
		
							
								
								
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -3733,7 +3733,6 @@ dependencies = [ | |||||||
|  "indexmap", |  "indexmap", | ||||||
|  "meilisearch-auth", |  "meilisearch-auth", | ||||||
|  "meilisearch-types", |  "meilisearch-types", | ||||||
|  "milli", |  | ||||||
|  "serde", |  "serde", | ||||||
|  "serde_json", |  "serde_json", | ||||||
|  "tempfile", |  "tempfile", | ||||||
|   | |||||||
| @@ -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.217", features = ["derive"] } | serde = { version = "1.0.217", features = ["derive"] } | ||||||
| serde_json = { version = "1.0.135", features = ["preserve_order"] } | serde_json = { version = "1.0.135", features = ["preserve_order"] } | ||||||
| tempfile = "3.15.0" | tempfile = "3.15.0" | ||||||
|   | |||||||
| @@ -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,15 +173,19 @@ 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( | ||||||
|                 .context("while rebuilding field distribution")?; |                 &index, | ||||||
|  |                 &mut index_txn, | ||||||
|  |                 &progress, | ||||||
|  |             ) | ||||||
|  |             .context("while rebuilding field distribution")?; | ||||||
|  |  | ||||||
|             let stats = IndexStats::new(&index, &index_txn) |             let stats = IndexStats::new(&index, &index_txn) | ||||||
|                 .with_context(|| format!("computing stats for index `{uid}`"))?; |                 .with_context(|| format!("computing stats for index `{uid}`"))?; | ||||||
| @@ -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()?, | ||||||
|   | |||||||
| @@ -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" |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user