Trait spacetimedb_vm::expr::SourceProvider

source ·
pub trait SourceProvider<'a> {
    type Source: 'a + IntoIterator<Item = RelValue<'a>>;

    // Required method
    fn take_source(&mut self, id: SourceId) -> Option<Self::Source>;
}
Expand description

Types that relate SourceIds to their in-memory tables.

Rather than embedding tables in query plans, we store a SourceExpr::InMemory, which contains the information necessary for optimization along with a SourceId. Query execution then executes the plan, and when it encounters a SourceExpr::InMemory, retrieves the Self::Source table from the corresponding provider. This allows query plans to be re-used, though each execution might require a new provider.

An in-memory table Self::Source is a type capable of producing [RelValue<'a>]s. The general form of this is Iterator<Item = RelValue<'a>>. Depending on the situation, this could be e.g.,

Required Associated Types§

source

type Source: 'a + IntoIterator<Item = RelValue<'a>>

The type of in-memory tables that this provider uses.

Required Methods§

source

fn take_source(&mut self, id: SourceId) -> Option<Self::Source>

Retrieve the Self::Source associated with id, if any.

Taking the same id a second time may or may not yield the same source. Callers should not assume that a generic provider will yield it more than once. This means that a query plan may not include multiple references to the same SourceId.

Implementations are also not obligated to inspect id, e.g., if there’s only one option.

Implementations on Foreign Types§

source§

impl<'a, I: 'a + IntoIterator<Item = RelValue<'a>>> SourceProvider<'a> for Option<I>

§

type Source = I

source§

fn take_source(&mut self, _: SourceId) -> Option<Self::Source>

Implementors§

source§

impl<'a> SourceProvider<'a> for NoInMemUsed

§

type Source = Empty<RelValue<'a>>

source§

impl<'a, I: 'a + IntoIterator<Item = RelValue<'a>>, F: FnMut(SourceId) -> Option<I>> SourceProvider<'a> for F

§

type Source = I

source§

impl<'a, T: 'a + IntoIterator<Item = RelValue<'a>>, const N: usize> SourceProvider<'a> for SourceSet<T, N>

§

type Source = T