Skip to content

Commit 3a71807

Browse files
committed
Use shared tree display extractor for plans
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent faf0058 commit 3a71807

2 files changed

Lines changed: 12 additions & 30 deletions

File tree

vortex-layout/src/plan/display.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,11 @@ use std::fmt;
66
pub use vortex_utils::tree::DepthContext as PlanTreeContext;
77
pub use vortex_utils::tree::IndentedFormatter as PlanIndentedFormatter;
88
use vortex_utils::tree::TreeDisplayAdapter;
9+
pub use vortex_utils::tree::TreeDisplayExtractor as PlanTreeExtractor;
910
use vortex_utils::tree::write_indented_tree;
1011

1112
use super::DynPlan;
1213

13-
/// Contributes one composable dimension of information to plan tree nodes.
14-
pub trait PlanTreeExtractor: Send + Sync {
15-
/// Writes space-prefixed annotations on the node's header line.
16-
fn write_header(
17-
&self,
18-
plan: &dyn DynPlan,
19-
context: &PlanTreeContext,
20-
formatter: &mut fmt::Formatter<'_>,
21-
) -> fmt::Result {
22-
let _ = (plan, context, formatter);
23-
Ok(())
24-
}
25-
26-
/// Writes detail lines beneath the node's header.
27-
fn write_details(
28-
&self,
29-
plan: &dyn DynPlan,
30-
context: &PlanTreeContext,
31-
formatter: &mut PlanIndentedFormatter<'_, '_>,
32-
) -> fmt::Result {
33-
let _ = (plan, context, formatter);
34-
Ok(())
35-
}
36-
}
37-
3814
/// Adds the plan's display representation to a tree node's header.
3915
pub struct PlanSummaryExtractor;
4016

@@ -45,7 +21,7 @@ impl PlanSummaryExtractor {
4521
}
4622
}
4723

48-
impl PlanTreeExtractor for PlanSummaryExtractor {
24+
impl PlanTreeExtractor<dyn DynPlan, PlanTreeContext> for PlanSummaryExtractor {
4925
fn write_header(
5026
&self,
5127
plan: &dyn DynPlan,
@@ -63,7 +39,7 @@ impl PlanTreeExtractor for PlanSummaryExtractor {
6339
/// start with only node and child names, then add extractors with [`Self::with`].
6440
pub struct PlanTreeDisplay<'a> {
6541
plan: &'a dyn DynPlan,
66-
extractors: Vec<Box<dyn PlanTreeExtractor>>,
42+
extractors: Vec<Box<dyn PlanTreeExtractor<dyn DynPlan, PlanTreeContext>>>,
6743
}
6844

6945
impl<'a> PlanTreeDisplay<'a> {
@@ -81,13 +57,19 @@ impl<'a> PlanTreeDisplay<'a> {
8157
}
8258

8359
/// Adds an extractor to the display pipeline.
84-
pub fn with<E: PlanTreeExtractor + 'static>(mut self, extractor: E) -> Self {
60+
pub fn with<E: PlanTreeExtractor<dyn DynPlan, PlanTreeContext> + 'static>(
61+
mut self,
62+
extractor: E,
63+
) -> Self {
8564
self.extractors.push(Box::new(extractor));
8665
self
8766
}
8867

8968
/// Adds a pre-boxed extractor to the display pipeline.
90-
pub fn with_boxed(mut self, extractor: Box<dyn PlanTreeExtractor>) -> Self {
69+
pub fn with_boxed(
70+
mut self,
71+
extractor: Box<dyn PlanTreeExtractor<dyn DynPlan, PlanTreeContext>>,
72+
) -> Self {
9173
self.extractors.push(extractor);
9274
self
9375
}

vortex-layout/src/plan/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ fn plan_display_matches_array_tree_display_shape() -> VortexResult<()> {
369369

370370
struct DepthExtractor;
371371

372-
impl PlanTreeExtractor for DepthExtractor {
372+
impl PlanTreeExtractor<dyn DynPlan, PlanTreeContext> for DepthExtractor {
373373
fn write_header(
374374
&self,
375375
_plan: &dyn DynPlan,

0 commit comments

Comments
 (0)