pub enum BoundExpression {
Scalar {
dtype: DType,
scalar_fn: ScalarFnRef,
children: Arc<Vec<BoundExpression>>,
},
Root {
dtype: DType,
},
}Expand description
An expression that has been type-checked against a scope’s root dtype.
Every node carries its own dtype, so reading one is a field access rather than a walk of the
subtree. Holding a BoundExpression is proof that the whole tree type-checked.
Binding is purely logical: it deals only in DTypes and never sees an array, a length, or an
encoding.
Variants§
Scalar
A scalar function applied to bound children.
Fields
scalar_fn: ScalarFnRefThe scalar function for this node.
children: Arc<Vec<BoundExpression>>The bound children, in argument order.
Sharing keeps clones cheap even though the iterative Drop implementation prevents
consumers from destructuring a BoundExpression by value.
Root
The scope itself. Its dtype is the scope’s root dtype.
Implementations§
Source§impl BoundExpression
impl BoundExpression
Sourcepub fn new_root(dtype: DType) -> BoundExpression
pub fn new_root(dtype: DType) -> BoundExpression
Create a bound root expression with the given dtype.
Sourcepub fn try_new(
scalar_fn: ScalarFnRef,
children: impl IntoIterator<Item = BoundExpression>,
) -> Result<BoundExpression, VortexError>
pub fn try_new( scalar_fn: ScalarFnRef, children: impl IntoIterator<Item = BoundExpression>, ) -> Result<BoundExpression, VortexError>
Create a bound scalar node from a scalar function and already-bound children.
Sourcepub fn with_children(
self,
children: impl IntoIterator<Item = BoundExpression>,
) -> Result<BoundExpression, VortexError>
pub fn with_children( self, children: impl IntoIterator<Item = BoundExpression>, ) -> Result<BoundExpression, VortexError>
Rebuild this node with new bound children, recomputing its dtype.
Sourcepub fn detach_identity(&self) -> BoundExpression
pub fn detach_identity(&self) -> BoundExpression
Returns a copy of this node with a fresh top-level children allocation, preserving its scalar function, dtype, and child subtrees.
Caches keyed by WeakBoundExprKey use this when a cached output expression would
otherwise reuse the key’s own children allocation and keep its weak key alive forever.
Sourcepub fn children(&self) -> &[BoundExpression]
pub fn children(&self) -> &[BoundExpression]
The bound children of this node, in argument order. Empty for BoundExpression::Root.
Sourcepub fn child(&self, index: usize) -> &BoundExpression
pub fn child(&self, index: usize) -> &BoundExpression
Return the child at index.
Sourcepub fn as_scalar(&self) -> Option<&ScalarFnRef>
pub fn as_scalar(&self) -> Option<&ScalarFnRef>
The scalar function for this node, or None if it is the scope root.
Sourcepub fn is<V>(&self) -> boolwhere
V: ScalarFnVTable,
pub fn is<V>(&self) -> boolwhere
V: ScalarFnVTable,
Return whether this node uses the given scalar-function vtable.
Sourcepub fn contains<V>(&self) -> Result<bool, VortexError>where
V: ScalarFnVTable,
pub fn contains<V>(&self) -> Result<bool, VortexError>where
V: ScalarFnVTable,
Return whether this expression tree contains a node using the given scalar-function vtable.
Sourcepub fn literal(value: Scalar) -> BoundExpression
pub fn literal(value: Scalar) -> BoundExpression
Create a bound literal node.
Sourcepub fn as_opt<V>(&self) -> Option<&<V as ScalarFnVTable>::Options>where
V: ScalarFnVTable,
pub fn as_opt<V>(&self) -> Option<&<V as ScalarFnVTable>::Options>where
V: ScalarFnVTable,
Return the typed scalar-function options when this node uses the given vtable.
Sourcepub fn as_<V>(&self) -> &<V as ScalarFnVTable>::Optionswhere
V: ScalarFnVTable,
pub fn as_<V>(&self) -> &<V as ScalarFnVTable>::Optionswhere
V: ScalarFnVTable,
Return the typed scalar-function options for this node.
§Panics
Panics when this node is the scope root or uses a different scalar-function vtable.
Sourcepub fn is_root_bound_to(&self, dtype: &DType) -> bool
pub fn is_root_bound_to(&self, dtype: &DType) -> bool
Return whether every scope root in this expression has dtype.
Expressions without a scope root, such as literals, match every dtype.
Sourcepub fn validity(&self) -> Result<BoundExpression, VortexError>
pub fn validity(&self) -> Result<BoundExpression, VortexError>
Returns a new expression representing the validity mask output of this expression.
Returned expression evaluates to a non-nullable boolean array. When scalar function’s validity is irreducible, returns “is_not_null(self)”, which requires evaluating “self”.
Sourcepub fn display_tree(&self) -> impl Display
pub fn display_tree(&self) -> impl Display
Display the bound expression as a formatted tree structure.
Source§impl BoundExpression
impl BoundExpression
Sourcepub fn optimize(&self) -> Result<BoundExpression, VortexError>
pub fn optimize(&self) -> Result<BoundExpression, VortexError>
Optimize the root expression node only, iterating to convergence.
This applies optimization rules repeatedly until no more changes occur:
simplify- scalar-function simplifications over the nodereduce- abstract reduction rules viaReduceNode
Sourcepub fn optimize_recursive(&self) -> Result<BoundExpression, VortexError>
pub fn optimize_recursive(&self) -> Result<BoundExpression, VortexError>
Optimize the entire expression tree recursively.
Optimizes children first (bottom-up), then optimizes the root.
Sourcepub fn try_optimize_recursive(
&self,
) -> Result<Option<BoundExpression>, VortexError>
pub fn try_optimize_recursive( &self, ) -> Result<Option<BoundExpression>, VortexError>
Try to optimize the entire expression tree recursively.
Trait Implementations§
Source§impl BoundExpressionPruneExt for BoundExpression
impl BoundExpressionPruneExt for BoundExpression
Source§fn falsify(
&self,
session: &VortexSession,
) -> VortexResult<Option<BoundExpression>>
fn falsify( &self, session: &VortexSession, ) -> VortexResult<Option<BoundExpression>>
Source§fn satisfy(
&self,
session: &VortexSession,
) -> VortexResult<Option<BoundExpression>>
fn satisfy( &self, session: &VortexSession, ) -> VortexResult<Option<BoundExpression>>
Source§impl Clone for BoundExpression
impl Clone for BoundExpression
Source§fn clone(&self) -> BoundExpression
fn clone(&self) -> BoundExpression
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundExpression
impl Debug for BoundExpression
Source§impl Display for BoundExpression
impl Display for BoundExpression
Source§impl DisplayTreeNode for BoundExpression
impl DisplayTreeNode for BoundExpression
Source§fn tree_children(&self) -> &[BoundExpression]
fn tree_children(&self) -> &[BoundExpression]
Source§impl Drop for BoundExpression
Iterative drop to avoid stack overflows on deep trees.
impl Drop for BoundExpression
Iterative drop to avoid stack overflows on deep trees.
impl Eq for BoundExpression
Source§impl ExactKey for BoundExpression
impl ExactKey for BoundExpression
Source§fn identity(&self) -> ExactIdentity<'_>
fn identity(&self) -> ExactIdentity<'_>
Source§impl ExprDisplay for BoundExpression
impl ExprDisplay for BoundExpression
Source§fn display_child(&self, index: usize) -> &dyn ExprDisplay
fn display_child(&self, index: usize) -> &dyn ExprDisplay
index.Source§fn display_children_count(&self) -> usize
fn display_children_count(&self) -> usize
Source§impl Hash for BoundExpression
impl Hash for BoundExpression
Source§impl Node for BoundExpression
impl Node for BoundExpression
Source§fn apply_children<'a, F: FnMut(&'a Self) -> VortexResult<TraversalOrder>>(
&'a self,
f: F,
) -> VortexResult<TraversalOrder>
fn apply_children<'a, F: FnMut(&'a Self) -> VortexResult<TraversalOrder>>( &'a self, f: F, ) -> VortexResult<TraversalOrder>
f to them. Read moreSource§fn map_children<F: FnMut(Self) -> VortexResult<Transformed<Self>>>(
self,
f: F,
) -> VortexResult<Transformed<Self>>
fn map_children<F: FnMut(Self) -> VortexResult<Transformed<Self>>>( self, f: F, ) -> VortexResult<Transformed<Self>>
f to them. Read moreSource§fn iter_children<T>(
&self,
f: impl FnOnce(&mut dyn Iterator<Item = &Self>) -> T,
) -> T
fn iter_children<T>( &self, f: impl FnOnce(&mut dyn Iterator<Item = &Self>) -> T, ) -> T
Source§fn children_count(&self) -> usize
fn children_count(&self) -> usize
Source§impl PartialEq for BoundExpression
impl PartialEq for BoundExpression
impl StructuralPartialEq for BoundExpression
Auto Trait Implementations§
impl !RefUnwindSafe for BoundExpression
impl !UnwindSafe for BoundExpression
impl Forget for BoundExpression
impl Freeze for BoundExpression
impl Move for BoundExpression
impl Send for BoundExpression
impl Sync for BoundExpression
impl Unpin for BoundExpression
impl UnsafeUnpin for BoundExpression
Blanket Implementations§
impl<A> Annotation for A
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> NodeExt for Twhere
T: Node,
impl<T> NodeExt for Twhere
T: Node,
Source§fn rewrite<R: NodeRewriter<NodeTy = Self>>(
self,
rewriter: &mut R,
) -> VortexResult<Transformed<Self>>
fn rewrite<R: NodeRewriter<NodeTy = Self>>( self, rewriter: &mut R, ) -> VortexResult<Transformed<Self>>
Source§fn accept<'a, V: NodeVisitor<'a, NodeTy = Self>>(
&'a self,
visitor: &mut V,
) -> VortexResult<TraversalOrder>
fn accept<'a, V: NodeVisitor<'a, NodeTy = Self>>( &'a self, visitor: &mut V, ) -> VortexResult<TraversalOrder>
Source§fn transform_down<F: FnMut(Self) -> VortexResult<Transformed<Self>>>(
self,
f: F,
) -> VortexResult<Transformed<Self>>
fn transform_down<F: FnMut(Self) -> VortexResult<Transformed<Self>>>( self, f: F, ) -> VortexResult<Transformed<Self>>
Source§fn fold_context<R, F: NodeFolderContext<NodeTy = Self, Result = R>>(
self,
ctx: &F::Context,
folder: &mut F,
) -> VortexResult<FoldUp<R>>
fn fold_context<R, F: NodeFolderContext<NodeTy = Self, Result = R>>( self, ctx: &F::Context, folder: &mut F, ) -> VortexResult<FoldUp<R>>
NodeFolderContext to the Node tree, with an initial Context.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.