Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

The top level query expression object. More...

#include <qExpr.h>

Inheritance diagram for ibis::qExpr:
ibis::compRange ibis::deprecatedJoin ibis::math::term ibis::qAnyAny ibis::qLike ibis::qMultiString ibis::qRange ibis::qString

List of all members.

Classes

struct  TTN
 A data structure including a query expression and the list of table names mentioned in the expression. More...
struct  weight
 A functor to be used by the function reorder. More...

Public Types

enum  COMPARE {
  OP_UNDEFINED, OP_LT, OP_GT, OP_LE,
  OP_GE, OP_EQ
}
 Comparison operator supported in RANGE.
typedef std::vector< TTNtermTableList
enum  TYPE {
  LOGICAL_UNDEFINED, LOGICAL_NOT, LOGICAL_AND, LOGICAL_OR,
  LOGICAL_XOR, LOGICAL_MINUS, RANGE, DRANGE,
  STRING, MSTRING, COMPRANGE, MATHTERM,
  DEPRECATEDJOIN, TOPK, ANYANY, LIKE,
  INTHOD, UINTHOD
}
 Definition of node types. More...

Public Member Functions

bool directEval () const
 Can the expression be directly evaluated?
virtual qExprdup () const
void extractDeprecatedJoins (std::vector< const deprecatedJoin * > &) const
 Extract conjunctive terms of the deprecated joins.
qRangefindRange (const char *vname)
 Find the first range condition involving the named variable.
void getConjunctiveTerms (termTableList &) const
 Extract the top-level conjunctive terms.
const qExprgetLeft () const
 Return a const pointer to the left child.
qExpr *& getLeft ()
 Return a pointer to the left child.
qExpr *& getRight ()
 Return a pointer to the right child.
const qExprgetRight () const
 Return a const pointer to the right child.
virtual void getTableNames (std::set< std::string > &plist) const
 Identify the data partitions involved in the query expression.
TYPE getType () const
 Return the node type.
virtual bool isConstant () const
 Is this expression a constant? A constant remains the same not matter which row it is applied to.
virtual bool isSimple () const
 Is the expression simple? A simple expression contains only range conditions connected with logical operators.
bool isTerminal () const
 Is this expression a terminal node of an expression tree?
virtual uint32_t nItems () const
 Count the number of items in the query expression.
qExproperator= (const qExpr &rhs)
 Assignment operator.
virtual void print (std::ostream &) const
 Print out the node in the string form.
virtual void printFull (std::ostream &out) const
 Print out the full expression.
 qExpr (const qExpr &qe)
 Copy Constructor. Deep copy.
 qExpr (TYPE op)
 Construct a node of specified type. Not for implicit type conversion.
 qExpr ()
 Default constructor. It generates a node of undefined type.
 qExpr (TYPE op, qExpr *qe1, qExpr *qe2)
 Construct a full specified node.
double reorder (const weight &)
 Reorder the expressions tree.
int separateSimple (ibis::qExpr *&simple, ibis::qExpr *&tail) const
 Separate an expression tree into two connected with an AND operator.
void setLeft (qExpr *expr)
 Change the left child.
void setRight (qExpr *expr)
 Change the right child.
void swap (qExpr &rhs)
 Swap the content. No exception expected.
virtual ~qExpr ()
 Destructor.

Static Public Member Functions

static std::string extractTableName (const char *)
 Extract the data partition name from the column name cn.
static void simplify (ibis::qExpr *&)
 Attempt to simplify the query expressions.
static void splitColumnName (const char *, std::string &, std::string &)
 Split the incoming name into data partition name and column name.

Protected Member Functions

void adjust ()
 Adjust the tree to favor the sequential evaluation order.

Protected Attributes

qExprleft
qExprright
TYPE type

Detailed Description

The top level query expression object.

It encodes the logical operations between two child expressions, serving as the interior nodes of an expression tree. Leaf nodes are going to be derived later.


Member Enumeration Documentation

Definition of node types.

Logical operators are listed in the front and leaf node types are listed at the end.


Constructor & Destructor Documentation

ibis::qExpr::qExpr ( TYPE  op,
qExpr qe1,
qExpr qe2 
) [inline]

Construct a full specified node.

The ownership of qe1 and qe2 is transferred to the newly created object. The destructor of this object will delete qe1 and qe2, the user shall not delete them directly or indirectly through the destruction of another object. This constructor is primarily used by the parsers that compose query expressions, where the final query expression tree is passed to the user. This design allows the user to take control of the final query expression without directly managing any of the lower level nodes in the expression tree.

virtual ibis::qExpr::~qExpr ( ) [inline, virtual]

Destructor.

It recursively deletes the nodes of an expression tree. In other word, it owns the descendents it points to.


Member Function Documentation

void ibis::qExpr::adjust ( ) [protected]

Adjust the tree to favor the sequential evaluation order.

Make the expression tree lean left.

References adjust().

Referenced by adjust().

std::string ibis::qExpr::extractTableName ( const char *  cn) [static]

Extract the data partition name from the column name cn.

It looks for the first period '.' in the column name. If a period is found, the characters before the period is returned as a string, otherwise, an empty string is returned.

Note:
The data partition name will be outputed in lowercase characters.

Referenced by ibis::quaere::create(), ibis::qAnyAny::getTableNames(), ibis::qMultiString::getTableNames(), ibis::qRange::getTableNames(), ibis::math::variable::getTableNames(), ibis::qLike::getTableNames(), and ibis::qString::getTableNames().

void ibis::qExpr::getConjunctiveTerms ( termTableList &  ttl) const

Extract the top-level conjunctive terms.

If the top-most operator is not the AND operator, the whole expression tree is considered one term. Because this function may be called recursively, the argument ttl is not cleared by this function. The caller needs to make sure it is cleared on input.

Referenced by ibis::quaere::create().

qExpr*& ibis::qExpr::getLeft ( ) [inline]
qExpr*& ibis::qExpr::getRight ( ) [inline]
void ibis::qExpr::getTableNames ( std::set< std::string > &  plist) const [virtual]

Identify the data partitions involved in the query expression.

Return the list of data partition names in a set.

It records a '*' for the variables without explicit partition names.

Reimplemented in ibis::qRange, ibis::qString, ibis::qLike, ibis::qMultiString, ibis::math::variable, ibis::compRange, and ibis::qAnyAny.

Referenced by ibis::quaere::create().

virtual bool ibis::qExpr::isConstant ( ) const [inline, virtual]

Is this expression a constant? A constant remains the same not matter which row it is applied to.

Reimplemented in ibis::math::number, ibis::math::literal, and ibis::compRange.

Referenced by ibis::countQuery::doEstimate(), ibis::query::doEvaluate(), ibis::countQuery::doEvaluate(), ibis::query::doScan(), ibis::countQuery::doScan(), and simplify().

virtual bool ibis::qExpr::isSimple ( ) const [inline, virtual]

Is the expression simple? A simple expression contains only range conditions connected with logical operators.

Reimplemented in ibis::compRange.

void ibis::qExpr::print ( std::ostream &  out) const [virtual]
void ibis::qExpr::printFull ( std::ostream &  out) const [virtual]
double ibis::qExpr::reorder ( const weight wt)

Reorder the expressions tree.

After reordering, the lightest weight is one the left side of a group of commutable operators.

References directEval(), ibis::gVerbose, and reorder().

Referenced by reorder().

int ibis::qExpr::separateSimple ( ibis::qExpr *&  simple,
ibis::qExpr *&  tail 
) const

Separate an expression tree into two connected with an AND operator.

The terms that are simply range conditions are placed in simple, and the remaining conditions are left in tail.

It returns 0 if there is a mixture of simple and complex conditions. In this case, both simple and tail would be non-nil. The return value is -1 if all conditions are complex and 1 if all conditions are simple. In these two cases, both simple and tail are nil.

References ibis::gVerbose, and print().

void ibis::qExpr::setLeft ( qExpr expr) [inline]

Change the left child.

This object takes the ownership of expr. The user can not delete expr either directly or indirectly through the destruction of another object (other than this one, of course).

Referenced by ibis::quaere::create(), ibis::math::stdFunction2::dup(), ibis::math::stdFunction1::dup(), ibis::math::bediener::dup(), ibis::query::setWhereClause(), and simplify().

void ibis::qExpr::setRight ( qExpr expr) [inline]

Change the right child.

This object takes the ownership of expr. The user can not delete expr either directly or indirectly through the destruction of another object (other than this one, of course).

Referenced by ibis::quaere::create(), ibis::math::stdFunction2::dup(), ibis::math::bediener::dup(), ibis::query::setWhereClause(), and simplify().

void ibis::qExpr::simplify ( ibis::qExpr *&  expr) [static]

Attempt to simplify the query expressions.

Operations performed include converting compRanges into qRanges, qDiscreteRange into qContinuousRange, perform constant evaluations, combining pairs of inverse functions.

This is necessary because the parser always generates compRange instead of qRange. The goal of simplifying arithmetic expressions is to reduce the number of accesses to the variable values (potentially reducing the number of disk accesses).

Note:
Be aware that rearranging the arithmetic expressions may affect the round-off perperties of these expressions, and therefore affect their computed results. Even though the typical differences might be small (after ten significant digits), however, the differences could accumulated and became noticeable. To turn off this optimization, set ibis::math::preserveInputExpressions to true.

References ibis::math::term::eval(), getLeft(), getRight(), getType(), ibis::gVerbose, ibis::qContinuousRange::inRange(), isConstant(), ibis::compRange::makeConstantFalse(), ibis::math::preserveInputExpressions, print(), printFull(), ibis::math::term::reduce(), setLeft(), and setRight().

Referenced by ibis::whereClause::amplify(), ibis::whereClause::parse(), and ibis::whereClause::verify().

void ibis::qExpr::splitColumnName ( const char *  inm,
std::string &  pn,
std::string &  cn 
) [static]

Split the incoming name into data partition name and column name.

It looks for the first period '.' in the incoming name. If a period is found, the characters before the period is returned as pn, and the characters after the period is returned as cn. If no period is found, pn will be a blank string and cn will be a copy of inm.

Note:
Both output names will be in lower case only.

The documentation for this class was generated from the following files:

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive