In-memory Natual Join. More...
#include <jnatural.h>
Public Member Functions | |
virtual int64_t | count () const |
Use sort-merge join. | |
jNatural (const ibis::part *partr, const ibis::part *parts, const char *colname, const char *condr, const char *conds, const char *sel) | |
Constructor. | |
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. | |
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 ibis::table::stringList &colnames) const |
Produce a projection of the joined table. | |
virtual ibis::table * | select () const |
Evaluate the select clause specified in the constructor. | |
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::typeList &rtypes, const ibis::table::bufferList &rbuff, const ibis::array_t< T > &sjcol, const ibis::table::typeList &stypes, const ibis::table::bufferList &sbuff, const ibis::table::stringList &cnamet, const std::vector< uint32_t > &cnpos) |
Generate a table representing an equi-join in memory. | |
static table * | fillResult (size_t nrows, const std::string &desc, const std::vector< std::string > &rjcol, const ibis::table::typeList &rtypes, const ibis::table::bufferList &rbuff, const std::vector< std::string > &sjcol, const ibis::table::typeList &stypes, const ibis::table::bufferList &sbuff, const ibis::table::stringList &cnamet, const std::vector< uint32_t > &cnpos) |
Form the joined table for string valued join columns. | |
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_ |
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
From partr Join parts Using(colname) Where condr And conds
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::gVerbose, 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
From partr Join parts On colr = cols where condr and conds; From partr, parts where partr.colr = parts.cols and condr and conds;
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::gVerbose, ibis::column::name(), ibis::part::name(), and ibis::countQuery::setWhereClause().
int64_t ibis::jNatural::count | ( | ) | const [virtual] |
Use sort-merge join.
This function sorts the qualified values and counts the number of results.
Implements ibis::quaere.
References ibis::BYTE, ibis::CATEGORY, ibis::DOUBLE, ibis::FLOAT, ibis::gVerbose, ibis::INT, ibis::LONG, ibis::SHORT, ibis::util::sortMerge(), ibis::TEXT, ibis::UBYTE, ibis::UINT, ibis::ULONG, and ibis::USHORT.
ibis::table * ibis::jNatural::fillResult | ( | size_t | nrows, |
const std::string & | desc, | ||
const ibis::array_t< T > & | rjcol, | ||
const ibis::table::typeList & | rtypes, | ||
const ibis::table::bufferList & | rbuff, | ||
const ibis::array_t< T > & | sjcol, | ||
const ibis::table::typeList & | stypes, | ||
const ibis::table::bufferList & | sbuff, | ||
const ibis::table::stringList & | tcname, | ||
const std::vector< uint32_t > & | tcnpos | ||
) | [static, protected] |
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::gVerbose, 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 std::vector< std::string > & | rjcol, | ||
const ibis::table::typeList & | rtypes, | ||
const ibis::table::bufferList & | rbuff, | ||
const std::vector< std::string > & | sjcol, | ||
const ibis::table::typeList & | stypes, | ||
const ibis::table::bufferList & | sbuff, | ||
const ibis::table::stringList & | tcname, | ||
const std::vector< uint32_t > & | tcnpos | ||
) | [static, protected] |
Form the joined table for string valued join columns.
The caller provides all relevant values, this function only need to join them to produce the output data table.
References ibis::table::allocateBuffer(), ibis::bord::copyValue(), ibis::table::freeBuffers(), ibis::gVerbose, ibis::util::ref(), ibis::util::shortName(), ibis::array_t< T >::size(), and ibis::UNKNOWN_TYPE.
ibis::table * ibis::jNatural::select | ( | const ibis::table::stringList & | colnames | ) | const [virtual] |
Produce a projection of the joined table.
This function selects values using the column names provided instead of the select clause specified when the query is constructed. Note that if more than one data partition was used in specifying the query, the column names should be fully qualified in the form of "part-name.column-name". If a dot ('.') is not present or the string before the dot is not the name of a data partition, the whole string is taken to be a column name. In which case, the lookup proceeds from the list of data partitions one at a time. A nil pointer will be returned if any name is not associated with a known column.
fill the in-memory buffer
Implements ibis::quaere.
References ibis::BYTE, ibis::CATEGORY, ibis::DOUBLE, ibis::FLOAT, ibis::table::freeBuffers(), ibis::gVerbose, ibis::INT, ibis::LONG, ibis::util::ref(), ibis::util::reorder(), ibis::SHORT, ibis::util::shortName(), ibis::array_t< T >::size(), ibis::TEXT, ibis::TYPESTRING, ibis::UBYTE, ibis::UINT, ibis::ULONG, ibis::UNKNOWN_TYPE, and ibis::USHORT.
![]() |