In file relquery.h:

class RelOpDagBuilder

The RelOpDagBuilder class encapsulates the process of checking query semantics and structuring a query directed acyclic graph (DAG)

Inheritance:


Public Methods

XxxErrCode BuildQueryDag (RelViewClass *View, RelQueryNode *&Root)
Builds a query DAG, given a query view
RelOpDagBuilder (const RelQueryEngine *Engine)
Constructor
~RelOpDagBuilder ()
Destructor

Protected Fields

XxxValueExprList* Aggregates
All expressions referenced which contain an aggregate
int Arity
The number of source relations
XxxBool* Ascending
An array of booleans corresponding to the ordering expressions; XXX_TRUE if ascending
XxxBool DistinctSelection
XXX_TRUE if the selection is distinct
const RelQueryEngine* Engine
A handle on this relational query engine
XxxValueExprList* FinalProjection
The projection which must be applied at the final SPJ
XxxBool FinalSPJNeeded
XXX_TRUE if a final SPJ is needed to project out intermediate fields
XxxValueExprList* GroupByProjection
The group-by projection list
XxxValueExprList* Groupings
All group-by expressions
XxxBooleanExpression* GroupSelection
The having condition
XxxValueExprList* GrpSelExprsRef
All value expressions referenced in the HAVING clause
XxxValueExprList* InitProjection
The list of all items that must be projected from the query inputs
XxxValueExprList* Ordering
The ordering expressions
XxxBooleanExpression* Selection
The selection condition
XxxValueExprList* SelectionExprsRef
All value expressions referenced in the WHERE clause
RelInfo** SourceRelations
The source relations specified in the FROM clause
XxxValueExprList* UserProjection
The projection list specified by the query

Protected Methods

XxxErrCode AddFinalSPJNode (RelQueryNode *&Root)
Creates the final SPJ node over the current root, which is passed in
XxxErrCode AddGroupByNode (RelQueryNode *&Root)
Creates the group-by node over the current root, which is passed in
XxxErrCode AddImpliedProjections ()
The query may reference expressions that are not explicitly projected; In this case, these expressions must be added to the initial projection and a final projection must be formed to remove them later
XxxErrCode AddInitialSPJNode (RelQueryNode *&SPJNode, RelQueryNode **FromNodes)
Creates the initial SPJ node with the from nodes as inputs
XxxErrCode AddOrderByNode (RelQueryNode *&Root)
Creates the order-by node over the current root, which is passed in
XxxErrCode BuildFromNodes (RelQueryNode **&FromNodes)
Creates query nodes for each of the relational inputs
XxxErrCode CheckSemantics ()
Checks the semantics of the information extracted
XxxErrCode GetViewInfo (const RelViewClass *View)
Takes the query view information and organizes it
void PrintQueryDag (ostream &OStr)
Prints the Query DAG to the output stream
XxxErrCode ReorganizeInfo ()
Reorganizes the information, changing the "implied expressions" to explicit ones; e

Documentation

The RelOpDagBuilder class encapsulates the process of checking query semantics and structuring a query directed acyclic graph (DAG). It generates extra info which it uses to construct a DAG. Note that the redundant RelQueryEngine::ViewToOpDag function is needed since a RelOpDagBuilder is created for every view transformed--a process which can be recursively necessary if a View is a FROM argument. The query graph is structured in the following way: an initial SPJ (select-project-join) node is created which takes all the query inputs as its children. Its projection list is a superset of the actual projection list, including also those attributes necessary for intermediate operations, such as ordering on a non-projected field. If aggregates (with or without grouping) are specified, a Group-By operator is placed above. If ordering is supplied, an Order-by operator is placed above. Finally, if items were projected in which were used only for intermediate operators, a final SPJ operator is placed above which projects these fields out.
const RelQueryEngine* Engine
A handle on this relational query engine

XxxValueExprList* UserProjection
The projection list specified by the query

XxxValueExprList* InitProjection
The list of all items that must be projected from the query inputs

XxxValueExprList* GroupByProjection
The group-by projection list

XxxValueExprList* Groupings
All group-by expressions

XxxValueExprList* Aggregates
All expressions referenced which contain an aggregate

XxxBool FinalSPJNeeded
XXX_TRUE if a final SPJ is needed to project out intermediate fields

XxxValueExprList* FinalProjection
The projection which must be applied at the final SPJ

XxxBool DistinctSelection
XXX_TRUE if the selection is distinct

XxxBooleanExpression* Selection
The selection condition

XxxValueExprList* SelectionExprsRef
All value expressions referenced in the WHERE clause

RelInfo** SourceRelations
The source relations specified in the FROM clause

int Arity
The number of source relations

XxxBooleanExpression* GroupSelection
The having condition

XxxValueExprList* GrpSelExprsRef
All value expressions referenced in the HAVING clause

XxxValueExprList* Ordering
The ordering expressions

XxxBool* Ascending
An array of booleans corresponding to the ordering expressions; XXX_TRUE if ascending

XxxErrCode GetViewInfo(const RelViewClass *View)
Takes the query view information and organizes it
Returns:
XXX_OK if extraction worked.
Parameters:
View - The view to process

XxxErrCode ReorganizeInfo()
Reorganizes the information, changing the "implied expressions" to explicit ones; e.g., performs intermediate projections and gathers aggregates.
Returns:
XXX_OK if necessities were determined successfully.

XxxErrCode CheckSemantics()
Checks the semantics of the information extracted. This is where all semantic SQL rules, such as "you cannot group by if no aggregates are present", are enforced.
Returns:
XXX_OK if semantics were correct

XxxErrCode AddImpliedProjections()
The query may reference expressions that are not explicitly projected; In this case, these expressions must be added to the initial projection and a final projection must be formed to remove them later

void PrintQueryDag(ostream &OStr)
Prints the Query DAG to the output stream

XxxErrCode BuildFromNodes(RelQueryNode **&FromNodes)
Creates query nodes for each of the relational inputs
Returns:
XXX_OK if all from nodes could be constructed
Parameters:
FromNodes - (output) An array of (arity) query nodes based on the input relations

XxxErrCode AddInitialSPJNode(RelQueryNode *&SPJNode, RelQueryNode **FromNodes)
Creates the initial SPJ node with the from nodes as inputs
Returns:
XXX_OK if no errors occurred
Parameters:
FromNodes - (input) An array of (arity) query nodes based on the input relations
SPJNode - (output) The initial SPJ node

XxxErrCode AddGroupByNode(RelQueryNode *&Root)
Creates the group-by node over the current root, which is passed in
Returns:
XXX_OK if no errors occurred
Parameters:
Root - (input) the current root (output) the new root

XxxErrCode AddOrderByNode(RelQueryNode *&Root)
Creates the order-by node over the current root, which is passed in
Returns:
XXX_OK if no errors occurred
Parameters:
Root - (input) the current root (output) the new root

XxxErrCode AddFinalSPJNode(RelQueryNode *&Root)
Creates the final SPJ node over the current root, which is passed in
Returns:
XXX_OK if no errors occurred
Parameters:
Root - (input) the current root (output) the new root

RelOpDagBuilder(const RelQueryEngine *Engine)
Constructor
Parameters:
Engine - A handle on the relational engine

~RelOpDagBuilder()
Destructor

XxxErrCode BuildQueryDag(RelViewClass *View, RelQueryNode *&Root)
Builds a query DAG, given a query view. This function calls all of the other functions.
Returns:
XXX_OK if no errors occurred
Parameters:
View - The view to be transformed into a tree
Root - The root of the newly contructed tree


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de