mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Improve code quality
This commit is contained in:
parent
59a1c5d9a7
commit
4a179fb3c0
9 changed files with 25 additions and 48 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::collections::BTreeSet;
|
||||
use std::fmt::Write;
|
||||
|
||||
use meilisearch_types::batches::{Batch, BatchEmbeddingStats, BatchEnqueuedAt, BatchStats};
|
||||
use meilisearch_types::batches::{Batch, EmbedderStatsView, BatchEnqueuedAt, BatchStats};
|
||||
use meilisearch_types::heed::types::{SerdeBincode, SerdeJson, Str};
|
||||
use meilisearch_types::heed::{Database, RoTxn};
|
||||
use meilisearch_types::milli::{CboRoaringBitmapCodec, RoaringBitmapCodec, BEU32};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashSet;
|
||||
use std::ops::{Bound, RangeBounds};
|
||||
|
||||
use meilisearch_types::batches::{Batch, BatchEmbeddingStats, BatchId};
|
||||
use meilisearch_types::batches::{Batch, EmbedderStatsView, BatchId};
|
||||
use meilisearch_types::heed::types::{DecodeIgnore, SerdeBincode, SerdeJson, Str};
|
||||
use meilisearch_types::heed::{Database, Env, RoTxn, RwTxn, WithoutTls};
|
||||
use meilisearch_types::milli::{CboRoaringBitmapCodec, RoaringBitmapCodec, BEU32};
|
||||
|
@ -92,10 +92,7 @@ impl BatchQueue {
|
|||
}
|
||||
|
||||
pub(crate) fn get_batch(&self, rtxn: &RoTxn, batch_id: BatchId) -> Result<Option<Batch>> {
|
||||
println!("Got batch from db {batch_id:?}");
|
||||
let r = Ok(self.all_batches.get(rtxn, &batch_id)?);
|
||||
println!("Got batch from db => {:?}", r);
|
||||
r
|
||||
Ok(self.all_batches.get(rtxn, &batch_id)?)
|
||||
}
|
||||
|
||||
/// Returns the whole set of batches that belongs to this index.
|
||||
|
@ -174,8 +171,6 @@ impl BatchQueue {
|
|||
pub(crate) fn write_batch(&self, wtxn: &mut RwTxn, batch: ProcessingBatch) -> Result<()> {
|
||||
let old_batch = self.all_batches.get(wtxn, &batch.uid)?;
|
||||
|
||||
println!("Saving batch: {:?}", batch.embedder_stats);
|
||||
|
||||
self.all_batches.put(
|
||||
wtxn,
|
||||
&batch.uid,
|
||||
|
|
|
@ -437,10 +437,8 @@ impl IndexScheduler {
|
|||
#[cfg(test)]
|
||||
self.maybe_fail(crate::test_utils::FailureLocation::InsideCreateBatch)?;
|
||||
|
||||
println!("create next batch");
|
||||
let batch_id = self.queue.batches.next_batch_id(rtxn)?;
|
||||
let mut current_batch = ProcessingBatch::new(batch_id);
|
||||
println!("over");
|
||||
|
||||
let enqueued = &self.queue.tasks.get_status(rtxn, Status::Enqueued)?;
|
||||
let count_total_enqueued = enqueued.len();
|
||||
|
@ -456,7 +454,6 @@ impl IndexScheduler {
|
|||
kind: Kind::TaskCancelation,
|
||||
id: task_id,
|
||||
});
|
||||
println!("task cancelled");
|
||||
return Ok(Some((Batch::TaskCancelation { task }, current_batch)));
|
||||
}
|
||||
|
||||
|
@ -527,7 +524,7 @@ impl IndexScheduler {
|
|||
}
|
||||
|
||||
// 5. We make a batch from the unprioritised tasks. Start by taking the next enqueued task.
|
||||
let task_id = if let Some(task_id) = enqueued.min() { task_id } else { println!("return"); return Ok(None) };
|
||||
let task_id = if let Some(task_id) = enqueued.min() { task_id } else { return Ok(None) };
|
||||
let mut task =
|
||||
self.queue.tasks.get_task(rtxn, task_id)?.ok_or(Error::CorruptedTaskQueue)?;
|
||||
|
||||
|
@ -605,7 +602,6 @@ impl IndexScheduler {
|
|||
autobatcher::autobatch(enqueued, index_already_exists, primary_key.as_deref())
|
||||
{
|
||||
current_batch.reason(autobatch_stop_reason.unwrap_or(stop_reason));
|
||||
println!("autobatch");
|
||||
return Ok(self
|
||||
.create_next_batch_index(
|
||||
rtxn,
|
||||
|
@ -619,7 +615,6 @@ impl IndexScheduler {
|
|||
|
||||
// If we found no tasks then we were notified for something that got autobatched
|
||||
// somehow and there is nothing to do.
|
||||
println!("nothing to do");
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::ops::Bound;
|
|||
use std::sync::Arc;
|
||||
use crate::milli::progress::EmbedderStats;
|
||||
|
||||
use meilisearch_types::batches::{Batch, BatchEmbeddingStats, BatchEnqueuedAt, BatchId, BatchStats};
|
||||
use meilisearch_types::batches::{Batch, EmbedderStatsView, BatchEnqueuedAt, BatchId, BatchStats};
|
||||
use meilisearch_types::heed::{Database, RoTxn, RwTxn};
|
||||
use meilisearch_types::milli::CboRoaringBitmapCodec;
|
||||
use meilisearch_types::task_view::DetailsView;
|
||||
|
@ -47,8 +47,6 @@ impl ProcessingBatch {
|
|||
let mut statuses = HashSet::default();
|
||||
statuses.insert(Status::Processing);
|
||||
|
||||
println!("Processing batch created: {}", uid);
|
||||
|
||||
Self {
|
||||
uid,
|
||||
details: DetailsView::default(),
|
||||
|
@ -104,14 +102,11 @@ impl ProcessingBatch {
|
|||
}
|
||||
|
||||
pub fn reason(&mut self, reason: BatchStopReason) {
|
||||
println!("batch stopped: {:?}", reason);
|
||||
self.reason = reason;
|
||||
}
|
||||
|
||||
/// Must be called once the batch has finished processing.
|
||||
pub fn finished(&mut self) {
|
||||
println!("Batch finished: {}", self.uid);
|
||||
|
||||
self.details = DetailsView::default();
|
||||
self.stats = BatchStats::default();
|
||||
self.finished_at = Some(OffsetDateTime::now_utc());
|
||||
|
@ -126,8 +121,6 @@ impl ProcessingBatch {
|
|||
|
||||
/// Update the timestamp of the tasks and the inner structure of this structure.
|
||||
pub fn update(&mut self, task: &mut Task) {
|
||||
println!("Updating task: {} in batch: {}", task.uid, self.uid);
|
||||
|
||||
// We must re-set this value in case we're dealing with a task that has been added between
|
||||
// the `processing` and `finished` state
|
||||
// We must re-set this value in case we're dealing with a task that has been added between
|
||||
|
@ -152,7 +145,6 @@ impl ProcessingBatch {
|
|||
}
|
||||
|
||||
pub fn to_batch(&self) -> Batch {
|
||||
println!("Converting to batch: {:?} {:?}", self.uid, self.embedder_stats);
|
||||
Batch {
|
||||
uid: self.uid,
|
||||
progress: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue