A representation of the where clause. More...
#include <whereClause.h>
Public Member Functions | |
void | clear () throw () |
Clear the existing content. | |
bool | empty () const |
The where clause is considered empty if the expr_ is a nil pointer. | |
const ibis::qExpr * | getExpr (void) const |
Return a pointer to the root of the expression tree for the where clause. | |
ibis::qExpr * | getExpr (void) |
Return a pointer to the root of the expression tree for the where clause. | |
const char * | getString (void) const |
Return a pointer to the string form of the where clause. | |
ibis::qExpr * | operator-> () |
Member access operator redefined to point to ibis::qExpr. | |
const ibis::qExpr * | operator-> () const |
Member access operator redefined to point to const ibis::qExpr. | |
whereClause & | operator= (const whereClause &) |
Assignment operator. | |
int | parse (const char *cl) |
Parse a new string. | |
void | resetString () |
Regenerate the string version of the query conditions. | |
void | setExpr (const ibis::qExpr *ex) |
Assign a new set of conditions directly. | |
void | simplify () |
Simplify the query expression. | |
void | swap (whereClause &rhs) throw () |
Swap the contents of two where clauses. | |
int | verify (const ibis::part &p0, const ibis::selectClause *sel=0) const |
Verify that the names exist in the data partition p0. | |
whereClause (const char *cl=0) | |
Construct a where clause from a string. | |
whereClause (const whereClause &) | |
Construct a where clause from another where clause. | |
~whereClause () | |
Destructor. | |
Static Public Member Functions | |
static int | removeAlias (ibis::qContinuousRange *&, const ibis::column *) |
Create a simple range expression as the replacement of the incoming oldr. | |
static int | verifyExpr (const ibis::qExpr *, const ibis::part &, const ibis::selectClause *) |
static int | verifyExpr (ibis::qExpr *&, const ibis::part &, const ibis::selectClause *) |
A function to verify an single query expression. | |
Protected Member Functions | |
void | amplify (const ibis::part &) |
Add conditions implied by self-join conditions. | |
Protected Attributes | |
std::string | clause_ |
String version of the where clause. | |
ibis::qExpr * | expr_ |
The expression tree. | |
Friends | |
class | ibis::whereParser |
A representation of the where clause.
It parses a string into an ibis::qExpr object. One may access the functions defined for ibis::qExpr through the operator->.
A where clause is a set of range conditions joined together with logical operators. The supported logical operators are
NOT, AND, OR, XOR, &&, ||.
The supported range conditions are equality conditions, discrete ranges, one-sided range conditions and two-sided range conditions.
column_name IN ( list_of_strings_or_numbers )
A between B and C
B <= A <= C
An arithematic expression may contain operators +, -, *, /, %, ^, and , as well as common one-argument and two-argument functions defined in the header file math.h. Both operators ^ and ** denote the exponential operation.
void ibis::whereClause::amplify | ( | const ibis::part & | part0 | ) | [protected] |
Add conditions implied by self-join conditions.
References ibis::math::term::eval(), ibis::qExpr::findRange(), ibis::column::getActualMax(), ibis::column::getActualMin(), ibis::part::getColumn(), ibis::qExpr::getLeft(), ibis::qExpr::getRight(), ibis::gVerbose, ibis::qRange::leftBound(), ibis::qRange::restrictRange(), ibis::qRange::rightBound(), and ibis::qExpr::simplify().
const ibis::qExpr* ibis::whereClause::getExpr | ( | void | ) | const [inline] |
Return a pointer to the root of the expression tree for the where clause.
References expr_.
Referenced by ibis::query::contractQuery(), ibis::query::countHits(), ibis::quaere::create(), ibis::query::estimate(), ibis::query::evaluate(), ibis::query::expandQuery(), ibis::query::getNumHits(), ibis::query::query(), ibis::query::setPartition(), ibis::query::setSelectClause(), ibis::countQuery::setWhereClause(), ibis::query::setWhereClause(), ibis::filter::sift(), ibis::filter::sift1(), ibis::filter::sift1S(), ibis::filter::sift2(), and ibis::filter::sift2S().
ibis::qExpr* ibis::whereClause::getExpr | ( | void | ) | [inline] |
Return a pointer to the root of the expression tree for the where clause.
References expr_.
int ibis::whereClause::removeAlias | ( | ibis::qContinuousRange *& | oldr, |
const ibis::column * | col | ||
) | [static] |
Create a simple range expression as the replacement of the incoming oldr.
It replaces the name of the column if the incoming expression uses an alias. It replaces the negative query boundaries with 0 for unsigned integer columns.
References ibis::column::isUnsignedInteger(), ibis::qContinuousRange::leftBound(), ibis::column::name(), and ibis::qContinuousRange::rightBound().
int ibis::whereClause::verify | ( | const ibis::part & | part0, |
const ibis::selectClause * | sel = 0 |
||
) | const |
Verify that the names exist in the data partition p0.
This function also simplifies the arithmetic expression if ibis::term::preserveInputExpression is not set and augment the expressions with implied conditions.
References ibis::qExpr::simplify().
Referenced by ibis::countQuery::setPartition(), ibis::query::setPartition(), ibis::countQuery::setWhereClause(), and ibis::query::setWhereClause().
int ibis::whereClause::verifyExpr | ( | ibis::qExpr *& | xp0, |
const ibis::part & | part0, | ||
const ibis::selectClause * | sel | ||
) | [static] |
A function to verify an single query expression.
This function check each variable name specified in the query expression to make sure they all appear as column names of the given data partition. It returns the number of names NOT in the data partition.
It also removes the aliases and simplifies certain query expressions. For example, it converts expressions of the form "string1 = string2" to string lookups when one of the strings is a name of a string-valued column.
References ibis::selectClause::aggExpr(), ibis::selectClause::aggSize(), ibis::CATEGORY, ibis::qContinuousRange::colName(), ibis::qDiscreteRange::colName(), ibis::qLike::colName(), ibis::qMultiString::colName(), ibis::math::term::dup(), ibis::math::variable::dup(), ibis::selectClause::find(), ibis::FLOAT, ibis::part::getColumn(), ibis::qExpr::getLeft(), ibis::qExpr::getRight(), ibis::qExpr::getType(), ibis::qDiscreteRange::getValues(), ibis::gVerbose, ibis::qContinuousRange::leftBound(), ibis::part::name(), ibis::qContinuousRange::rightBound(), ibis::TEXT, ibis::column::type(), and ibis::TYPESTRING.
![]() |