pub struct Model {
    pub(crate) top_box: BoxId,
    boxes: HashMap<BoxId, Box<RefCell<QueryBox>>>,
    box_id_gen: Gen<BoxId>,
    quantifiers: HashMap<QuantifierId, Box<RefCell<Quantifier>>>,
    quantifier_id_gen: Gen<QuantifierId>,
}
Expand description

A Query Graph Model instance represents a SQL query. See the design doc for details.

In this representation, SQL queries are represented as a graph of operators, represented as boxes, that are connected via quantifiers. A top-level box represents the entry point of the query.

Each non-leaf box has a set of quantifiers, which are the inputs of the operation it represents. The quantifier adds information about how the relation represented by its input box is consumed by the parent box.

Fields§

§top_box: BoxId

The ID of the box representing the entry-point of the query.

§boxes: HashMap<BoxId, Box<RefCell<QueryBox>>>

All boxes in the query graph model.

§box_id_gen: Gen<BoxId>

Used for assigning unique IDs to query boxes.

§quantifiers: HashMap<QuantifierId, Box<RefCell<Quantifier>>>

All quantifiers in the query graph model.

§quantifier_id_gen: Gen<QuantifierId>

Used for assigning unique IDs to quantifiers.

Implementations§

Helper methods for the derivation of the RelationType attribute.

Infers a vector of ColumnType values for the columns of the given BoxId.

Note: this method should be used only internally in order to derive the RelationType attribute of a Model.

Infers a ColumnType corresponding to the given BoxScalarExpr used within the context of an enclosing BoxId.

Note: this method should be used only internally in order to derive the RelationType attribute of a Model.

Looks up a ColumnType corresponding to the given ColumnReference from the RelationType attribute of the input box, assuming the ColumnReference occurs within the context of the enclosing BoxId.

Note: this method should be used only internally in order to derive the RelationType attribute of a Model.

An iterator over immutable references to the QueryBox instances in this Model.

Get an immutable reference to the box identified by box_id bound to this Model.

Get a mutable reference to the box identified by box_id bound to this Model.

Create a new quantifier and adds it to the parent box

Get an immutable reference to the box identified by box_id bound to this Model.

Get a mutable reference to the box identified by box_id bound to this Model.

source

pub(crate) fn try_visit_pre_post<'a, F, G, E>(
    &'a self,
    pre: &mut F,
    post: &mut G
) -> Result<(), E>where
    F: FnMut(&Model, &BoxId) -> Result<(), E>,
    G: FnMut(&Model, &BoxId) -> Result<(), E>,

Traverse the entire graph using depth-first traversal.

The function pre runs on a parent QueryBox before it runs on any of its children. The function post runs on all children QueryBoxes before it runs on a parent.

source

pub(crate) fn try_visit_pre_post_descendants<'a, F, G, E>(
    &'a self,
    pre: &mut F,
    post: &mut G,
    root: BoxId
) -> Result<(), E>where
    F: FnMut(&Model, &BoxId) -> Result<(), E>,
    G: FnMut(&Model, &BoxId) -> Result<(), E>,

Traverse a subgraph using depth-first traversal starting at root.

The function pre runs on a parent QueryBox before it runs on any of its children. The function post runs on all children QueryBoxes before it runs on a parent.

source

pub(crate) fn try_visit_mut_pre_post<'a, F, G, E>(
    &'a mut self,
    pre: &mut F,
    post: &mut G
) -> Result<(), E>where
    F: FnMut(&mut Model, &BoxId) -> Result<(), E>,
    G: FnMut(&mut Model, &BoxId) -> Result<(), E>,

Same as Model::try_visit_pre_post, but permits mutating the model.

source

pub(crate) fn try_visit_mut_pre_post_descendants<'a, F, G, E>(
    &'a mut self,
    pre: &mut F,
    post: &mut G,
    root: BoxId
) -> Result<(), E>where
    F: FnMut(&mut Model, &BoxId) -> Result<(), E>,
    G: FnMut(&mut Model, &BoxId) -> Result<(), E>,

Same as Model::try_visit_pre_post_descendants, but permits mutating the model.

Removes unreferenced objects from the model.

May be invoked several times during query rewrites.

Renumbers all the boxes and quantifiers in the model starting from 0.

Intended to be called after Model::garbage_collect.

Renumbering the model does not save memory or improve the performance of traversing the model, but it does make the Dot graph easier to parse.

Validate a model with a default validator chain.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Wrap the input message T in a tonic::Request
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more