In-memory Natual Join. More...
#include <jnatural.h>
Public Member Functions | |
virtual int64_t | count () const |
Use sort-merge join. More... | |
template<typename T > | |
ibis::table * | fillResult (size_t nrows, const std::string &desc, const ibis::array_t< T > &rjcol, const ibis::table::typeArray &rtypes, const ibis::table::bufferArray &rbuff, const ibis::array_t< T > &sjcol, const ibis::table::typeArray &stypes, const ibis::table::bufferArray &sbuff, const ibis::table::stringArray &tcname, const std::vector< uint32_t > &tcnpos) |
Generate a table representing an equi-join in memory. More... | |
jNatural (const ibis::part *partr, const ibis::part *parts, const char *colname, const char *condr, const char *conds, const char *sel) | |
Constructor. More... | |
jNatural (const ibis::part *partr, const ibis::part *parts, const ibis::column *colr, const ibis::column *cols, const ibis::qExpr *condr, const ibis::qExpr *conds, const ibis::selectClause *sel, const ibis::fromClause *frm, const char *desc) | |
Constructor. More... | |
virtual void | roughCount (uint64_t &nmin, uint64_t &nmax) const |
Estimate the number of hits. Don't do much right now, may change later. | |
virtual ibis::table * | select () const |
Evaluate the select clause specified in the constructor. | |
virtual ibis::table * | select (const char *) const |
Produce a project based on the given select clause. More... | |
virtual ibis::table * | select (const ibis::table::stringArray &colnames) const |
Select values for a list of column names. More... | |
Static Protected Member Functions | |
template<typename T > | |
static table * | fillResult (size_t nrows, const std::string &desc, const ibis::array_t< T > &rjcol, const ibis::table::typeArray &rtypes, const ibis::table::bufferArray &rbuff, const ibis::array_t< T > &sjcol, const ibis::table::typeArray &stypes, const ibis::table::bufferArray &sbuff, const ibis::table::stringArray &cnamet, const std::vector< uint32_t > &cnpos) |
static table * | fillResult (size_t nrows, const std::string &desc, const std::vector< std::string > &rjcol, const ibis::table::typeArray &rtypes, const ibis::table::bufferArray &rbuff, const std::vector< std::string > &sjcol, const ibis::table::typeArray &stypes, const ibis::table::bufferArray &sbuff, const ibis::table::stringArray &cnamet, const std::vector< uint32_t > &cnpos) |
Form the joined table for string valued join columns. More... | |
Protected Attributes | |
const ibis::column & | colR_ |
const ibis::column & | colS_ |
std::string | desc_ |
const ibis::fromClause * | frm_ |
ibis::bitvector | maskR_ |
ibis::bitvector | maskS_ |
int64_t | nrows |
array_t< uint32_t > * | orderR_ |
array_t< uint32_t > * | orderS_ |
const ibis::part & | R_ |
const ibis::part & | S_ |
const ibis::selectClause * | sel_ |
void * | valR_ |
void * | valS_ |
Additional Inherited Members | |
Static Public Member Functions inherited from ibis::quaere | |
static quaere * | create (const char *sel, const char *from, const char *where) |
Create a query object using the global datasets. | |
static quaere * | create (const char *sel, const char *from, const char *where, const ibis::partList &prts) |
Generate a query expression. More... | |
static quaere * | create (const ibis::part *partr, const ibis::part *parts, const char *colname, const char *condr=0, const char *conds=0, const char *sel=0) |
Specify a natural join operation. More... | |
Protected Member Functions inherited from ibis::quaere | |
quaere () | |
Default constructor. Only used by derived classes. | |
In-memory Natual Join.
ibis::jNatural::jNatural | ( | const ibis::part * | partr, |
const ibis::part * | parts, | ||
const char * | colname, | ||
const char * | condr, | ||
const char * | conds, | ||
const char * | sel | ||
) |
Constructor.
This constructor handles a join equivalent to the following SQL statement
Note that conditions specified in condr is for partr only, and conds is for parts only. When the column names in these conditions contain table names, the table names in them are ignored. If no conditions are specified, all valid records in the partition will participate in the natural join. This constructor avoids the need of specifying an alias when performing self-join, however, it also makes it impossible to distingush the column names in the select clause.
References ibis::bitvector::copy(), ibis::countQuery::evaluate(), ibis::countQuery::getHitVector(), ibis::column::getNullMask(), ibis::countQuery::getWhereClause(), ibis::part::name(), ibis::countQuery::setWhereClause(), ibis::column::type(), and ibis::TYPESTRING.
ibis::jNatural::jNatural | ( | const ibis::part * | partr, |
const ibis::part * | parts, | ||
const ibis::column * | colr, | ||
const ibis::column * | cols, | ||
const ibis::qExpr * | condr, | ||
const ibis::qExpr * | conds, | ||
const ibis::selectClause * | sel, | ||
const ibis::fromClause * | frm, | ||
const char * | desc | ||
) |
Constructor.
This constructor handles a join expression equivalent to one of the following SQL statements
Note that this function processes the selection conditions on partr and parts immediately and therefore does not actually remember the conditions condr and conds. To preserve those conditions, it is recommended to keep the original query string as the description desc.
References ibis::bitvector::copy(), ibis::countQuery::evaluate(), ibis::countQuery::getHitVector(), ibis::column::getNullMask(), ibis::countQuery::getWhereClause(), ibis::part::name(), ibis::column::name(), and ibis::countQuery::setWhereClause().
|
virtual |
Use sort-merge join.
This function sorts the qualified values and counts the number of results.
Implements ibis::quaere.
References ibis::CATEGORY, ibis::DOUBLE, ibis::FLOAT, ibis::INT, ibis::LONG, ibis::SHORT, ibis::util::sortMerge(), ibis::TEXT, ibis::UBYTE, ibis::UINT, ibis::ULONG, and ibis::USHORT.
|
staticprotected |
Form the joined table for string valued join columns.
The caller provides all relevant values, this function only needs to join them to produce the output data table.
References ibis::table::allocateBuffer(), ibis::bord::copyValue(), ibis::table::freeBuffers(), ibis::util::ref(), ibis::util::shortName(), ibis::array_t< T >::size(), and ibis::UNKNOWN_TYPE.
ibis::table* ibis::jNatural::fillResult | ( | size_t | nrows, |
const std::string & | desc, | ||
const ibis::array_t< T > & | rjcol, | ||
const ibis::table::typeArray & | rtypes, | ||
const ibis::table::bufferArray & | rbuff, | ||
const ibis::array_t< T > & | sjcol, | ||
const ibis::table::typeArray & | stypes, | ||
const ibis::table::bufferArray & | sbuff, | ||
const ibis::table::stringArray & | tcname, | ||
const std::vector< uint32_t > & | tcnpos | ||
) |
Generate a table representing an equi-join in memory.
The input to this function are values to go into the resulting table. It only needs to match the rows and fill the output table.
References ibis::table::allocateBuffer(), ibis::bord::copyValue(), ibis::table::freeBuffers(), ibis::util::ref(), ibis::util::shortName(), ibis::array_t< T >::size(), and ibis::UNKNOWN_TYPE.
|
virtual |
Produce a project based on the given select clause.
The joint data table is defined by the where clause and the from clause given to the constructor of this object.
Implements ibis::quaere.
References ibis::selectClause::aggExpr(), ibis::selectClause::aggSize(), ibis::table::describe(), ibis::selectClause::getAggregator(), ibis::table::nColumns(), ibis::table::nRows(), ibis::array_t< T >::push_back(), ibis::math::barrel::recordVariable(), ibis::array_t< T >::reserve(), and ibis::util::shortName().
|
virtual |
Select values for a list of column names.
fill the in-memory buffer
Implements ibis::quaere.
References ibis::CATEGORY, ibis::DOUBLE, ibis::FLOAT, ibis::table::freeBuffers(), ibis::category::getDictionary(), ibis::bord::column::getDictionary(), ibis::INT, ibis::LONG, ibis::util::ref(), ibis::util::reorder(), ibis::bord::column::setDictionary(), ibis::SHORT, ibis::util::shortName(), ibis::array_t< T >::size(), ibis::TEXT, ibis::column::type(), ibis::TYPESTRING, ibis::UBYTE, ibis::UINT, ibis::ULONG, ibis::UNKNOWN_TYPE, and ibis::USHORT.