A two-level index. More...
#include <ibin.h>
Public Member Functions | |
virtual void | adjustLength (uint32_t nrows) |
Make sure all bitmaps have nr bits. | |
virtual long | append (const char *dt, const char *df, uint32_t nnew) |
Create index for the data in df and append the result to the index in dt. | |
long | append (const ibis::pack &tail) |
virtual void | binBoundaries (std::vector< double > &) const |
The function binBoundaries and binWeights return bin boundaries and counts of each bin respectively. | |
virtual void | binWeights (std::vector< uint32_t > &) const |
virtual void | estimate (const ibis::qContinuousRange &expr, ibis::bitvector &lower, ibis::bitvector &upper) const |
Provide an estimation based on the current index. | |
virtual long | evaluate (const ibis::qContinuousRange &expr, ibis::bitvector &hits) const |
To evaluate the exact hits. | |
virtual long | evaluate (const ibis::qDiscreteRange &expr, ibis::bitvector &hits) const |
To evaluate the exact hits. | |
virtual double | getSum () const |
Compute the approximate value of the sum from the binned index. | |
virtual const char * | name () const |
Returns the name of the index, similar to the function type , but returns a string instead. | |
virtual uint32_t | numBins () const |
pack (const ibis::bin &rhs) | |
Constructor. | |
pack (const ibis::column *c, ibis::fileManager::storage *st, size_t offset=8) | |
Reconstruct an index from content of a storage object. | |
virtual void | print (std::ostream &out) const |
Prints human readable information. | |
virtual int | read (const char *idxfile) |
Read the content of an index from the specified location. | |
virtual int | read (ibis::fileManager::storage *st) |
Read the index content from a storage object. | |
virtual void | speedTest (std::ostream &out) const |
Time some logical operations and print out their speed. | |
virtual INDEX_TYPE | type () const |
Returns an index type identifier. | |
virtual float | undecidable (const ibis::qContinuousRange &expr, ibis::bitvector &iffy) const |
Mark the position of the rows that can not be decided with this index. | |
virtual int | write (const char *dt) const |
Write the index to the specified location. | |
Protected Member Functions | |
virtual void | clear () |
Clear the existing content. | |
virtual double | computeSum () const |
The the approximate sum of all values using the top level bins. | |
virtual size_t | getSerialSize () const throw () |
Get an estimate of the size of index on disk. |
A two-level index.
Coarse level is cumulative, but not the bottom level.
ibis::pack::pack | ( | const ibis::column * | c, |
ibis::fileManager::storage * | st, | ||
size_t | start = 8 |
||
) |
Reconstruct an index from content of a storage object.
In addition to the common content for index::bin, the following are inserted after minval array: (this constructor relies the fact that max1 and min1 follow minval immediately without any separation or padding)
max1 (double) -- the maximum value of all data entry min1 (double) -- the minimum value of those larger than or equal to the largest bounds value (bounds[nobs-1]) offsets_for_next_level ([nobs+1]) -- as the name suggests, these are the offsets (in this file) for the next level ibis::pack.
After the bit vectors of this level are written, the next level ibis::pack are written without header.
References ibis::fileManager::storage::begin(), ibis::bin::bin(), clear(), ibis::index::col, ibis::gVerbose, ibis::column::name(), ibis::part::name(), ibis::bin::nobs, and print().
ibis::pack::pack | ( | const ibis::bin & | rhs | ) | [explicit] |
Constructor.
Generate an ibis::pack from ibis::bin.
References ibis::bin::bin(), ibis::index::bits, ibis::bin::bounds, clear(), ibis::index::col, ibis::bin::divideBitmaps(), ibis::gVerbose, ibis::column::indexSpec(), ibis::bin::maxval, ibis::bin::minval, ibis::column::name(), ibis::part::name(), ibis::bin::nobs, ibis::index::nrows, print(), and ibis::array_t< T >::resize().
void ibis::pack::adjustLength | ( | uint32_t | nr | ) | [virtual] |
Make sure all bitmaps have nr bits.
It appends zero bits to short bitmaps and or truncates long ones.
Reimplemented from ibis::bin.
References ibis::bin::adjustLength().
void ibis::pack::binBoundaries | ( | std::vector< double > & | ) | const [virtual] |
The function binBoundaries and binWeights return bin boundaries and counts of each bin respectively.
Reimplemented from ibis::bin.
void ibis::pack::clear | ( | ) | [protected, virtual] |
Clear the existing content.
Free the objectes pointed to by the pointers.
Reimplemented from ibis::bin.
References ibis::bin::clear().
Referenced by pack().
void ibis::pack::estimate | ( | const ibis::qContinuousRange & | expr, |
ibis::bitvector & | lower, | ||
ibis::bitvector & | upper | ||
) | const [virtual] |
Provide an estimation based on the current index.
Set bits in lower are hits for certain, set bits in upper are candidates. Set bits in (upper - lower) should be checked to verifies which ones are actually hits. If the bitvector upper contain less bits than bitvector lower, the content of upper is assumed to be the same as lower.
Reimplemented from ibis::bin.
References ibis::bitvector::clear(), ibis::bitvector::copy(), ibis::util::eq2range(), ibis::bitvector::flip(), ibis::gVerbose, ibis::util::incrDouble(), ibis::qContinuousRange::leftBound(), ibis::qContinuousRange::rightBound(), ibis::bitvector::set(), and ibis::bitvector::size().
long ibis::pack::evaluate | ( | const ibis::qContinuousRange & | expr, |
ibis::bitvector & | hits | ||
) | const [virtual] |
To evaluate the exact hits.
On success, return the number of hits, otherwise a negative value is returned.
Reimplemented from ibis::bin.
References ibis::bitvector::cnt(), and ibis::bitvector::size().
virtual long ibis::pack::evaluate | ( | const ibis::qDiscreteRange & | , |
ibis::bitvector & | |||
) | const [inline, virtual] |
To evaluate the exact hits.
On success, return the number of hits, otherwise a negative value is returned.
Reimplemented from ibis::bin.
References ibis::range::evaluate().
size_t ibis::pack::getSerialSize | ( | ) | const throw () [protected, virtual] |
Get an estimate of the size of index on disk.
This function is used to determine whether to use 64-bit offsets or 32-bit offsets. For the purpose of this estimation, we assume 64-bit offsets are needed. This function recursively calls itself to determine the size of sub-indexes.
Reimplemented from ibis::bin.
virtual const char* ibis::pack::name | ( | ) | const [inline, virtual] |
Returns the name of the index, similar to the function type
, but returns a string instead.
Reimplemented from ibis::bin.
void ibis::pack::print | ( | std::ostream & | out | ) | const [virtual] |
Prints human readable information.
Outputs information about the index as text to the specified output stream.
Reimplemented from ibis::bin.
References ibis::gVerbose.
Referenced by pack().
float ibis::pack::undecidable | ( | const ibis::qContinuousRange & | , |
ibis::bitvector & | |||
) | const [virtual] |
Mark the position of the rows that can not be decided with this index.
expr | the range conditions to be evaluated. |
iffy | the bitvector marking the positions of rows that can not be decided using the index. Return value is the expected fraction of undecided rows that might satisfy the range conditions. |
Reimplemented from ibis::bin.
References ibis::bitvector::cnt(), ibis::qContinuousRange::leftBound(), ibis::qContinuousRange::rightBound(), ibis::bitvector::set(), and ibis::bitvector::size().
int ibis::pack::write | ( | const char * | dt | ) | const [virtual] |
Write the index to the specified location.
The incoming argument can be a directory name or a file name. The actualy index file name is determined by the function indexFileName.
Reimplemented from ibis::bin.
References ibis::fileManager::flushFile(), ibis::gVerbose, ibis::fileManager::instance(), ibis::index::PACK, and UnixOpen.
![]() |