Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions datafusion/distributed/src/codec/distributed_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl PhysicalExtensionCodec for DistributedCodec {
let Ok(url) = Url::parse(&url_str) else {
return Err(proto_error("Invalid URL in task"));
};
worker_urls.push(url);
worker_urls.push(url.into());
}
Ok(Stage::Remote(RemoteStage {
query_id: deserialize_uuid(proto.query_id.as_ref())?,
Expand Down Expand Up @@ -349,7 +349,7 @@ impl PhysicalExtensionCodec for DistributedCodec {
let mut tasks = Vec::with_capacity(remote.workers.len());
for worker in &remote.workers {
tasks.push(ExecutionTaskProto {
url_str: Some(worker.to_string()),
url_str: Some(worker.ready_url()?.to_string()),
})
}
StageProto {
Expand Down
24 changes: 7 additions & 17 deletions datafusion/distributed/src/coordinator/prepare_dynamic_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::dynamic_filtering::{
use crate::execution_plans::SamplerExec;
use crate::stage::{LocalStage, RemoteStage};
use crate::{
BytesCounterMetric, CoordinatorToWorkerMsg, LoadInfo, MaxGaugeMetric, NetworkBoundaryExt,
NetworkCoalesceExec, Stage, TaskCountAnnotation,
BytesCounterMetric, LoadInfo, MaxGaugeMetric, NetworkBoundaryExt, NetworkCoalesceExec, Stage,
TaskCountAnnotation,
};
use async_trait::async_trait;
use dashmap::DashMap;
Expand Down Expand Up @@ -123,23 +123,13 @@ impl NetworkBoundaryBuilder for DynamicPlanBuilder<'_> {

let mut load_info_rxs = Vec::with_capacity(input_stage.tasks);

let mut stage_coordinator = self.query_coordinator.stage_coordinator(&input_stage);

let mut futures = Vec::with_capacity(input_stage.tasks);
for task_i in 0..input_stage.tasks {
futures.push(stage_coordinator.init_bidirectional_stream(task_i));
}
let results = futures::future::try_join_all(futures).await?;
let stage_coordinator = self.query_coordinator.stage_coordinator(&input_stage);

let mut workers = Vec::with_capacity(input_stage.tasks);
for (task_i, (url, worker_tx, worker_rx_stream)) in results.into_iter().enumerate() {
workers.push(url);
load_info_rxs.push({
let rx = stage_coordinator.worker_to_coordinator_task(task_i, worker_rx_stream);
UnboundedReceiverStream::new(rx)
});
let _ = worker_tx.send(CoordinatorToWorkerMsg::KickOffSampling);
stage_coordinator.coordinator_to_worker_task(task_i, worker_tx)?;
for task_i in 0..input_stage.tasks {
let (worker_loc, load_info_rx) = stage_coordinator.init_bidirectional_stream(task_i)?;
workers.push(worker_loc);
load_info_rxs.push(UnboundedReceiverStream::new(load_info_rx));
}
stage_coordinator.seal_dynamic_filter_stage()?;

Expand Down
16 changes: 5 additions & 11 deletions datafusion/distributed/src/coordinator/prepare_static_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,14 @@ pub(super) async fn prepare_static_plan(
vec![]
};

let mut stage_coordinator = query_coordinator.stage_coordinator(stage);
let mut futures = Vec::with_capacity(stage.tasks);
for task_i in 0..stage.tasks {
futures.push(stage_coordinator.init_bidirectional_stream(task_i));
}
let results = futures::future::try_join_all(futures).await?;

let stage_coordinator = query_coordinator.stage_coordinator(stage);
let mut workers = Vec::with_capacity(stage.tasks);
for (task_i, (url, worker_tx, worker_stream)) in results.into_iter().enumerate() {
workers.push(url);
stage_coordinator.worker_to_coordinator_task(task_i, worker_stream);
stage_coordinator.coordinator_to_worker_task(task_i, worker_tx)?;
for task_i in 0..stage.tasks {
let (worker_loc, _) = stage_coordinator.init_bidirectional_stream(task_i)?;
workers.push(worker_loc);
}
stage_coordinator.seal_dynamic_filter_stage()?;

Ok(Transformed::yes(plan.with_input_stage(Stage::Remote(
RemoteStage {
query_id: stage.query_id,
Expand Down
Loading
Loading