Struct sql::query_model::Model[][src]

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

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.

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.

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.

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.

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

Performs the conversion.

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

Performs the conversion.

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

Performs the conversion.

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