mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14:27 +01:00
Progress displayed in logs
This commit is contained in:
parent
c782c09208
commit
bfefaf71c2
@ -39,7 +39,9 @@ use meilisearch_types::milli::vector::parsed_vectors::{
|
|||||||
};
|
};
|
||||||
use meilisearch_types::milli::{self, Filter, ThreadPoolNoAbortBuilder};
|
use meilisearch_types::milli::{self, Filter, ThreadPoolNoAbortBuilder};
|
||||||
use meilisearch_types::settings::{apply_settings_to_builder, Settings, Unchecked};
|
use meilisearch_types::settings::{apply_settings_to_builder, Settings, Unchecked};
|
||||||
use meilisearch_types::tasks::{Details, IndexSwap, Kind, KindWithContent, Status, Task};
|
use meilisearch_types::tasks::{
|
||||||
|
Details, IndexSwap, Kind, KindWithContent, Status, Task, TaskProgress,
|
||||||
|
};
|
||||||
use meilisearch_types::{compression, Index, VERSION_FILE_NAME};
|
use meilisearch_types::{compression, Index, VERSION_FILE_NAME};
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use time::macros::format_description;
|
use time::macros::format_description;
|
||||||
@ -1240,7 +1242,21 @@ impl IndexScheduler {
|
|||||||
secs_since_started_processing_at
|
secs_since_started_processing_at
|
||||||
.store((now - started_processing_at).as_secs(), atomic::Ordering::Relaxed);
|
.store((now - started_processing_at).as_secs(), atomic::Ordering::Relaxed);
|
||||||
|
|
||||||
processing_tasks.write().unwrap().update_progress(progress);
|
let TaskProgress {
|
||||||
|
current_step,
|
||||||
|
finished_steps,
|
||||||
|
total_steps,
|
||||||
|
finished_documents,
|
||||||
|
total_documents,
|
||||||
|
} = processing_tasks.write().unwrap().update_progress(progress);
|
||||||
|
|
||||||
|
tracing::info!(
|
||||||
|
current_step,
|
||||||
|
finished_steps,
|
||||||
|
total_steps,
|
||||||
|
finished_documents,
|
||||||
|
total_documents
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
match operation {
|
match operation {
|
||||||
|
@ -182,8 +182,8 @@ impl ProcessingTasks {
|
|||||||
self.processing = processing;
|
self.processing = processing;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_progress(&mut self, progress: Progress) {
|
fn update_progress(&mut self, progress: Progress) -> TaskProgress {
|
||||||
self.progress.get_or_insert_with(TaskProgress::default).update(progress);
|
self.progress.get_or_insert_with(TaskProgress::default).update(progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the processing tasks to an empty list
|
/// Set the processing tasks to an empty list
|
||||||
|
@ -39,10 +39,10 @@ pub struct Task {
|
|||||||
pub kind: KindWithContent,
|
pub kind: KindWithContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct TaskProgress {
|
pub struct TaskProgress {
|
||||||
pub current_step: String,
|
pub current_step: &'static str,
|
||||||
pub finished_steps: u16,
|
pub finished_steps: u16,
|
||||||
pub total_steps: u16,
|
pub total_steps: u16,
|
||||||
pub finished_documents: Option<u32>,
|
pub finished_documents: Option<u32>,
|
||||||
@ -58,7 +58,7 @@ impl Default for TaskProgress {
|
|||||||
impl TaskProgress {
|
impl TaskProgress {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
current_step: String::new(),
|
current_step: "start",
|
||||||
finished_steps: 0,
|
finished_steps: 0,
|
||||||
total_steps: 1,
|
total_steps: 1,
|
||||||
finished_documents: None,
|
finished_documents: None,
|
||||||
@ -66,15 +66,17 @@ impl TaskProgress {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, progress: Progress) {
|
pub fn update(&mut self, progress: Progress) -> TaskProgress {
|
||||||
if self.current_step != progress.step_name {
|
|
||||||
self.current_step.clear();
|
|
||||||
self.current_step.push_str(progress.step_name);
|
|
||||||
}
|
|
||||||
self.total_steps = progress.total_steps;
|
|
||||||
if self.finished_steps > progress.finished_steps {
|
if self.finished_steps > progress.finished_steps {
|
||||||
return;
|
return *self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.current_step != progress.step_name {
|
||||||
|
self.current_step = progress.step_name
|
||||||
|
}
|
||||||
|
|
||||||
|
self.total_steps = progress.total_steps;
|
||||||
|
|
||||||
if self.finished_steps < progress.finished_steps {
|
if self.finished_steps < progress.finished_steps {
|
||||||
self.finished_documents = None;
|
self.finished_documents = None;
|
||||||
self.total_documents = None;
|
self.total_documents = None;
|
||||||
@ -83,12 +85,13 @@ impl TaskProgress {
|
|||||||
if let Some((finished_documents, total_documents)) = progress.finished_total_documents {
|
if let Some((finished_documents, total_documents)) = progress.finished_total_documents {
|
||||||
if let Some(task_finished_documents) = self.finished_documents {
|
if let Some(task_finished_documents) = self.finished_documents {
|
||||||
if task_finished_documents > finished_documents {
|
if task_finished_documents > finished_documents {
|
||||||
return;
|
return *self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.finished_documents = Some(finished_documents);
|
self.finished_documents = Some(finished_documents);
|
||||||
self.total_documents = Some(total_documents);
|
self.total_documents = Some(total_documents);
|
||||||
}
|
}
|
||||||
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user