Struct Scope

Source
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

Source

pub fn new(arr: ArrayRef) -> Self

Source

pub fn empty(len: usize) -> Self

Source

pub fn array(&self, id: &Identifier) -> Option<&ArrayRef>

Get a value out of the scope by its Identifier

Source

pub fn vars(&self, id: Identifier) -> VortexResult<&Arc<dyn Any + Send + Sync>>

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn copy_with_array(&self, ident: Identifier, value: ArrayRef) -> Self

Source

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.

Source

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.

Source

pub fn with_var( self, ident: Identifier, var: Arc<dyn Any + Send + Sync>, ) -> Self

Source

pub fn with_scope_var<V: ScopeVar>(self, var: V) -> Self

Returns a new evaluation scope with the given variable applied.

Source

pub fn scope_var<V: ScopeVar>(&self) -> Option<&V>

Returns the scope variable of type V if it exists.

Source

pub fn scope_var_mut<V: ScopeVar>(&mut self) -> Option<&mut V>

Returns the mutable scope variable of type V if it exists.

Source

pub fn iter(&self) -> impl Iterator<Item = (&Identifier, &ArrayRef)>

Trait Implementations§

Source§

impl Clone for Scope

Source§

fn clone(&self) -> Scope

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Scope

Source§

fn default() -> Scope

Returns the “default value” for a type. Read more
Source§

impl From<&Scope> for ScopeDType

Source§

fn from(ctx: &Scope) -> Self

Converts to this type from the input type.
Source§

impl From<Arc<dyn Array>> for Scope

Source§

fn from(value: ArrayRef) -> Self

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> ExprSerializable for T