pub enum Plan<T = Timestamp> {
Show 13 variants Constant { rows: Result<Vec<(Row, T, Diff)>, EvalError>, }, Get { id: Id, keys: AvailableCollections, plan: GetPlan, }, Let { id: LocalId, value: Box<Plan<T>>, body: Box<Plan<T>>, }, LetRec { ids: Vec<LocalId>, values: Vec<Plan<T>>, limits: Vec<Option<LetRecLimit>>, body: Box<Plan<T>>, }, Mfp { input: Box<Plan<T>>, mfp: MapFilterProject, input_key_val: Option<(Vec<MirScalarExpr>, Option<Row>)>, }, FlatMap { input: Box<Plan<T>>, func: TableFunc, exprs: Vec<MirScalarExpr>, mfp_after: MapFilterProject, input_key: Option<Vec<MirScalarExpr>>, }, Join { inputs: Vec<Plan<T>>, plan: JoinPlan, }, Reduce { input: Box<Plan<T>>, key_val_plan: KeyValPlan, plan: ReducePlan, input_key: Option<Vec<MirScalarExpr>>, }, TopK { input: Box<Plan<T>>, top_k_plan: TopKPlan, }, Negate { input: Box<Plan<T>>, }, Threshold { input: Box<Plan<T>>, threshold_plan: ThresholdPlan, }, Union { inputs: Vec<Plan<T>>, consolidate_output: bool, }, ArrangeBy { input: Box<Plan<T>>, forms: AvailableCollections, input_key: Option<Vec<MirScalarExpr>>, input_mfp: MapFilterProject, },
}
Expand description

A rendering plan with as much conditional logic as possible removed.

Variants§

§

Constant

Fields

§rows: Result<Vec<(Row, T, Diff)>, EvalError>

Explicit update triples for the collection.

A collection containing a pre-determined collection.

§

Get

Fields

§id: Id

A global or local identifier naming the collection.

§keys: AvailableCollections

Arrangements that will be available.

The collection will also be loaded if available, which it will not be for imported data, but which it may be for locally defined data.

§plan: GetPlan

The actions to take when introducing the collection.

A reference to a bound collection.

This is commonly either an external reference to an existing source or maintained arrangement, or an internal reference to a Let identifier.

§

Let

Fields

§id: LocalId

The local identifier to be used, available to body as Id::Local(id).

§value: Box<Plan<T>>

The collection that should be bound to id.

§body: Box<Plan<T>>

The collection that results, which is allowed to contain Get stages that reference Id::Local(id).

Binds value to id, and then results in body with that binding.

This stage has the effect of sharing value across multiple possible uses in body, and is the only mechanism we have for sharing collection information across parts of a dataflow.

The binding is not available outside of body.

§

LetRec

Fields

§ids: Vec<LocalId>

The local identifiers to be used, available to body as Id::Local(id).

§values: Vec<Plan<T>>

The collection that should be bound to id.

§limits: Vec<Option<LetRecLimit>>

Maximum number of iterations. See further info on the MIR LetRec.

§body: Box<Plan<T>>

The collection that results, which is allowed to contain Get stages that reference Id::Local(id).

Binds values to ids, evaluates them potentially recursively, and returns body.

All bindings are available to all bindings, and to body. The contents of each binding are initially empty, and then updated through a sequence of iterations in which each binding is updated in sequence, from the most recent values of all bindings.

§

Mfp

Fields

§input: Box<Plan<T>>

The input collection.

§mfp: MapFilterProject

Linear operator to apply to each record.

§input_key_val: Option<(Vec<MirScalarExpr>, Option<Row>)>

Whether the input is from an arrangement, and if so, whether we can seek to a specific value therein

Map, Filter, and Project operators.

This stage contains work that we would ideally like to fuse to other plan stages, but for practical reasons cannot. For example: reduce, threshold, and topk stages are not able to absorb this operator.

§

FlatMap

Fields

§input: Box<Plan<T>>

The input collection.

§func: TableFunc

The variable-record emitting function.

§exprs: Vec<MirScalarExpr>

Expressions that for each row prepare the arguments to func.

§mfp_after: MapFilterProject

Linear operator to apply to each record produced by func.

§input_key: Option<Vec<MirScalarExpr>>

The particular arrangement of the input we expect to use, if any

A variable number of output records for each input record.

This stage is a bit of a catch-all for logic that does not easily fit in map stages. This includes table valued functions, but also functions of multiple arguments, and functions that modify the sign of updates.

This stage allows a MapFilterProject operator to be fused to its output, and this can be very important as otherwise the output of func is just appended to the input record, for as many outputs as it has. This has the unpleasant default behavior of repeating potentially large records that are being unpacked, producing quadratic output in those cases. Instead, in these cases use a mfp member that projects away these large fields.

§

Join

Fields

§inputs: Vec<Plan<T>>

An ordered list of inputs that will be joined.

§plan: JoinPlan

Detailed information about the implementation of the join.

This includes information about the implementation strategy, but also any map, filter, project work that we might follow the join with, but potentially pushed down into the implementation of the join.

A multiway relational equijoin, with fused map, filter, and projection.

This stage performs a multiway join among inputs, using the equality constraints expressed in plan. The plan also describes the implementation strategy we will use, and any pushed down per-record work.

§

Reduce

Fields

§input: Box<Plan<T>>

The input collection.

§key_val_plan: KeyValPlan

A plan for changing input records into key, value pairs.

§plan: ReducePlan

A plan for performing the reduce.

The implementation of reduction has several different strategies based on the properties of the reduction, and the input itself. Please check out the documentation for this type for more detail.

§input_key: Option<Vec<MirScalarExpr>>

The particular arrangement of the input we expect to use, if any

Aggregation by key.

§

TopK

Fields

§input: Box<Plan<T>>

The input collection.

§top_k_plan: TopKPlan

A plan for performing the Top-K.

The implementation of reduction has several different strategies based on the properties of the reduction, and the input itself. Please check out the documentation for this type for more detail.

Key-based “Top K” operator, retaining the first K records in each group.

§

Negate

Fields

§input: Box<Plan<T>>

The input collection.

Inverts the sign of each update.

§

Threshold

Fields

§input: Box<Plan<T>>

The input collection.

§threshold_plan: ThresholdPlan

A plan for performing the threshold.

The implementation of reduction has several different strategies based on the properties of the reduction, and the input itself. Please check out the documentation for this type for more detail.

Filters records that accumulate negatively.

Although the operator suppresses updates, it is a stateful operator taking resources proportional to the number of records with non-zero accumulation.

§

Union

Fields

§inputs: Vec<Plan<T>>

The input collections

§consolidate_output: bool

Whether to consolidate the output, e.g., cancel negated records.

Adds the contents of the input collections.

Importantly, this is multiset union, so the multiplicities of records will add. This is in contrast to set union, where the multiplicities would be capped at one. A set union can be formed with Union followed by Reduce implementing the “distinct” operator.

§

ArrangeBy

Fields

§input: Box<Plan<T>>

The input collection.

§forms: AvailableCollections

A list of arrangement keys, and possibly a raw collection, that will be added to those of the input.

If any of these collection forms are already present in the input, they have no effect.

§input_key: Option<Vec<MirScalarExpr>>

The key that must be used to access the input.

§input_mfp: MapFilterProject

The MFP that must be applied to the input.

The input plan, but with additional arrangements.

This operator does not change the logical contents of input, but ensures that certain arrangements are available in the results. This operator can be important for e.g. the Join stage which benefits from multiple arrangements or to cap a Plan so that indexes can be exported.

Implementations§

source§

impl<T> Plan<T>

source

pub fn children_mut(&mut self) -> impl Iterator<Item = &mut Self>

Iterates through mutable references to child expressions.

source§

impl Plan

source

pub fn pretty(&self) -> String

Pretty-print this Plan to a string.

source

pub fn explain( &self, config: &ExplainConfig, humanizer: Option<&dyn ExprHumanizer> ) -> String

Pretty-print this Plan to a string using a custom ExplainConfig and an optionally provided ExprHumanizer.

source§

impl<T: Timestamp> Plan<T>

source

pub fn arrange_by( self, collections: AvailableCollections, old_collections: &AvailableCollections, arity: usize ) -> Self

Replace the plan with another one that has the collection in some additional forms.

source

fn from_mir( expr: &MirRelationExpr, arrangements: &mut BTreeMap<Id, AvailableCollections>, debug_info: LirDebugInfo<'_> ) -> Result<(Self, AvailableCollections), String>

This method converts a MirRelationExpr into a plan that can be directly rendered.

The rough structure is that we repeatedly extract map/filter/project operators from each expression we see, bundle them up as a MapFilterProject object, and then produce a plan for the combination of that with the next operator.

The method takes as an argument the existing arrangements for each bound identifier, which it will locally add to and remove from for Let bindings (by the end of the call it should contain the same bindings as when it started).

The result of the method is both a Plan, but also a list of arrangements that are certain to be produced, which can be relied on by the next steps in the plan. Each of the arrangement keys is associated with an MFP that must be applied if that arrangement is used, to back out the permutation associated with that arrangement.

An empty list of arrangement keys indicates that only a Collection stream can be assumed to exist.

source

fn from_mir_stack_safe( expr: &MirRelationExpr, arrangements: &mut BTreeMap<Id, AvailableCollections>, debug_info: LirDebugInfo<'_> ) -> Result<(Self, AvailableCollections), String>

source

pub fn finalize_dataflow( desc: DataflowDescription<OptimizedMirRelationExpr>, enable_consolidate_after_union_negate: bool, enable_monotonic_oneshot_selects: bool ) -> Result<DataflowDescription<Self>, String>

Convert the dataflow description into one that uses render plans.

source

fn lower_dataflow( desc: DataflowDescription<OptimizedMirRelationExpr> ) -> Result<DataflowDescription<Self>, String>

Lowers the dataflow description from MIR to LIR. To this end, the method collects all available arrangements and based on this information creates plans for every object to be built for the dataflow.

source

fn refine_source_mfps(dataflow: &mut DataflowDescription<Self>)

Refines the source instance descriptions for sources imported by dataflow to push down common MFP expressions.

source

fn refine_union_negate_consolidation(dataflow: &mut DataflowDescription<Self>)

Changes the consolidate_output flag of such Unions that have at least one Negated input.

source

fn refine_single_time_operator_selection( dataflow: &mut DataflowDescription<Self> )

Refines the plans of objects to be built as part of dataflow to take advantage of monotonic operators if the dataflow refers to a single-time, i.e., is for a one-shot SELECT query.

source

fn refine_single_time_consolidation( dataflow: &mut DataflowDescription<Self>, config: &TransformConfig ) -> Result<(), String>

Refines the plans of objects to be built as part of a single-time dataflow to relax the setting of the must_consolidate attribute of monotonic operators, if necessary, whenever the input is deemed to be physically monotonic.

source

pub fn partition_among(self, parts: usize) -> Vec<Self>

Partitions the plan into parts many disjoint pieces.

This is used to partition Plan::Constant stages so that the work can be distributed across many workers.

Trait Implementations§

source§

impl Arbitrary for Plan

§

type Strategy = BoxedStrategy<Plan<Timestamp>>

The type of Strategy used to generate values of type Self.
§

type Parameters = ()

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
source§

fn arbitrary_with(_: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
source§

impl<T: Clone> Clone for Plan<T>

source§

fn clone(&self) -> Plan<T>

Returns a copy 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<T> CollectionPlan for Plan<T>

source§

fn depends_on_into(&self, out: &mut BTreeSet<GlobalId>)

Collects the set of global identifiers from dataflows referenced in Get.
source§

fn depends_on(&self) -> BTreeSet<GlobalId, Global>

Returns the set of global identifiers from dataflows referenced in Get. Read more
source§

impl<T: Debug> Debug for Plan<T>

source§

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

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

impl<'de, T> Deserialize<'de> for Plan<T>where T: Deserialize<'de>,

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 DisplayText<PlanRenderingContext<'_, Plan<Timestamp>>> for Plan

source§

fn fmt_text( &self, f: &mut Formatter<'_>, ctx: &mut PlanRenderingContext<'_, Plan> ) -> Result

source§

impl<T: PartialEq> PartialEq<Plan<T>> for Plan<T>

source§

fn eq(&self, other: &Plan<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RustType<ProtoPlan> for Plan

source§

fn into_proto(&self) -> ProtoPlan

Convert a Self into a Proto value.
source§

fn from_proto(proto: ProtoPlan) -> Result<Self, TryFromProtoError>

Consume and convert a Proto back into a Self value. Read more
source§

impl<T> Serialize for Plan<T>where T: Serialize,

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

impl<T: Eq> Eq for Plan<T>

source§

impl<T> StructuralEq for Plan<T>

source§

impl<T> StructuralPartialEq for Plan<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Plan<T>where T: RefUnwindSafe,

§

impl<T> Send for Plan<T>where T: Send,

§

impl<T> Sync for Plan<T>where T: Sync,

§

impl<T> Unpin for Plan<T>where T: Unpin,

§

impl<T> UnwindSafe for Plan<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for Twhere T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Pointable for T

source§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ProgressEventTimestamp for Twhere T: Data + Debug + Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Upcasts this ProgressEventTimestamp to Any. Read more
source§

fn type_name(&self) -> &'static str

Returns the name of the concrete type of this object. Read more
source§

impl<P, R> ProtoType<R> for Pwhere R: RustType<P>,

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> Data for Twhere T: Clone + 'static,

source§

impl<T> Data for Twhere T: Send + Sync + Any + Serialize + for<'a> Deserialize<'a> + 'static,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> ExchangeData for Twhere T: Data + Data,