Skip to content

Commit be971d2

Browse files
authored
Minor touchups to vortex-expr (#3466)
There's a lot more work to do there, but I think that's a start. Signed-off-by: Adam Gutglick <[email protected]>
1 parent 912c2e1 commit be971d2

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

vortex-expr/src/transform/partition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a> StructFieldExpressionSplitter<'a> {
157157
let ctx = ScopeDType::new(dtype.clone());
158158

159159
Ok(PartitionedExpr {
160-
root: simplify_typed(split.result, &ctx)?,
160+
root: simplify_typed(split.into_inner(), &ctx)?,
161161
partitions: partitions.into_boxed_slice(),
162162
partition_names: partition_names.into(),
163163
partition_dtypes: partition_dtypes.into_boxed_slice(),
@@ -193,7 +193,7 @@ impl FolderMut for StructFieldExpressionSplitter<'_> {
193193
let replaced = node
194194
.clone()
195195
.transform(&mut ScopeStepIntoFieldExpr(field_name.clone()))?;
196-
sub_exprs.push(replaced.result);
196+
sub_exprs.push(replaced.into_inner());
197197

198198
let access = get_item(
199199
Self::field_idx_name(field_name, idx),

vortex-expr/src/transform/remove_merge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{ExprRef, Merge, ScopeDType, VortexExpr, get_item, pack};
66
/// Replaces [Merge] with combination of [GetItem] and [Pack] expressions.
77
pub(crate) fn remove_merge(e: ExprRef, ctx: &ScopeDType) -> VortexResult<ExprRef> {
88
let mut transform = RemoveMergeTransform { ctx };
9-
e.transform(&mut transform).map(|e| e.result)
9+
e.transform(&mut transform).map(|e| e.into_inner())
1010
}
1111

1212
struct RemoveMergeTransform<'a> {

vortex-expr/src/transform/remove_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{ExprRef, ScopeDType, Select, get_item, pack};
66
/// Replaces [Select] with combination of [GetItem] and [Pack] expressions.
77
pub(crate) fn remove_select(e: ExprRef, ctx: &ScopeDType) -> VortexResult<ExprRef> {
88
let mut transform = RemoveSelectTransform { ctx };
9-
e.transform(&mut transform).map(|e| e.result)
9+
e.transform(&mut transform).map(|e| e.into_inner())
1010
}
1111

1212
struct RemoveSelectTransform<'a> {

vortex-expr/src/transform/simplify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{ExprRef, GetItem, Pack};
1010
/// If the scope dtype is known, see `simplify_typed` for a simplifier which uses dtype.
1111
pub fn simplify(e: ExprRef) -> VortexResult<ExprRef> {
1212
let mut folder = Simplify;
13-
let e = e.transform(&mut folder).map(|e| e.result)?;
13+
let e = e.transform(&mut folder).map(|e| e.into_inner())?;
1414
Ok(find_between(e.clone()))
1515
}
1616

vortex-expr/src/traversal/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,22 @@ use crate::ExprRef;
1515
/// - `Skip`: Skip visiting the children of the current node.
1616
/// - `Stop`: Stop visiting any more nodes in the traversal.
1717
/// - `Continue`: Continue with the traversal as expected.
18-
1918
#[derive(Debug, Clone, PartialEq, Eq)]
2019
pub enum TraversalOrder {
21-
// In a top-down traversal, skip visiting the children of the current node.
22-
// In the bottom-up phase of the traversal this does nothing (for now).
20+
/// In a top-down traversal, skip visiting the children of the current node.
21+
/// In the bottom-up phase of the traversal this does nothing (for now).
2322
Skip,
2423

25-
// Stop visiting any more nodes in the traversal.
24+
/// Stop visiting any more nodes in the traversal.
2625
Stop,
2726

28-
// Continue with the traversal as expected.
27+
/// Continue with the traversal as expected.
2928
Continue,
3029
}
3130

3231
#[derive(Debug, Clone)]
3332
pub struct TransformResult<T> {
34-
pub result: T,
33+
result: T,
3534
order: TraversalOrder,
3635
changed: bool,
3736
}
@@ -52,6 +51,10 @@ impl<T> TransformResult<T> {
5251
changed: false,
5352
}
5453
}
54+
55+
pub fn into_inner(self) -> T {
56+
self.result
57+
}
5558
}
5659

5760
pub trait NodeVisitor<'a> {
@@ -169,7 +172,7 @@ pub trait Node: Sized {
169172
}
170173

171174
impl Node for ExprRef {
172-
// A pre-order traversal.
175+
/// A pre-order traversal.
173176
fn accept<'a, V: NodeVisitor<'a, NodeTy = ExprRef>>(
174177
&'a self,
175178
visitor: &mut V,
@@ -216,7 +219,7 @@ impl Node for ExprRef {
216219
visitor.visit_up(self, context, children)
217220
}
218221

219-
// A post-order transform, with an option to ignore sub-tress (using visit_down).
222+
/// A post-order transform, with an option to ignore sub-tress (using visit_down).
220223
fn transform<V: MutNodeVisitor<NodeTy = Self>>(
221224
self,
222225
visitor: &mut V,

0 commit comments

Comments
 (0)