Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ibis::countQuery Class Reference

A simple count query. More...

#include <countQuery.h>

Public Member Functions

void clear ()
 Releases the resources held by the query object and re-initialize the select clause and the where clause to blank. More...
 
 countQuery (const part *et=0, const ibis::selectClause *s=0)
 Constructor. Generates a new countQuery on the data partition et.
 
int estimate ()
 Functions to perform estimation. More...
 
int evaluate ()
 Computes the exact hits. More...
 
const ibis::bitvectorgetCandVector () const
 Return the pointer to the candidates vector. More...
 
long getHitRows (std::vector< uint32_t > &rids) const
 Get the row numbers of the hits. More...
 
const ibis::bitvectorgetHitVector () const
 Return the pointer to the internal hit vector. More...
 
long getMaxNumHits () const
 Return the number of records in the upper bound.
 
long getMinNumHits () const
 Return the number of records in the lower bound.
 
long getNumHits () const
 Return the number of records in the exact solution. More...
 
const partgetPartition () const
 Return the pointer to the data partition used to process the count.
 
const selectClausegetSelectClause () const
 Return the pointer to the select clause.
 
const char * getWhereClause () const
 Return the where clause string.
 
int setPartition (const ibis::part *tbl)
 Resets the data partition used to evaluate the query conditions to the partition specified in the argument. More...
 
int setSelectClause (const ibis::selectClause *s)
 Change the select clause.
 
int setWhereClause (const char *str)
 Specify the where clause in string form. More...
 
int setWhereClause (const ibis::qExpr *)
 Specify the where clause in the form of a qExpr object. More...
 
virtual ~countQuery ()
 Destructor.
 

Protected Member Functions

void doEstimate (const qExpr *term, ibis::bitvector &low, ibis::bitvector &high) const
 !< Candidate query results. More...
 
int doEvaluate (const qExpr *term, const ibis::bitvector &mask, ibis::bitvector &hits) const
 Evaluate one term of a query expression.
 
int doScan (const ibis::qExpr *term, const ibis::bitvector &mask, ibis::bitvector &ht) const
 Evaluate one term using the base data.
 

Protected Attributes

ibis::bitvectorcand
 !< Solution in bitvector form (or lower bound)
 
whereClause conds
 
ibis::bitvectorhits
 !< Select clause.
 
const selectClausem_sel
 !< Data partition used to process the query.
 
const partmypart
 !< Query conditions.
 

Detailed Description

A simple count query.

A count query is a special form of the SQL select statement, where the select clause is "count(*)". This data structure is much simpler than ibis::query because it does not produce an identifier for itself and does not ever attempt to record the status of the query. However, it does accept the same where clause as ibis::query. In addition, it may take a select clause to provide definitions of aliases in the where clause.

Member Function Documentation

void ibis::countQuery::clear ( )

Releases the resources held by the query object and re-initialize the select clause and the where clause to blank.

Referenced by ~countQuery().

void ibis::countQuery::doEstimate ( const qExpr term,
ibis::bitvector low,
ibis::bitvector high 
) const
protected

!< Candidate query results.

Attempt to estimate the number of hits based on indexes.

Estimate one term of a query expression.

Interpret a null expression as satisfy everything to allow empty where clause to follow the SQL standard.

References ibis::bitvector::bytes(), ibis::bitvector::clear(), ibis::bitvector::cnt(), ibis::qExists::colName(), ibis::bitvector::copy(), ibis::bitvector::flip(), ibis::qExpr::getLeft(), ibis::qExpr::getRight(), ibis::qExpr::getType(), ibis::qExpr::isConstant(), ibis::bitvector::set(), ibis::bitvector::size(), and ibis::bitvector::sloppyCount().

int ibis::countQuery::estimate ( )

Functions to perform estimation.

Compute the possible hits expressed as hits and cand, where hits contains definite hits and cand may contain additional rows that need to be further examined.

This is done by using the indexes. If possible it will build new indices. The lower bound contains only records that are hits and the upper bound contains all hits but may also contain some records that are not hits. Returns 0 for success, a negative value for error.

References ibis::bitvector::adjustSize(), ibis::bitvector::compress(), and ibis::bitvector::size().

Referenced by ibis::mensa::estimate(), ibis::bord::estimate(), and ibis::filter::roughCount().

int ibis::countQuery::evaluate ( )
const ibis::bitvector* ibis::countQuery::getCandVector ( ) const
inline

Return the pointer to the candidates vector.

The user should NOT attempt to free the returned pointer.

References cand.

Referenced by ibis::filter::roughCount().

long ibis::countQuery::getHitRows ( std::vector< uint32_t > &  rids) const

Get the row numbers of the hits.

Extract the positions of the bits that are 1s in the solution.

This is only valid after the query has been evaluated. If it has not been evaluated, it will return a negative number to indicate error. Upon a successful completion of this function, the return value should be the rids.size().

References ibis::bitvector::indexSet::nIndices().

const ibis::bitvector* ibis::countQuery::getHitVector ( ) const
inline
long ibis::countQuery::getNumHits ( ) const

Return the number of records in the exact solution.

A negative number will be returned if the query has not been evaluated.

Referenced by ibis::table::computeHits(), ibis::filter::count(), ibis::part::get1DBins(), ibis::part::get1DDistribution(), ibis::part::get2DBins(), ibis::part::get2DDistribution(), ibis::part::get3DBins(), and ibis::part::get3DDistribution().

int ibis::countQuery::setPartition ( const ibis::part tbl)

Resets the data partition used to evaluate the query conditions to the partition specified in the argument.

Integer error code: 0: successful completion of the requested operation.

-1: nil pointer to data partition or empty partition. -2: invalid string for select clause. -3: select clause contains invalid column name. -4: invalid string for where clause. -5: where clause can not be parsed correctly. -6: where clause contains invalid column names or unsupported functions. -7: empty rid list for set rid operation. -8: neither rids nor range conditions are set. -9: encountered some exceptional conditions during query evaluations. -10: no private directory to store bundles. -11: Query not fully evaluated.

References cand, ibis::whereClause::empty(), hits, m_sel, mypart, ibis::part::name(), ibis::part::nColumns(), ibis::part::nRows(), and ibis::whereClause::verify().

Referenced by ibis::table::computeHits(), ibis::filter::count(), ibis::mensa::estimate(), ibis::bord::estimate(), and ibis::filter::roughCount().

int ibis::countQuery::setWhereClause ( const char *  str)

Specify the where clause in string form.

The where clause is a string representing a list of range conditions.

A where clause is mandatory if a query is to be estimated or evaluated. This function may be called multiple times and each invocation will overwrite the previous where clause.

accepted a suggestion from Robert Wong to allow the condition to be accepted even if some columns are not found.

References ibis::whereClause::getExpr(), and ibis::whereClause::verify().

Referenced by ibis::table::computeHits(), ibis::filter::count(), ibis::mensa::estimate(), ibis::bord::estimate(), fastbit_selection_estimate(), fastbit_selection_evaluate(), ibis::part::get1DBins(), ibis::part::get1DDistribution(), ibis::part::get2DBins(), ibis::part::get2DDistribution(), ibis::part::get3DBins(), ibis::part::get3DDistribution(), ibis::part::getCumulativeDistribution(), ibis::part::getDistribution(), ibis::part::getJointDistribution(), ibis::jNatural::jNatural(), ibis::jRange::jRange(), ibis::part::old2DDistribution(), ibis::filter::roughCount(), ibis::filter::sift2(), and ibis::filter::sift2S().

int ibis::countQuery::setWhereClause ( const ibis::qExpr qx)

Specify the where clause in the form of a qExpr object.

This function accepts a user constructed query expression object.

It can be used to bypass the parsing of where clause string.

References ibis::whereClause::getExpr(), ibis::qExpr::nItems(), ibis::whereClause::resetString(), ibis::whereClause::setExpr(), ibis::whereClause::swap(), and ibis::whereClause::verify().


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