Skip to content

Commit

Permalink
Avoid recomputing new_pipeline_ids to increase readability. (#3215)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Apr 25, 2023
1 parent 37d6691 commit 6c46d9e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions quickwit/quickwit-indexing/src/actors/indexing_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,18 @@ impl IndexingService {

let running_pipeline_ids: HashSet<IndexingPipelineId> =
self.indexing_pipeline_handles.keys().cloned().collect();
let new_pipeline_ids = updated_pipeline_ids

let new_pipeline_ids: Vec<&IndexingPipelineId> = updated_pipeline_ids
.difference(&running_pipeline_ids)
.collect_vec();
.collect();

// We fetch the new indexes metadata.
let indexes_metadata_futures = new_pipeline_ids
.iter()
// No need to emit two request for the same `index_id`
.unique_by(|pipeline_id| pipeline_id.index_id.clone())
.map(|pipeline_id| self.index_metadata(ctx, &pipeline_id.index_id));

let indexes_metadata = try_join_all(indexes_metadata_futures).await?;
let indexes_metadata_by_index_id: HashMap<String, IndexMetadata> = indexes_metadata
.into_iter()
Expand All @@ -489,7 +493,7 @@ impl IndexingService {
let mut failed_spawning_pipeline_ids: Vec<IndexingPipelineId> = Vec::new();

// Add new pipelines.
for new_pipeline_id in updated_pipeline_ids.difference(&running_pipeline_ids) {
for new_pipeline_id in new_pipeline_ids {
info!(pipeline_id=?new_pipeline_id, "Spawning indexing pipeline.");
let index_metadata = indexes_metadata_by_index_id
.get(&new_pipeline_id.index_id)
Expand Down

0 comments on commit 6c46d9e

Please sign in to comment.