-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
789c87a
commit 0af7652
Showing
4 changed files
with
48 additions
and
45 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
44 changes: 44 additions & 0 deletions
44
rust/cubestore/cubestore/src/queryplanner/physical_plan_flags.rs
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,44 @@ | ||
use datafusion::physical_plan::merge_sort::MergeSortExec; | ||
use datafusion::physical_plan::ExecutionPlan; | ||
|
||
use serde::Serialize; | ||
use serde_json::{json, Value}; | ||
|
||
#[derive(Serialize)] | ||
pub struct PhysicalPlanFlags { | ||
pub merge_sort_node: bool, | ||
} | ||
|
||
impl PhysicalPlanFlags { | ||
pub fn enough_to_fill(&self) -> bool { | ||
self.merge_sort_node | ||
} | ||
|
||
pub fn is_suboptimal_query(&self) -> bool { | ||
!self.merge_sort_node | ||
} | ||
|
||
pub fn to_json(&self) -> Value { | ||
json!(self) | ||
} | ||
|
||
pub fn with_execution_plan(p: &dyn ExecutionPlan) -> Self { | ||
let mut flags = PhysicalPlanFlags { | ||
merge_sort_node: false, | ||
}; | ||
PhysicalPlanFlags::physical_plan_flags_fill(p, &mut flags); | ||
flags | ||
} | ||
|
||
fn physical_plan_flags_fill(p: &dyn ExecutionPlan, flags: &mut PhysicalPlanFlags) { | ||
if p.as_any().is::<MergeSortExec>() { | ||
flags.merge_sort_node = true; | ||
} | ||
if flags.enough_to_fill() { | ||
return; | ||
} | ||
for child in p.children() { | ||
PhysicalPlanFlags::physical_plan_flags_fill(child.as_ref(), flags); | ||
} | ||
} | ||
} |
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