A data structure for representing user queries. More...
#include <query.h>
Classes | |
class | readLock |
A read lock on a query object. More... | |
class | result |
The class ibis::query::result allows user to retrieve query result one row at a time. More... | |
class | weight |
A class to be used for reordering the terms in the where clauses. More... | |
class | writeLock |
A write lock on a query object. More... | |
Public Types | |
enum | QUERY_STATE { UNINITIALIZED, SET_COMPONENTS, SET_RIDS, SET_PREDICATE, SPECIFIED, QUICK_ESTIMATE, FULL_EVALUATE, BUNDLES_TRUNCATED, HITS_TRUNCATED } |
Public Member Functions | |
int | addConditions (const ibis::qExpr *qexp) |
Add a set of conditions to the existing where clause. More... | |
int | addConditions (const char *) |
Add a set of conditions to the existing where clause. More... | |
void | clear () |
Releases the resources held by the query object. More... | |
void | clearErrorMessage () const |
Reset the last error message to blank. | |
const selectClause & | components () const |
Return a list of names specified in the select clause. | |
void | contractQuery () |
Contracts where clause to preferred bounds. More... | |
long | countHits () const |
Count the number of hits. More... | |
const char * | dir () const |
Return the directory for any persistent data. More... | |
int | estimate () |
Function to perform estimation. More... | |
int | evaluate (const bool evalSelect=false) |
Computes the exact hits. More... | |
void | expandQuery () |
Expands where clause to preferred bounds. More... | |
long | getCandidateRows (std::vector< uint32_t > &) const |
Extract the positions of candidates. More... | |
const ibis::bitvector * | getCandidateVector () const |
Return a pointer to the bit vector representing the candidates. | |
long | getExpandedHits (ibis::bitvector &) const |
Get a bitvector containing all rows satisfying the query condition. More... | |
long | getHitRows (std::vector< uint32_t > &rids) const |
Extract the positions of the bits that are 1s in the solution. More... | |
const ibis::bitvector * | getHitVector () const |
Return the pointer to the internal hit vector. More... | |
const char * | getLastError () const |
Return the last error message recorded internally. | |
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 |
Compute the number of records in the exact solution. More... | |
virtual const char * | getSelectClause () const |
Return the select clause string. | |
QUERY_STATE | getState () const |
Return the current state of query. | |
const RIDSet * | getUserRIDs () const |
Return a const pointer to the copy of the user supplied RID set. | |
virtual const char * | getWhereClause () const |
Return the where clause string. | |
const char * | id () const |
Return an identifier of the query. | |
long | limit (const char *names, uint32_t keep, bool updateHits=true) |
Truncate the results to provide the top-K rows. More... | |
void | logMessage (const char *event, const char *fmt,...) const |
Used to print information about the progress or state of query processing. More... | |
int | orderby (const char *names) const |
Re-order the results according to the new "ORDER BY" specification. More... | |
const part * | partition () const |
Return the pointer to the data partition used to process the query. | |
void | printSelected (std::ostream &out) const |
Print the values of the selected columns to the specified output stream. More... | |
void | printSelectedWithRID (std::ostream &out) const |
Print the values of the columns in the select clause without functions. More... | |
query (const char *dir, const ibis::partList &tl) | |
Constructor. More... | |
query (const char *uid=0, const part *et=0, const char *pref=0) | |
Constructor. More... | |
RIDSet * | readRIDs () const |
Read RIDs from the file named "-rids". More... | |
std::string | removeComplexConditions () |
Separate out the sub-expressions that are not simple. More... | |
long | sequentialScan (ibis::bitvector &bv) const |
Perform a simple sequential scan. More... | |
int | setPartition (const ibis::part *tbl) |
Resets the data partition associated with the query. More... | |
int | setRIDs (const RIDSet &set) |
Specify a list of Row IDs for the query object. More... | |
virtual int | setSelectClause (const char *str) |
Specifies the select clause for the query. More... | |
int | setTable (const ibis::part *tbl) |
This is deprecated, will be removed soon. | |
int | setWhereClause (const char *str) |
Specify the where clause in the string form. More... | |
int | setWhereClause (const std::vector< const char * > &names, const std::vector< double > &lbounds, const std::vector< double > &rbounds) |
Specify the where clause as a set of conjunctive ranges. More... | |
int | setWhereClause (const ibis::qExpr *qexp) |
Specify the where clause through a qExpr object. More... | |
time_t | timestamp () const |
The time stamp on the data used to process the query. | |
const char * | userName () const |
User started the query. | |
void | writeRIDs (const RIDSet *rids) const |
Write the list of RIDs to a file named "-rids". | |
virtual | ~query () |
Desctructor. | |
array_t< signed char > * | getQualifiedBytes (const char *column_name) |
The functions getQualifiedTTT return the values of selected columns in the records that satisfies the specified conditions. More... | |
array_t< unsigned char > * | getQualifiedUBytes (const char *column_name) |
Retrieve the values of column_name as 8-bit unsigned integers. More... | |
array_t< int16_t > * | getQualifiedShorts (const char *column_name) |
Retrieve the values of column_name as 16-bit integers. More... | |
array_t< uint16_t > * | getQualifiedUShorts (const char *column_name) |
Retrieve the values of column_name as 16-bit unsigned integers. More... | |
array_t< int32_t > * | getQualifiedInts (const char *column_name) |
Retrieve integer values from records satisfying the query conditions. More... | |
array_t< uint32_t > * | getQualifiedUInts (const char *column_name) |
Retrieve unsigned integer values from records satisfying the query conditions. More... | |
array_t< int64_t > * | getQualifiedLongs (const char *column_name) |
Retrieve values of column_name as 64-bit integers. More... | |
array_t< uint64_t > * | getQualifiedULongs (const char *column_name) |
Retrieve values of column_name as 64-bit unsigned integers. More... | |
array_t< float > * | getQualifiedFloats (const char *column_name) |
Retrieve floating-point values from records satisfying the query conditions. More... | |
array_t< double > * | getQualifiedDoubles (const char *column_name) |
Retrieve double precision floating-point values from records satisfying the query conditions. More... | |
std::vector< std::string > * | getQualifiedStrings (const char *column_name) |
Retrieve string values from records satisfying the query conditions. More... | |
RIDSet * | getRIDs () const |
Return the list of row IDs of the hits. More... | |
RIDSet * | getRIDs (const ibis::bitvector &mask) const |
Return a list of row IDs that match the mask. More... | |
const RIDSet * | getRIDsInBundle (const uint32_t bid) const |
Return the list of row IDs of the hits within the specified bundle. | |
template<> | |
int64_t | countEqualPairs (const array_t< int32_t > &val1, const array_t< uint32_t > &val2) const |
template<> | |
int64_t | countEqualPairs (const array_t< uint32_t > &val1, const array_t< int32_t > &val2) const |
template<> | |
int64_t | countDeltaPairs (const array_t< uint32_t > &val1, const array_t< int32_t > &val2, const uint32_t &delta) const |
template<> | |
int64_t | countDeltaPairs (const array_t< int32_t > &val1, const array_t< uint32_t > &val2, const int32_t &delta) const |
template<> | |
int64_t | recordEqualPairs (const array_t< uint32_t > &val1, const array_t< int32_t > &val2, const array_t< uint32_t > &ind1, const array_t< uint32_t > &ind2, const char *filename) const |
template<> | |
int64_t | recordEqualPairs (const array_t< int32_t > &val1, const array_t< uint32_t > &val2, const array_t< uint32_t > &ind1, const array_t< uint32_t > &ind2, const char *filename) const |
template<> | |
int64_t | recordDeltaPairs (const array_t< uint32_t > &val1, const array_t< int32_t > &val2, const array_t< uint32_t > &ind1, const array_t< uint32_t > &ind2, const uint32_t &delta, const char *filename) const |
template<> | |
int64_t | recordDeltaPairs (const array_t< int32_t > &val1, const array_t< uint32_t > &val2, const array_t< uint32_t > &ind1, const array_t< uint32_t > &ind2, const int32_t &delta, const char *filename) const |
Static Public Member Functions | |
static bool | isValidToken (const char *tok) |
Is the given string a valid query token. More... | |
static void | keepQueryRecords () |
Tell the destructor to leave stored information on disk. | |
static void | removeQueryRecords () |
Tell the destructor to remove all stored information about queries. | |
static unsigned | tokenLength () |
Length of the query token. | |
Protected Member Functions | |
int | computeHits () |
Generate the hit vector. More... | |
template<typename T1 , typename T2 > | |
int64_t | countDeltaPairs (const array_t< T1 > &val1, const array_t< T2 > &val2, const T1 &delta) const |
Assume the two input arrays are sorted in ascending order, count the number of elements that are with delta of each other. More... | |
template<typename T1 , typename T2 > | |
int64_t | countEqualPairs (const array_t< T1 > &val1, const array_t< T2 > &val2) const |
Assume the two input arrays are sorted in ascending order, count the number of elements that match. More... | |
uint32_t | countPages (unsigned wordsize) const |
Count the number of pages accessed to retrieve every value in the hit vector. More... | |
int | doContract (ibis::qExpr *exp0) const |
Contract range conditions to remove the need of candidate check. | |
void | doEstimate (const qExpr *term, ibis::bitvector &low, ibis::bitvector &high) const |
Use index only to come up with a upper bound and a lower bound. More... | |
int | doEvaluate (const qExpr *term, ibis::bitvector &hits) const |
Evaluate the query expression. More... | |
int | doEvaluate (const qExpr *term, const ibis::bitvector &mask, ibis::bitvector &hits) const |
Evaluate the query expression with mask. More... | |
int | doExpand (ibis::qExpr *exp0) const |
Expand range conditions to remove the need of candidate check. | |
int | doScan (const qExpr *term, const ibis::bitvector &mask, ibis::bitvector &hits) const |
Masked sequential scan. More... | |
int | doScan (const qExpr *term, ibis::bitvector &hits) const |
Perform a sequential scan. More... | |
void | gainReadAccess (const char *mesg) const |
void | gainWriteAccess (const char *mesg) const |
void | getBounds () |
Compute the upper and lower bounds for range queries. | |
bool | hasBundles () const |
void | logError (const char *event, const char *fmt,...) const |
!< The warning/error message | |
void | logWarning (const char *event, const char *fmt,...) const |
int64_t | mergePairs (const char *pairfile) const |
void | orderPairs (const char *pairfile) const |
Sort the content of the file as ibis::rid_t. More... | |
void | printRIDs (const RIDSet &ridset) const |
Export the Row IDs of the hits to log file. More... | |
int64_t | processJoin () |
Process the join operation and return the number of pairs. More... | |
void | readHits () |
Read the results of the query. | |
void | readQuery (const ibis::partList &tl) |
Read the status information from disk. More... | |
template<typename T1 , typename T2 > | |
int64_t | recordDeltaPairs (const array_t< T1 > &val1, const array_t< T2 > &val2, const array_t< uint32_t > &ind1, const array_t< uint32_t > &ind2, const T1 &delta, const char *pairfile) const |
template<typename T1 , typename T2 > | |
int64_t | recordEqualPairs (const array_t< T1 > &val1, const array_t< T2 > &val2, const array_t< uint32_t > &ind1, const array_t< uint32_t > &ind2, const char *pairfile) const |
void | releaseAccess (const char *mesg) const |
void | removeFiles () |
Remove the files written by this object. | |
void | reorderExpr () |
int64_t | sortEquiJoin (const ibis::deprecatedJoin &cmp, const ibis::bitvector &mask) const |
Performing an equi-join by sorting the selected values first. More... | |
int64_t | sortEquiJoin (const ibis::deprecatedJoin &cmp, const ibis::bitvector &mask, const char *pairfile) const |
Perform equi-join by sorting the selected values. More... | |
int64_t | sortJoin (const std::vector< const ibis::deprecatedJoin * > &terms, const ibis::bitvector &mask) const |
int64_t | sortJoin (const ibis::deprecatedJoin &cmp, const ibis::bitvector &mask) const |
int64_t | sortRangeJoin (const ibis::deprecatedJoin &cmp, const ibis::bitvector &mask) const |
Performing a range join by sorting the selected values. More... | |
int64_t | sortRangeJoin (const ibis::deprecatedJoin &cmp, const ibis::bitvector &mask, const char *pairfile) const |
Performing range join by sorting the selected values. | |
void | storeErrorMesg (const char *) const |
Store the message into member variable lastError for later use. More... | |
void | writeHits () const |
Write the results of the query. | |
virtual void | writeQuery () |
Write the basic information about the query to disk. More... | |
Protected Attributes | |
selectClause | comps |
!< Query conditions | |
whereClause | conds |
!< Name of the user who specified the query | |
ibis::part::readLock * | dslock |
!< Estimated upper bound | |
ibis::bitvector * | hits |
!< Status of the query | |
char | lastError [MAX_LINE+PATH_MAX] |
!< A read lock on the mypart | |
QUERY_STATE | state |
!< Select clause | |
ibis::bitvector * | sup |
!< Solution in bitvector form (or lower bound) | |
char * | user |
Friends | |
class | readLock |
class | writeLock |
A data structure for representing user queries.
This is the primary entry for user to take advantage of bitmap indexing facilities. A query is a very limited version of the SQL SELECT statement. It is only defined on one data partition and it takes a where clause and a select clause. The where clause is mandatory!
It contains a list of range conditions joined together with logical operators, such as "temperature > 700 and 100 <= presessure < 350". Records whose values satisfy the conditions defined in the where clause is considered hits. A query may retrieve values of variables/columns specified in the select clause. A select clause is optional. If specified, it contains a list of column names. These columns must not be NULL in order for a record to be a hit. If any additional functions are needed in the select clause, use the function ibis::table::select instead of using this class.
The hits can be computed in two ways by using functions estimate
or evaluate
. The function estimate
can take advantage of the indices to give two approximate solutions, one as an upper bound and the other as a lower bound. The bitmap indices will be automatically built according to the specification if they are not present. The accuracy of the bounds depend on the nature of the indices available. If no index can be constructed, the lower bound would be empty and the upper bound would include every record. When the function evaluate
is called, the exact solution is computed no matter whether the function estimate
has been called or not. The solution produced is recorded as a bit vector. The user may use ibis::bitvector::indexSet to extract the record numbers of the hits or use one of the functions getQualifiedInts
, getQualifiedFloats
, and getQualifiedDoubles
to retrieve the values of the selected columns. Additionally, one may call either printSelected
or printSelectedWithRID
to print the selected values to the specified I/O stream.
ibis::query::query | ( | const char * | dir, |
const ibis::partList & | tl | ||
) |
Constructor.
Reconstructs query from stored information in the named directory dir
. This is only used for recovering from program crashes, not intended for user to manually construct a query in a directory.
References comps, conds, dir(), ibis::selectClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), hits, QUICK_ESTIMATE, readHits(), readQuery(), SET_COMPONENTS, SET_PREDICATE, SET_RIDS, SPECIFIED, state, ibis::util::strnewdup(), sup, and UNINITIALIZED.
ibis::query::query | ( | const char * | uid = 0 , |
const part * | et = 0 , |
||
const char * | pref = 0 |
||
) |
Constructor.
Generates a new query on the given data partition.
References ibis::gParameters(), lastError, and ibis::util::strnewdup().
int ibis::query::addConditions | ( | const ibis::qExpr * | qx | ) |
Add a set of conditions to the existing where clause.
The new query expression is joined with the existing conditions with the AND operator.
References ibis::whereClause::addExpr(), BUNDLES_TRUNCATED, comps, conds, ibis::selectClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), ibis::whereClause::getString(), hits, HITS_TRUNCATED, ibis::part::name(), ibis::qExpr::nItems(), QUICK_ESTIMATE, removeFiles(), ibis::whereClause::resetString(), SET_COMPONENTS, SET_PREDICATE, SPECIFIED, state, sup, UNINITIALIZED, ibis::whereClause::verify(), and writeQuery().
int ibis::query::addConditions | ( | const char * | qx | ) |
Add a set of conditions to the existing where clause.
The new query expression is joined with the existing conditions with the AND operator.
References ibis::whereClause::addConditions(), BUNDLES_TRUNCATED, comps, conds, ibis::selectClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), ibis::whereClause::getString(), hits, HITS_TRUNCATED, ibis::part::name(), ibis::qExpr::nItems(), QUICK_ESTIMATE, removeFiles(), ibis::whereClause::resetString(), SET_COMPONENTS, SET_PREDICATE, SPECIFIED, state, sup, UNINITIALIZED, ibis::whereClause::verify(), and writeQuery().
void ibis::query::clear | ( | ) |
Releases the resources held by the query object.
It re-initializes the select clause and the where clause to blank.
References ibis::fileManager::flushDir(), ibis::gParameters(), ibis::fileManager::instance(), and ibis::util::removeDir().
|
protected |
Generate the hit vector.
Make sure mypart is set before calling this function.
References ibis::bitvector::compress(), ibis::bitvector::indexSet::indices(), ibis::bitvector::indexSet::isRange(), ibis::bitvector::indexSet::nIndices(), and ibis::bitvector::size().
Referenced by evaluate().
void ibis::query::contractQuery | ( | ) |
Contracts where clause to preferred bounds.
Similar to function exandQuery, but makes the bounds of the range conditions narrower rather than wider.
References BUNDLES_TRUNCATED, comps, conds, doContract(), dslock, ibis::selectClause::empty(), ibis::whereClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), hits, HITS_TRUNCATED, QUICK_ESTIMATE, removeFiles(), ibis::whereClause::resetString(), SPECIFIED, state, sup, and writeQuery().
|
protected |
Assume the two input arrays are sorted in ascending order, count the number of elements that are with delta of each other.
Note that both template arguments should be elemental types or they must support operators -, +, == and < with mixed types.
References ibis::array_t< T >::size().
int64_t ibis::query::countDeltaPairs | ( | const array_t< uint32_t > & | val1, |
const array_t< int32_t > & | val2, | ||
const uint32_t & | delta | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), and ibis::array_t< T >::size().
int64_t ibis::query::countDeltaPairs | ( | const array_t< int32_t > & | val1, |
const array_t< uint32_t > & | val2, | ||
const int32_t & | delta | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), and ibis::array_t< T >::size().
|
protected |
Assume the two input arrays are sorted in ascending order, count the number of elements that match.
Note that both template arguments should be elemental types or they must support operators == and < with mixed types.
References ibis::array_t< T >::size().
int64_t ibis::query::countEqualPairs | ( | const array_t< int32_t > & | val1, |
const array_t< uint32_t > & | val2 | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), and ibis::array_t< T >::size().
int64_t ibis::query::countEqualPairs | ( | const array_t< uint32_t > & | val1, |
const array_t< int32_t > & | val2 | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), and ibis::array_t< T >::size().
long ibis::query::countHits | ( | ) | const |
Count the number of hits.
Don't generate the hit vector if not already there. It only work for queries containing a single range condition. Furthermore, this function does not obtain a read lock on the query or the partition. Therefore it is possible for another thread to modify the query object while the evaluation is in progress.
References ibis::bitvector::cnt(), conds, ibis::part::countHits(), ibis::whereClause::empty(), ibis::whereClause::getExpr(), hits, ibis::part::nRows(), and sup.
|
protected |
Count the number of pages accessed to retrieve every value in the hit vector.
References ibis::bitvector::indexSet::indices(), ibis::bitvector::indexSet::isRange(), ibis::bitvector::indexSet::nIndices(), and ibis::fileManager::pageSize().
Referenced by evaluate().
|
inline |
Return the directory for any persistent data.
This is not nil only if the recovery feature is enabled. By default, the recovery feature is disabled.
Referenced by ibis::bundle1::bundle1(), ibis::bundles::bundles(), query(), ibis::bundle1::write(), and ibis::bundles::write().
|
protected |
Use index only to come up with a upper bound and a lower bound.
Treats nil term as matching every row to allow empty where clauses to be interpreted as matching everything (to conform to SQL standard).
References ibis::bitvector::bytes(), ibis::bitvector::clear(), ibis::bitvector::cnt(), ibis::qExists::colName(), ibis::bitvector::copy(), ibis::bitvector::flip(), ibis::compRange::inRange(), ibis::compRange::isConstant(), ibis::math::term::isTrue(), ibis::util::logMessage(), ibis::bitvector::set(), ibis::bitvector::size(), and ibis::bitvector::sloppyCount().
|
protected |
Evaluate the query expression.
Combines the operations on index and the sequential scan in one function.
It returns a non-negative value to indicate success and a negative value to indicate error. Note that a return value of zero indicates that no hits is found. However, a positive return value does not necessarily mean the number of hits is greater than zero, it simply means that it will take some work to figure out the actually number of hits.
References ibis::bitvector::bytes(), ibis::bitvector::clear(), ibis::bitvector::cnt(), ibis::qExists::colName(), ibis::bitvector::flip(), ibis::compRange::inRange(), ibis::qExpr::isConstant(), ibis::compRange::isConstant(), ibis::math::term::isTrue(), ibis::bitvector::set(), ibis::bitvector::size(), and ibis::bitvector::sloppyCount().
|
protected |
Evaluate the query expression with mask.
Combines the operations on index and the sequential scan in one function.
References ibis::bitvector::bytes(), ibis::bitvector::cnt(), ibis::qExists::colName(), ibis::bitvector::copy(), ibis::bitvector::flip(), ibis::compRange::inRange(), ibis::qExpr::isConstant(), ibis::compRange::isConstant(), ibis::math::term::isTrue(), ibis::bitvector::set(), ibis::bitvector::size(), and ibis::bitvector::sloppyCount().
|
protected |
Masked sequential scan.
Reads the data partition to resolve the query conditions.
References ibis::bitvector::bytes(), ibis::bitvector::cnt(), ibis::qExists::colName(), ibis::bitvector::copy(), ibis::qExpr::getLeft(), ibis::qExpr::getRight(), ibis::qExpr::getType(), ibis::compRange::inRange(), ibis::qExpr::isConstant(), ibis::compRange::isConstant(), ibis::math::term::isTrue(), ibis::util::logMessage(), ibis::horometer::realTime(), ibis::bitvector::set(), ibis::bitvector::size(), ibis::bitvector::sloppyCount(), ibis::horometer::start(), and ibis::horometer::stop().
|
protected |
Perform a sequential scan.
Reads the data partition to resolve the query expression.
References ibis::bitvector::cnt(), ibis::qExists::colName(), ibis::bitvector::flip(), ibis::compRange::inRange(), ibis::qExpr::isConstant(), ibis::compRange::isConstant(), ibis::math::term::isTrue(), ibis::bitvector::set(), ibis::bitvector::size(), and ibis::bitvector::sloppyCount().
int ibis::query::estimate | ( | ) |
Function to perform estimation.
It computes a lower bound and an upper bound of hits. It uses the indexes only. If necessary it will build new indexes. The lower bound contains records that are definitely hits and the upper bound contains all hits but may also contain some records that are not hits. We also call the records in the upper bound candidates.
Returns 0 for success, a negative value for error.
References ibis::bitvector::adjustSize(), ibis::bitvector::bytes(), ibis::bitvector::cnt(), comps, conds, ibis::horometer::CPUTime(), ibis::qExpr::directEval(), dslock, ibis::selectClause::empty(), ibis::whereClause::empty(), ibis::util::emptyCache(), getBounds(), ibis::whereClause::getExpr(), ibis::part::getNullMask(), ibis::whereClause::getString(), hits, ibis::fileManager::instance(), logError(), ibis::part::nColumns(), ibis::part::nRows(), ibis::fileManager::pageCount(), QUICK_ESTIMATE, ibis::horometer::realTime(), removeFiles(), ibis::bitvector::set(), ibis::bitvector::size(), SPECIFIED, ibis::horometer::start(), state, ibis::horometer::stop(), sup, and ibis::part::timestamp().
Referenced by getNumHits(), and removeComplexConditions().
int ibis::query::evaluate | ( | const bool | evalSelect = false | ) |
Computes the exact hits.
The same answer shall be computed whether there is any index or not. The argument evalSelect indicates whether the select clause should be evaluated at the same time. If its value is true, the columns specified in the select clause will be retrieved from disk and stored in the temporary location for this query. If not, the qualified values need to be retrieved by calling one of getRIDs, getQualifiedInts, getQualifiedFloats, getQualifiedDoubles and similar functions. These functions work with one column at a time. Note that if the data is dynamically varying, the values retrived later could be different from the values extracted while processing this function.
Returns 0 or a positive integer for success, a negative value for error. Note that when it returns 0, it indicates that the number of hits is 0. However, when it returns a positive value, the return value may not be the number of hits. This semantics is actually implemented in the support functions such as computeHits, doEvaluate, and doScan.
References ibis::bitvector::bytes(), ibis::bitvector::clusteringFactor(), ibis::bitvector::cnt(), comps, computeHits(), conds, countPages(), ibis::horometer::CPUTime(), ibis::bundle::create(), dslock, ibis::selectClause::empty(), ibis::whereClause::empty(), ibis::util::emptyCache(), ibis::util::envLock, FULL_EVALUATE, ibis::whereClause::getExpr(), ibis::whereClause::getString(), hits, ibis::fileManager::iBeat(), ibis::fileManager::instance(), logError(), logMessage(), ibis::part::name(), ibis::part::nColumns(), ibis::part::nRows(), ibis::fileManager::pageCount(), ibis::fileManager::pageSize(), ibis::bitvector::randomSize(), ibis::horometer::realTime(), removeFiles(), ibis::array_t< T >::size(), ibis::bitvector::size(), ibis::bitvector::sloppyCount(), SPECIFIED, ibis::horometer::start(), state, ibis::horometer::stop(), sup, ibis::part::timestamp(), ibis::bundle::write(), writeHits(), and writeQuery().
Referenced by ibis::bord::computeHits(), getQualifiedBytes(), getQualifiedDoubles(), getQualifiedFloats(), getQualifiedInts(), getQualifiedLongs(), getQualifiedShorts(), getQualifiedStrings(), getQualifiedUBytes(), getQualifiedUInts(), getQualifiedULongs(), getQualifiedUShorts(), limit(), ibis::part::quickTest(), and removeComplexConditions().
void ibis::query::expandQuery | ( | ) |
Expands where clause to preferred bounds.
This is to make sure the function estimate will give exact answer. It does nothing if there is no preferred bounds in the indices.
References BUNDLES_TRUNCATED, comps, conds, doExpand(), dslock, ibis::selectClause::empty(), ibis::whereClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), hits, HITS_TRUNCATED, QUICK_ESTIMATE, removeFiles(), ibis::whereClause::resetString(), SPECIFIED, state, sup, and writeQuery().
long ibis::query::getCandidateRows | ( | std::vector< uint32_t > & | rids | ) | const |
Extract the positions of candidates.
This is meant to be used after calling the function estimate. It will return the position the hits if they are known already. If no estimate is known or the query is formed yet, 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::cnt(), hits, ibis::bitvector::indexSet::nIndices(), and sup.
long ibis::query::getExpandedHits | ( | ibis::bitvector & | res | ) | const |
Get a bitvector containing all rows satisfying the query condition.
The resulting bitvector inculdes both active rows and inactive rows.
References ibis::bitvector::clear().
Referenced by ibis::part::stringToBitvector().
long ibis::query::getHitRows | ( | std::vector< uint32_t > & | rids | ) | const |
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::cnt(), hits, ibis::bitvector::indexSet::nIndices(), and sup.
|
inline |
Return the pointer to the internal hit vector.
The user should NOT attempt to free the returned pointer. If this function is called before calling ibis::query::evaluate, it might return a nil pointer.
References hits.
Referenced by ibis::bundle1::bundle1(), ibis::bundles::bundles(), and ibis::part::quickTest().
long int ibis::query::getNumHits | ( | ) | const |
Compute the number of records in the exact solution.
This function will return the number of hits based on the internally stored information or other inexpensive options. It will not perform a full evaluation to compute the numbers of hits. It is intended to be called after calling ibis::query::evaluate. The return value will be -1 if it is not able to determine the number of hits.
References ibis::bitvector::cnt(), conds, ibis::part::countHits(), ibis::whereClause::empty(), estimate(), ibis::whereClause::getExpr(), hits, ibis::part::nRows(), QUICK_ESTIMATE, state, and sup.
Referenced by ibis::bundle0::bundle0(), ibis::bundle1::bundle1(), ibis::bundles::bundles(), ibis::bord::computeHits(), and ibis::part::quickTest().
ibis::array_t< signed char > * ibis::query::getQualifiedBytes | ( | const char * | colname | ) |
The functions getQualifiedTTT
return the values of selected columns in the records that satisfies the specified conditions.
An implicit casting will be performed if possible.
The caller must call the operator delete
to free the pointers returned.
Any column in the data partition may be used with getQualifiedTTT
, not just those given in the select clause. The content returned is read from disk when these functions are called.
Retrieve the values of column_name as 8-bit integers.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectBytes(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< double > * ibis::query::getQualifiedDoubles | ( | const char * | colname | ) |
Retrieve double precision floating-point values from records satisfying the query conditions.
An implicit casting will be performed if the specified column is not of type double.
Note that casting from 64-bit integers to double may cause loss of precision; casting of 32-bit floating-point values to 64-bit version may lead to spurious precision.
References dslock, evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectDoubles(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< float > * ibis::query::getQualifiedFloats | ( | const char * | colname | ) |
Retrieve floating-point values from records satisfying the query conditions.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit floating-point values.
References dslock, evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectFloats(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< int32_t > * ibis::query::getQualifiedInts | ( | const char * | colname | ) |
Retrieve integer values from records satisfying the query conditions.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectInts(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< int64_t > * ibis::query::getQualifiedLongs | ( | const char * | colname | ) |
Retrieve values of column_name as 64-bit integers.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectLongs(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< int16_t > * ibis::query::getQualifiedShorts | ( | const char * | colname | ) |
Retrieve the values of column_name as 16-bit integers.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectShorts(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
std::vector< std::string > * ibis::query::getQualifiedStrings | ( | const char * | colname | ) |
Retrieve string values from records satisfying the query conditions.
The argument colname
must be the name of a string-valued column, otherwise a null pointer will be returned.
References dslock, evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectStrings(), state, and ibis::part::timestamp().
ibis::array_t< unsigned char > * ibis::query::getQualifiedUBytes | ( | const char * | colname | ) |
Retrieve the values of column_name as 8-bit unsigned integers.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit unsigned integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectUBytes(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< uint32_t > * ibis::query::getQualifiedUInts | ( | const char * | colname | ) |
Retrieve unsigned integer values from records satisfying the query conditions.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit unsigned integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectUInts(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< uint64_t > * ibis::query::getQualifiedULongs | ( | const char * | colname | ) |
Retrieve values of column_name as 64-bit unsigned integers.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit unsigned integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectULongs(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::array_t< uint16_t > * ibis::query::getQualifiedUShorts | ( | const char * | colname | ) |
Retrieve the values of column_name as 16-bit unsigned integers.
An implicit casting will be performed if possible.
A null pointer will be returned if the underlying values can not be safely cast into 32-bit unsigned integers.
References evaluate(), FULL_EVALUATE, hits, logMessage(), ibis::part::selectUShorts(), ibis::array_t< T >::size(), state, and ibis::part::timestamp().
ibis::RIDSet * ibis::query::getRIDs | ( | ) | const |
Return the list of row IDs of the hits.
FastBit has a built-in type called ibis::rid_t.
User may use it to provide a global row identifier for each row. We call such row identifiers (RIDs) the extenal RIDs. In many cases, there is no external RIDs provided by the user, then there is still a set of implicit RIDs numbered from 0 to nRows()-1. This function will retrieve the extenal RIDs if they are present, otherwise, it will return the implicit RIDs.
References ibis::bitvector::cnt(), ibis::array_t< T >::deepCopy(), ibis::part::explicitRIDs(), FULL_EVALUATE, hits, logMessage(), ibis::bitvector::indexSet::nIndices(), ibis::part::nRows(), ibis::array_t< T >::push_back(), readRIDs(), ibis::array_t< T >::reserve(), ibis::array_t< T >::size(), state, ibis::part::timestamp(), and writeRIDs().
Referenced by ibis::part::quickTest().
ibis::RIDSet * ibis::query::getRIDs | ( | const ibis::bitvector & | mask | ) | const |
Return a list of row IDs that match the mask.
The data type for row identifiers is ibis::rid_t, which can be treated as unsigned 64-bit integer.
These identifiers (RIDs) can be either provided by the user (external RIDs) or internally generated from row positions (implicit RIDs). If the user has not provided external RIDs, then this function simply decodes the positions of the bits that are marked 1 and places the positions in the output array.
The return value can be null if this query object is not associated with a data partition or the mask contains no bit marked 1.
References ibis::bitvector::cnt(), logMessage(), ibis::part::name(), ibis::part::nRows(), and ibis::array_t< T >::size().
|
static |
Is the given string a valid query token.
Return true if it has the expected token format, otherwise false.
References ibis::util::charIndex, ibis::util::logMessage(), and tokenLength().
long ibis::query::limit | ( | const char * | names, |
uint32_t | keep, | ||
bool | updateHits = true |
||
) |
Truncate the results to provide the top-K rows.
It returns the number of results kept, which is the smaller of the current number of rows and the input argument keep
. A negative value is returned in case of error, e.g., query has not been fully specified. If the 4th argument is true, the internal hit vector is updated to match the truncated solution. Otherwise, the internal hit vector is left unchanged. Since the functions getNumHits and getQualifiedTTT uses this internal hit vector, it is generally a good idea to update the hit vector. On the other hand, one may wish to avoid this update if the hit vector is to be kept for some purpose.
References BUNDLES_TRUNCATED, ibis::horometer::CPUTime(), ibis::bundle::create(), evaluate(), ibis::part::evaluateRIDSet(), FULL_EVALUATE, ibis::bundle::getRIDs(), hits, HITS_TRUNCATED, logMessage(), QUICK_ESTIMATE, ibis::horometer::realTime(), SET_COMPONENTS, SET_PREDICATE, SET_RIDS, ibis::bundle::size(), SPECIFIED, ibis::horometer::start(), state, ibis::horometer::stop(), ibis::bundle::truncate(), UNINITIALIZED, and ibis::bundle::write().
void ibis::query::logMessage | ( | const char * | event, |
const char * | fmt, | ||
... | |||
) | const |
Used to print information about the progress or state of query processing.
It prefixes each message with a query token.
References ibis::util::getLocalTime(), and ibis::util::getLogFile().
Referenced by ibis::bundle::create(), evaluate(), getQualifiedBytes(), getQualifiedDoubles(), getQualifiedFloats(), getQualifiedInts(), getQualifiedLongs(), getQualifiedShorts(), getQualifiedStrings(), getQualifiedUBytes(), getQualifiedUInts(), getQualifiedULongs(), getQualifiedUShorts(), getRIDs(), getRIDsInBundle(), getState(), limit(), orderby(), removeComplexConditions(), setPartition(), setSelectClause(), and setWhereClause().
int ibis::query::orderby | ( | const char * | names | ) | const |
Re-order the results according to the new "ORDER BY" specification.
It returns 0 if it completes successfully. It returns a negative number to indicate error. If direction
>= 0, sort the values in ascending order, otherwise, sort them in descending order.
References BUNDLES_TRUNCATED, ibis::horometer::CPUTime(), ibis::bundle::create(), FULL_EVALUATE, HITS_TRUNCATED, logMessage(), ibis::horometer::realTime(), ibis::bundle::reorder(), ibis::horometer::start(), state, ibis::horometer::stop(), and ibis::bundle::write().
|
protected |
Sort the content of the file as ibis::rid_t.
It reads the content of the file one block at a time during the initial sorting of the blocks. It then merges the sorted blocks to produce a overall sorted file. Note that ibis::rid_t is simply a pair of integers. Sinc the pairs are recorded as pairs of integers too, this should work.
References ibis::fileManager::bytesFree(), ibis::util::getFileSize(), ibis::fileManager::instance(), ibis::util::logMessage(), PREFERRED_BLOCK_SIZE, and UnixOpen.
|
protected |
Export the Row IDs of the hits to log file.
ibis::query::setMyDir
This function prints a list of RIDs to the log file.
References ibis::array_t< T >::size().
void ibis::query::printSelected | ( | std::ostream & | out | ) | const |
Print the values of the selected columns to the specified output stream.
The printed values are grouped by the columns without functions. For each group, the functions are evaluated on the columns named in the function. This is equivalent to have implicit "GROUP BY" and "ORDER BY" keywords on all columns appears without a function in the select clause.
References ibis::bundle::create(), ibis::bundle::print(), and ibis::bundle::write().
void ibis::query::printSelectedWithRID | ( | std::ostream & | out | ) | const |
Print the values of the columns in the select clause without functions.
One the groups of unique values are printed. For each group, the row ID (RID) of the rows are also printed.
References ibis::bundle::create(), ibis::bundle::printAll(), and ibis::bundle::write().
|
protected |
Process the join operation and return the number of pairs.
This function only counts the number of hits; it does produce the actual tuples for the results of join. Additionally, it performs only self-join, i.e., join a partition with itself. This is only meant to test some algorithms for evaluating joins.
References ibis::index::BINNING, ibis::bitvector::bytes(), ibis::fileManager::bytesFree(), ibis::fileManager::bytesInUse(), ibis::bitvector64::clear(), ibis::bitvector::clusteringFactor(), ibis::bitvector64::cnt(), ibis::bitvector::cnt(), ibis::horometer::CPUTime(), ibis::math::barrel::equivalent(), ibis::qExpr::findRange(), ibis::column::getNullMask(), ibis::util::logMessage(), ibis::bitvector64::markovSize(), ibis::column::name(), ibis::util::outerProduct(), ibis::horometer::realTime(), ibis::math::barrel::recordVariable(), ibis::index::RELIC, ibis::bitvector64::set(), ibis::bitvector::size(), ibis::bitvector64::size(), ibis::horometer::start(), ibis::horometer::stop(), ibis::bitvector64::swap(), and ibis::index::type().
|
protected |
Read the status information from disk.
A function to read the query file in a directory – used by the constructor that takes a directory name as the argument the file contains:
References ibis::util::clear(), and ibis::util::strnewdup().
Referenced by query().
ibis::RIDSet * ibis::query::readRIDs | ( | ) | const |
Read RIDs from the file named "-rids".
Return a pointer to ibis::RIDSet.
References ibis::fileManager::getFile(), ibis::fileManager::instance(), and ibis::array_t< T >::size().
Referenced by ibis::bundle1::bundle1(), ibis::bundles::bundles(), and getRIDs().
int64_t ibis::query::recordDeltaPairs | ( | const array_t< uint32_t > & | val1, |
const array_t< int32_t > & | val2, | ||
const array_t< uint32_t > & | ind1, | ||
const array_t< uint32_t > & | ind2, | ||
const uint32_t & | delta, | ||
const char * | filename | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), ibis::array_t< T >::size(), and UnixOpen.
int64_t ibis::query::recordDeltaPairs | ( | const array_t< int32_t > & | val1, |
const array_t< uint32_t > & | val2, | ||
const array_t< uint32_t > & | ind1, | ||
const array_t< uint32_t > & | ind2, | ||
const int32_t & | delta, | ||
const char * | filename | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), ibis::array_t< T >::size(), and UnixOpen.
int64_t ibis::query::recordEqualPairs | ( | const array_t< uint32_t > & | val1, |
const array_t< int32_t > & | val2, | ||
const array_t< uint32_t > & | ind1, | ||
const array_t< uint32_t > & | ind2, | ||
const char * | filename | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), ibis::array_t< T >::size(), and UnixOpen.
int64_t ibis::query::recordEqualPairs | ( | const array_t< int32_t > & | val1, |
const array_t< uint32_t > & | val2, | ||
const array_t< uint32_t > & | ind1, | ||
const array_t< uint32_t > & | ind2, | ||
const char * | filename | ||
) | const |
This is an explicit specialization of a protected member of ibis::query class.
References ibis::array_t< T >::find(), ibis::array_t< T >::size(), and UnixOpen.
std::string ibis::query::removeComplexConditions | ( | ) |
Separate out the sub-expressions that are not simple.
This is intended to allow the overall where clause to be evaluated in separated steps, where the simple conditions are left for this software to handle and the more complex ones are to be handled by another software. The set of conditions remain with this query object and the conditions returned by this function are assumed to be connected with the operator AND. If the top-most operator in the WHERE clause is not an AND operator, the whole clause will be returned if it contains any conditions that is not simple, otherwise, an empty string will be returned.
References BUNDLES_TRUNCATED, ibis::whereClause::clear(), conds, ibis::whereClause::empty(), estimate(), evaluate(), FULL_EVALUATE, getBounds(), ibis::whereClause::getString(), hits, HITS_TRUNCATED, logMessage(), ibis::part::nRows(), ibis::qExpr::print(), QUICK_ESTIMATE, ibis::qExpr::separateSimple(), ibis::bitvector::set(), setWhereClause(), state, and sup.
long ibis::query::sequentialScan | ( | ibis::bitvector & | res | ) | const |
Perform a simple sequential scan.
Return a (new) bitvector that contains the result of directly scan the raw data to determine what records satisfy the user specified conditions. It is mostly used for testing purposes. It can be called any time after the where clause is set, and does not change the state of the current query.
References ibis::bitvector::clear(), ibis::bitvector::cnt(), ibis::bitvector::copy(), ibis::horometer::CPUTime(), ibis::util::emptyCache(), ibis::bitvector::indexSet::indices(), ibis::bitvector::indexSet::isRange(), ibis::bitvector::indexSet::nIndices(), ibis::bitvector::print(), ibis::horometer::realTime(), ibis::horometer::start(), and ibis::horometer::stop().
Referenced by ibis::part::quickTest().
int ibis::query::setPartition | ( | const ibis::part * | tbl | ) |
Resets the data partition associated with the query.
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 BUNDLES_TRUNCATED, comps, conds, dslock, ibis::selectClause::empty(), ibis::whereClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), ibis::whereClause::getString(), hits, HITS_TRUNCATED, logMessage(), ibis::part::name(), ibis::part::nColumns(), ibis::part::nRows(), QUICK_ESTIMATE, removeFiles(), SET_COMPONENTS, SET_PREDICATE, SPECIFIED, state, sup, ibis::selectClause::verify(), ibis::whereClause::verify(), and writeQuery().
Referenced by setTable().
int ibis::query::setRIDs | ( | const RIDSet & | set | ) |
Specify a list of Row IDs for the query object.
Select the records with an RID in the list of RIDs.
References BUNDLES_TRUNCATED, comps, ibis::array_t< T >::deepCopy(), ibis::selectClause::empty(), FULL_EVALUATE, hits, HITS_TRUNCATED, QUICK_ESTIMATE, removeFiles(), SET_RIDS, ibis::array_t< T >::size(), SPECIFIED, state, sup, and writeQuery().
Referenced by ibis::part::quickTest().
|
virtual |
Specifies the select clause for the query.
The select clause is a string of column names separated by spaces, commas (,) or semicolons(;). Repeated calls to this function simply overwrite the previous definition of the select clause. If no select clause is specified, the where clause alone determines whether record is a hit or not. The select clause will be reordered to make the plain column names without functions appear before with functions.
References BUNDLES_TRUNCATED, ibis::part::columnNames(), comps, conds, FULL_EVALUATE, ibis::whereClause::getExpr(), hits, HITS_TRUNCATED, logMessage(), ibis::part::name(), QUICK_ESTIMATE, removeFiles(), SET_COMPONENTS, SPECIFIED, state, sup, ibis::selectClause::swap(), ibis::selectClause::verify(), and writeQuery().
Referenced by ibis::part::quickTest().
int ibis::query::setWhereClause | ( | const char * | str | ) |
Specify the where clause in the string form.
The where clause is a string representing a list of range conditions. By SQL convention, an empty where clause matches all rows. This function may be called multiple times and each invocation will overwrite the previous where clause.
References BUNDLES_TRUNCATED, comps, conds, ibis::selectClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), ibis::whereClause::getString(), hits, HITS_TRUNCATED, logMessage(), ibis::part::name(), ibis::qExpr::printFull(), QUICK_ESTIMATE, removeFiles(), SET_PREDICATE, SPECIFIED, state, sup, ibis::whereClause::swap(), ibis::whereClause::verify(), and writeQuery().
Referenced by ibis::bord::computeHits(), ibis::part::quickTest(), removeComplexConditions(), and ibis::part::stringToBitvector().
int ibis::query::setWhereClause | ( | const std::vector< const char * > & | names, |
const std::vector< double > & | lbounds, | ||
const std::vector< double > & | rbounds | ||
) |
Specify the where clause as a set of conjunctive ranges.
This function accepts a set of range conditions expressed by the three vectors. The arrays are expected to be of the same size, and each triplet <names[i], lbounds[i], rbounds[i]> are interpreted as
The range conditions are joined together with the AND operator. If vectors lbounds and rbounds are not the same size, then the missing one is consider to represent an open boundary. For example, if lbounds[4] exists but not rbounds[4], they the range condition is interpreted as
References BUNDLES_TRUNCATED, comps, conds, ibis::selectClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), hits, HITS_TRUNCATED, ibis::part::name(), QUICK_ESTIMATE, removeFiles(), SET_COMPONENTS, SET_PREDICATE, ibis::whereClause::setExpr(), ibis::qExpr::setLeft(), ibis::qExpr::setRight(), SPECIFIED, state, sup, UNINITIALIZED, ibis::whereClause::verify(), and writeQuery().
int ibis::query::setWhereClause | ( | const ibis::qExpr * | qx | ) |
Specify the where clause through 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 BUNDLES_TRUNCATED, comps, conds, ibis::selectClause::empty(), FULL_EVALUATE, ibis::whereClause::getExpr(), ibis::whereClause::getString(), hits, HITS_TRUNCATED, ibis::part::name(), ibis::qExpr::nItems(), QUICK_ESTIMATE, removeFiles(), ibis::whereClause::resetString(), SET_COMPONENTS, SET_PREDICATE, ibis::whereClause::setExpr(), SPECIFIED, state, sup, ibis::whereClause::swap(), UNINITIALIZED, ibis::whereClause::verify(), and writeQuery().
|
protected |
Performing an equi-join by sorting the selected values first.
This version reads the values marked to be 1 in the bitvector mask
and performs the actual operation of counting the number of pairs with equal values in memory.
References ibis::CATEGORY, ibis::horometer::CPUTime(), ibis::DOUBLE, ibis::FLOAT, ibis::INT, ibis::util::logMessage(), ibis::horometer::realTime(), ibis::column::selectValues(), ibis::horometer::start(), ibis::horometer::stop(), ibis::column::type(), and ibis::UINT.
|
protected |
Perform equi-join by sorting the selected values.
This version reads the values marked to be 1 in the bitvector mask
. It writes the the pairs satisfying the join condition to a file name pairfile
.
References ibis::CATEGORY, ibis::horometer::CPUTime(), ibis::DOUBLE, ibis::FLOAT, ibis::INT, ibis::util::logMessage(), ibis::horometer::realTime(), ibis::column::selectValues(), ibis::array_t< T >::size(), ibis::array_t< T >::stableSort(), ibis::horometer::start(), ibis::horometer::stop(), ibis::column::type(), and ibis::UINT.
|
protected |
Performing a range join by sorting the selected values.
The sorting is performed through std::sort
algorithm.
References ibis::CATEGORY, ibis::horometer::CPUTime(), ibis::DOUBLE, ibis::math::term::eval(), ibis::FLOAT, ibis::INT, ibis::util::logMessage(), ibis::horometer::realTime(), ibis::column::selectValues(), ibis::horometer::start(), ibis::horometer::stop(), ibis::column::type(), and ibis::UINT.
|
protected |
Store the message into member variable lastError for later use.
This function will truncate long messages because lastError is declared with a fixed size of MAX_LINE+PATH_MAX. If the incoming argument is a nil pointer or an empty sttring, lastError will be set to be an empty string as if clearErrorMessage is called.
|
protectedvirtual |
Write the basic information about the query to disk.
Write the content of the current query into a file.
Referenced by addConditions(), contractQuery(), evaluate(), expandQuery(), setPartition(), setRIDs(), setSelectClause(), and setWhereClause().