pub struct Scope { /* private fields */ }
Expand description
Scope define the evaluation context/scope that an expression uses when being evaluated.
There is a special Identifier
(Identity
) which is used to bind the initial array being evaluated
Other identifier can be bound with variables either before execution or while executing (see Let
).
Values can be extracted from the scope using the Var
expression.
<let x = lit(1) in var(Identifier::Identity) + var(x), { Identity -> Primitive[1,2,3]> ->
<var(Identifier::Identity) + var(x), { Identity -> Primitive[1,2,3], x -> ConstantArray(1)> ->
<Primitive[1,2,3] + var(x), { Identity -> Primitive[1,2,3], x -> ConstantArray(1)> ->
<Primitive[1,2,3] + ConstantArray(1), { Identity -> Primitive[1,2,3], x -> ConstantArray(1)> ->
<Primitive[2,3,4], { Identity -> Primitive[1,2,3], x -> ConstantArray(1)>
Other values can be bound before execution e.g.
<var("x") + var("y") + var("z"), x -> ..., y -> ..., z -> ...>
Implementations§
Source§impl Scope
impl Scope
pub fn new(arr: ArrayRef) -> Self
pub fn empty(len: usize) -> Self
Sourcepub fn array(&self, id: &Identifier) -> Option<&ArrayRef>
pub fn array(&self, id: &Identifier) -> Option<&ArrayRef>
Get a value out of the scope by its Identifier
pub fn vars(&self, id: Identifier) -> VortexResult<&Arc<dyn Any + Send + Sync>>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn copy_with_array(&self, ident: Identifier, value: ArrayRef) -> Self
Sourcepub fn with_array(self, ident: Identifier, value: ArrayRef) -> Self
pub fn with_array(self, ident: Identifier, value: ArrayRef) -> Self
Register an array with an identifier in the scope, overriding any existing value stored in it.
Sourcepub fn with_array_pair(self, (ident, value): ScopeElement) -> Self
pub fn with_array_pair(self, (ident, value): ScopeElement) -> Self
Register an array with an identifier in the scope, overriding any existing value stored in it.
pub fn with_var( self, ident: Identifier, var: Arc<dyn Any + Send + Sync>, ) -> Self
Sourcepub fn with_scope_var<V: ScopeVar>(self, var: V) -> Self
pub fn with_scope_var<V: ScopeVar>(self, var: V) -> Self
Returns a new evaluation scope with the given variable applied.
Sourcepub fn scope_var<V: ScopeVar>(&self) -> Option<&V>
pub fn scope_var<V: ScopeVar>(&self) -> Option<&V>
Returns the scope variable of type V
if it exists.
Sourcepub fn scope_var_mut<V: ScopeVar>(&mut self) -> Option<&mut V>
pub fn scope_var_mut<V: ScopeVar>(&mut self) -> Option<&mut V>
Returns the mutable scope variable of type V
if it exists.
pub fn iter(&self) -> impl Iterator<Item = (&Identifier, &ArrayRef)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scope
impl !RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl !UnwindSafe for Scope
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more