Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
ibis::whereClause Class Reference

A representation of the where clause. More...

#include <whereClause.h>

List of all members.

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::qExprgetExpr (void) const
 Return a pointer to the root of the expression tree for the where clause.
ibis::qExprgetExpr (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::qExproperator-> ()
 Member access operator redefined to point to ibis::qExpr.
const ibis::qExproperator-> () const
 Member access operator redefined to point to const ibis::qExpr.
whereClauseoperator= (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::qExprexpr_
 The expression tree.

Friends

class ibis::whereParser

Detailed Description

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.

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.

Note:
Operators & and | are reserved for bitwise logical operations within an arithmetic expression, while && and || are for logical operations between query conditions.

Member Function Documentation

void ibis::whereClause::amplify ( const ibis::part part0) [protected]

Add conditions implied by self-join conditions.

Note:
This name is intentionally vague to discourage its use. It might be completely removed in a later release.

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.

Note:
Functions that modify this object may invalidate the pointer returned by this function.

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.

Note:
The select clause is provided to make the aliases defined there available to the where clause.
Simplifying the arithmetic expressions typically reduces the time needed for evaluations, but may introduces a different set of round-off erros in the evaluation process than the original expression.

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.


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