Skip to main content

VirtualValue

Enum VirtualValue 

Source
#[non_exhaustive]
pub enum VirtualValue { Materialized { value: Value, schema: Schema, }, Cached { key: CacheKey, schema: Schema, }, Deferred { producer_node_id: String, cache_key: CacheKey, schema: Schema, }, Stream { source_id: String, schema: Schema, }, }
Expand description

A lazy reference to a value that can be materialized on demand.

This is the core of Soma’s data virtualization. Instead of computing and storing every intermediate result, values are represented as references that carry enough information to:

  • Inspect schema without loading data
  • Check whether the data is already available
  • Compute it when needed

Like Denodo’s data virtualization, but for computation rather than SQL.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Materialized

Already computed and in memory. Ready to use.

Fields

§value: Value
§schema: Schema
§

Cached

Stored in cache (K/V store). Can be loaded on demand.

Fields

§schema: Schema
§

Deferred

Not computed yet. Carries the “recipe” to produce it: which node produces it, and what its cache key would be.

Fields

§producer_node_id: String
§cache_key: CacheKey
§schema: Schema
§

Stream

A stream that materializes chunk by chunk.

Fields

§source_id: String
§schema: Schema

Implementations§

Source§

impl VirtualValue

Source

pub fn materialized(value: Value) -> Self

Create a materialized value with auto-inferred schema.

Source

pub fn materialized_with_schema(value: Value, schema: Schema) -> Self

Create a materialized value with explicit schema.

Source

pub fn cached(key: CacheKey, schema: Schema) -> Self

Create a cached reference.

Source

pub fn deferred( producer_node_id: impl Into<String>, cache_key: CacheKey, schema: Schema, ) -> Self

Create a deferred (not yet computed) reference.

Source

pub fn schema(&self) -> &Schema

Get the schema without materializing the value.

Source

pub fn status(&self) -> ValueStatus

Get the current status.

Source

pub fn as_value(&self) -> Option<&Value>

Get the materialized value if already in memory.

Source

pub fn cache_key(&self) -> Option<&CacheKey>

Get the cache key (if this value is cached or deferred).

Source

pub fn try_load(&self, cache: &dyn CacheStore) -> Result<Option<Value>>

Materialize from a cache store. Returns the value if found, None if not cached.

Source

pub fn resolve(&self, cache: &dyn CacheStore) -> Result<Self>

Upgrade this reference: if Deferred, check cache; if Cached, load. Returns a new VirtualValue that may be closer to Materialized.

Trait Implementations§

Source§

impl Clone for VirtualValue

Source§

fn clone(&self) -> VirtualValue

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtualValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for VirtualValue

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for VirtualValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Value> for VirtualValue

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl Serialize for VirtualValue

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,