Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ibis::whereClause Class Reference

A representation of the where clause. More...

#include <whereClause.h>

Public Member Functions

void addConditions (const char *)
 Append a set of conditions to the existing where clause. More...
 
void addExpr (const ibis::qExpr *)
 Append a set of conditions to the existing where clause. More...
 
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. More...
 
ibis::qExprgetExpr (void)
 Return a pointer to the root of the expression tree for the where clause. More...
 
void getNullMask (const ibis::part &, ibis::bitvector &) const
 
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. More...
 
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. More...
 
 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. More...
 
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. More...
 

Protected Member Functions

void amplify (const ibis::part &)
 !< The expression tree. More...
 

Protected Attributes

std::string clause_
 
ibis::qExprexpr_
 !< String version of the where clause.
 

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.

The following operations on text fields are also supported. For the purpose of query composition, they can be tought of as alternative form of discrete ranges.

Member Function Documentation

void ibis::whereClause::addConditions ( const char *  cl)

Append a set of conditions to the existing where clause.

The new conditions are joined together with the existing ones with the AND operator.

Referenced by ibis::query::addConditions().

void ibis::whereClause::addExpr ( const ibis::qExpr ex)

Append a set of conditions to the existing where clause.

The new conditions are joined together with the existing ones with the AND operator.

Note
This object will have a copy of the incomping object.

References ibis::qExpr::dup().

Referenced by ibis::query::addConditions().

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

!< The expression tree.

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::qRange::leftBound(), ibis::qRange::restrictRange(), ibis::qRange::rightBound(), and ibis::qExpr::simplify().

const ibis::qExpr* ibis::whereClause::getExpr ( void  ) const
inline
ibis::qExpr* ibis::whereClause::getExpr ( void  )
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().

void ibis::whereClause::setExpr ( const ibis::qExpr ex)
inline

Assign a new set of conditions directly.

The new set of conditions is copied here.

References ibis::qExpr::dup(), and expr_.

Referenced by ibis::table::select(), ibis::countQuery::setWhereClause(), and ibis::query::setWhereClause().

int ibis::whereClause::verify ( const ibis::part part0,
const ibis::selectClause sel = 0 
) const

Verify that the names exist in the data partition.

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.

Referenced by ibis::query::addConditions(), 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 checks 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::qAnyString::colName(), ibis::qLike::colName(), ibis::math::term::dup(), ibis::math::variable::dup(), ibis::selectClause::find(), ibis::FLOAT, ibis::selectClause::getAggregator(), ibis::part::getColumn(), ibis::column::getDictionary(), ibis::qExpr::getLeft(), ibis::qExpr::getRight(), ibis::qExpr::getType(), ibis::qDiscreteRange::getValues(), ibis::column::isFloat(), ibis::column::isInteger(), ibis::qContinuousRange::leftBound(), ibis::part::name(), ibis::column::name(), ibis::util::readDouble(), ibis::util::readInt(), ibis::qContinuousRange::rightBound(), ibis::TEXT, ibis::column::type(), ibis::TYPESTRING, ibis::UBYTE, and ibis::UINT.


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