-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3cf8d1
commit 80c2c56
Showing
33 changed files
with
320 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,28 +25,26 @@ repository = "https://github.com/apache/arrow-ballista" | |
readme = "README.md" | ||
authors = ["Apache DataFusion <[email protected]>"] | ||
edition = "2021" | ||
rust-version = "1.72" | ||
|
||
[dependencies] | ||
async-trait = { workspace = true } | ||
ballista-core = { path = "../core", version = "0.12.0" } | ||
ballista-executor = { path = "../executor", version = "0.12.0", optional = true } | ||
ballista-scheduler = { path = "../scheduler", version = "0.12.0", optional = true } | ||
datafusion = { workspace = true } | ||
datafusion-proto = { workspace = true } | ||
futures = { workspace = true } | ||
log = { workspace = true } | ||
parking_lot = { workspace = true } | ||
tempfile = { workspace = true } | ||
|
||
tokio = { workspace = true } | ||
url = { workspace = true } | ||
|
||
[dev-dependencies] | ||
ballista-executor = { path = "../executor", version = "0.12.0" } | ||
ballista-scheduler = { path = "../scheduler", version = "0.12.0" } | ||
ctor = { workspace = true } | ||
datafusion-proto = { workspace = true } | ||
env_logger = { workspace = true } | ||
rstest = { version = "0.23" } | ||
tempfile = { workspace = true } | ||
tonic = { workspace = true } | ||
|
||
[features] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use crate::error::Result; | ||
use crate::execution_plans::{ShuffleWriterExec, UnresolvedShuffleExec}; | ||
|
||
use datafusion::datasource::physical_plan::{CsvExec, ParquetExec}; | ||
use datafusion::physical_plan::aggregates::AggregateExec; | ||
use datafusion::physical_plan::coalesce_batches::CoalesceBatchesExec; | ||
use datafusion::physical_plan::coalesce_partitions::CoalescePartitionsExec; | ||
use datafusion::physical_plan::filter::FilterExec; | ||
use datafusion::physical_plan::joins::HashJoinExec; | ||
use datafusion::physical_plan::projection::ProjectionExec; | ||
use datafusion::physical_plan::sorts::sort::SortExec; | ||
use datafusion::physical_plan::ExecutionPlan; | ||
use std::fs::File; | ||
use std::io::{BufWriter, Write}; | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
use std::sync::Arc; | ||
|
||
pub fn produce_diagram(filename: &str, stages: &[Arc<ShuffleWriterExec>]) -> Result<()> { | ||
let write_file = File::create(filename)?; | ||
let mut w = BufWriter::new(&write_file); | ||
writeln!(w, "digraph G {{")?; | ||
|
||
// draw stages and entities | ||
for stage in stages { | ||
writeln!(w, "\tsubgraph cluster{} {{", stage.stage_id())?; | ||
writeln!(w, "\t\tlabel = \"Stage {}\";", stage.stage_id())?; | ||
let mut id = AtomicUsize::new(0); | ||
build_exec_plan_diagram( | ||
&mut w, | ||
stage.children()[0].as_ref(), | ||
stage.stage_id(), | ||
&mut id, | ||
true, | ||
)?; | ||
writeln!(w, "\t}}")?; | ||
} | ||
|
||
// draw relationships | ||
for stage in stages { | ||
let mut id = AtomicUsize::new(0); | ||
build_exec_plan_diagram( | ||
&mut w, | ||
stage.children()[0].as_ref(), | ||
stage.stage_id(), | ||
&mut id, | ||
false, | ||
)?; | ||
} | ||
|
||
write!(w, "}}")?; | ||
Ok(()) | ||
} | ||
|
||
fn build_exec_plan_diagram( | ||
w: &mut BufWriter<&File>, | ||
plan: &dyn ExecutionPlan, | ||
stage_id: usize, | ||
id: &mut AtomicUsize, | ||
draw_entity: bool, | ||
) -> Result<usize> { | ||
let operator_str = if plan.as_any().downcast_ref::<AggregateExec>().is_some() { | ||
"AggregateExec" | ||
} else if plan.as_any().downcast_ref::<SortExec>().is_some() { | ||
"SortExec" | ||
} else if plan.as_any().downcast_ref::<ProjectionExec>().is_some() { | ||
"ProjectionExec" | ||
} else if plan.as_any().downcast_ref::<HashJoinExec>().is_some() { | ||
"HashJoinExec" | ||
} else if plan.as_any().downcast_ref::<ParquetExec>().is_some() { | ||
"ParquetExec" | ||
} else if plan.as_any().downcast_ref::<CsvExec>().is_some() { | ||
"CsvExec" | ||
} else if plan.as_any().downcast_ref::<FilterExec>().is_some() { | ||
"FilterExec" | ||
} else if plan.as_any().downcast_ref::<ShuffleWriterExec>().is_some() { | ||
"ShuffleWriterExec" | ||
} else if plan | ||
.as_any() | ||
.downcast_ref::<UnresolvedShuffleExec>() | ||
.is_some() | ||
{ | ||
"UnresolvedShuffleExec" | ||
} else if plan | ||
.as_any() | ||
.downcast_ref::<CoalesceBatchesExec>() | ||
.is_some() | ||
{ | ||
"CoalesceBatchesExec" | ||
} else if plan | ||
.as_any() | ||
.downcast_ref::<CoalescePartitionsExec>() | ||
.is_some() | ||
{ | ||
"CoalescePartitionsExec" | ||
} else { | ||
println!("Unknown: {plan:?}"); | ||
"Unknown" | ||
}; | ||
|
||
let node_id = id.load(Ordering::SeqCst); | ||
id.store(node_id + 1, Ordering::SeqCst); | ||
|
||
if draw_entity { | ||
writeln!( | ||
w, | ||
"\t\tstage_{stage_id}_exec_{node_id} [shape=box, label=\"{operator_str}\"];" | ||
)?; | ||
} | ||
for child in plan.children() { | ||
if let Some(shuffle) = child.as_any().downcast_ref::<UnresolvedShuffleExec>() { | ||
if !draw_entity { | ||
writeln!( | ||
w, | ||
"\tstage_{}_exec_1 -> stage_{}_exec_{};", | ||
shuffle.stage_id, stage_id, node_id | ||
)?; | ||
} | ||
} else { | ||
// relationships within same entity | ||
let child_id = | ||
build_exec_plan_diagram(w, child.as_ref(), stage_id, id, draw_entity)?; | ||
if draw_entity { | ||
writeln!( | ||
w, | ||
"\t\tstage_{stage_id}_exec_{child_id} -> stage_{stage_id}_exec_{node_id};" | ||
)?; | ||
} | ||
} | ||
} | ||
Ok(node_id) | ||
} |
Oops, something went wrong.