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.,
MemTable, producingRelValue::Projection,&'a [ProductValue]producingRelValue::ProjRef.
Required Associated Types§
sourcetype Source: 'a + IntoIterator<Item = RelValue<'a>>
type Source: 'a + IntoIterator<Item = RelValue<'a>>
The type of in-memory tables that this provider uses.
Required Methods§
sourcefn take_source(&mut self, id: SourceId) -> Option<Self::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.