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_value(&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.
pub fn with_var( self, ident: Identifier, var: Arc<dyn Any + Send + Sync>, ) -> Self
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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