rename documents -> substep

This commit is contained in:
Louis Dureuil 2024-11-20 15:11:26 +01:00
parent 8380ddbdcd
commit ff9c92c409
No known key found for this signature in database
4 changed files with 23 additions and 27 deletions

View File

@ -1246,16 +1246,16 @@ impl IndexScheduler {
current_step, current_step,
finished_steps, finished_steps,
total_steps, total_steps,
finished_documents, finished_substeps,
total_documents, total_substeps,
} = processing_tasks.write().unwrap().update_progress(progress); } = processing_tasks.write().unwrap().update_progress(progress);
tracing::info!( tracing::info!(
current_step, current_step,
finished_steps, finished_steps,
total_steps, total_steps,
finished_documents, finished_substeps,
total_documents total_substeps
); );
}; };

View File

@ -45,8 +45,8 @@ pub struct TaskProgress {
pub current_step: &'static str, 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_substeps: Option<u32>,
pub total_documents: Option<u32>, pub total_substeps: Option<u32>,
} }
impl Default for TaskProgress { impl Default for TaskProgress {
@ -61,8 +61,8 @@ impl TaskProgress {
current_step: "start", current_step: "start",
finished_steps: 0, finished_steps: 0,
total_steps: 1, total_steps: 1,
finished_documents: None, finished_substeps: None,
total_documents: None, total_substeps: None,
} }
} }
@ -78,18 +78,18 @@ impl TaskProgress {
self.total_steps = progress.total_steps; 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_substeps = None;
self.total_documents = None; self.total_substeps = None;
} }
self.finished_steps = progress.finished_steps; self.finished_steps = progress.finished_steps;
if let Some((finished_documents, total_documents)) = progress.finished_total_documents { if let Some((finished_substeps, total_substeps)) = progress.finished_total_substep {
if let Some(task_finished_documents) = self.finished_documents { if let Some(task_finished_substeps) = self.finished_substeps {
if task_finished_documents > finished_documents { if task_finished_substeps > finished_substeps {
return *self; return *self;
} }
} }
self.finished_documents = Some(finished_documents); self.finished_substeps = Some(finished_substeps);
self.total_documents = Some(total_documents); self.total_substeps = Some(total_substeps);
} }
*self *self
} }

View File

@ -253,11 +253,7 @@ where
} }
let finished_documents = (finished_documents * CHUNK_SIZE) as u32; let finished_documents = (finished_documents * CHUNK_SIZE) as u32;
(send_progress)(Progress::from_step_documents( (send_progress)(Progress::from_step_substep(step, finished_documents, total_documents));
step,
finished_documents,
total_documents,
));
// Clean up and reuse the document-specific allocator // Clean up and reuse the document-specific allocator
context.doc_alloc.reset(); context.doc_alloc.reset();
@ -276,7 +272,7 @@ where
}, },
)?; )?;
(send_progress)(Progress::from_step_documents(step, total_documents, total_documents)); (send_progress)(Progress::from_step_substep(step, total_documents, total_documents));
Ok(()) Ok(())
} }
@ -285,7 +281,7 @@ pub struct Progress {
pub finished_steps: u16, pub finished_steps: u16,
pub total_steps: u16, pub total_steps: u16,
pub step_name: &'static str, pub step_name: &'static str,
pub finished_total_documents: Option<(u32, u32)>, pub finished_total_substep: Option<(u32, u32)>,
} }
impl Progress { impl Progress {
@ -294,12 +290,12 @@ impl Progress {
finished_steps: step.finished_steps(), finished_steps: step.finished_steps(),
total_steps: Step::total_steps(), total_steps: Step::total_steps(),
step_name: step.name(), step_name: step.name(),
finished_total_documents: None, finished_total_substep: None,
} }
} }
pub fn from_step_documents(step: Step, finished_documents: u32, total_documents: u32) -> Self { pub fn from_step_substep(step: Step, finished_substep: u32, total_substep: u32) -> Self {
Self { Self {
finished_total_documents: Some((finished_documents, total_documents)), finished_total_substep: Some((finished_substep, total_substep)),
..Progress::from_step(step) ..Progress::from_step(step)
} }
} }

View File

@ -71,7 +71,7 @@ impl<'pl> DocumentOperation<'pl> {
if must_stop_processing() { if must_stop_processing() {
return Err(InternalError::AbortedIndexation.into()); return Err(InternalError::AbortedIndexation.into());
} }
send_progress(Progress::from_step_documents( send_progress(Progress::from_step_substep(
Step::PreparingPayloads, Step::PreparingPayloads,
payload_index as u32, payload_index as u32,
payload_count as u32, payload_count as u32,
@ -117,7 +117,7 @@ impl<'pl> DocumentOperation<'pl> {
operations_stats.push(PayloadStats { document_count, bytes, error }); operations_stats.push(PayloadStats { document_count, bytes, error });
} }
send_progress(Progress::from_step_documents( send_progress(Progress::from_step_substep(
Step::PreparingPayloads, Step::PreparingPayloads,
payload_count as u32, payload_count as u32,
payload_count as u32, payload_count as u32,