Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ibis::bundle Class Referenceabstract

The public interface of bundles. More...

#include <bundle.h>

Inheritance diagram for ibis::bundle:
ibis::bundle0 ibis::bundle1 ibis::bundles

Public Member Functions

virtual void * columnArray (uint32_t) const
 Return the pointer to the underlying array used to store the jth column of the bundle. More...
 
virtual const ibis::columncolumnPointer (uint32_t) const
 Column pointer.
 
virtual ibis::TYPE_T columnType (uint32_t) const
 Return the type used to store the values of the jth column of the bundle. More...
 
const ibis::RIDSetgetRIDs (uint32_t ind) const
 Return the RIDs of the indth bundle.
 
const ibis::RIDSetgetRIDs () const
 Return the pointer to all RIDs.
 
const ibis::array_t< uint32_t > * getStarts () const
 Return the pointer to array starts.
 
uint32_t numRowsInBundle (uint32_t ind) const
 Compute the number of rows in bundle ind.
 
virtual void print (std::ostream &out) const =0
 Print the bundle values to the specified output stream.
 
virtual void printAll (std::ostream &out) const =0
 Print the bundle values along with the RIDs.
 
virtual void printColumnNames (std::ostream &out) const =0
 Print column names.
 
virtual void reorder (const char *)=0
 Re-order the bundles according to the new keys.
 
uint32_t rowCounts (array_t< uint32_t > &cnt) const
 Compute the number of rows in each group(bundle). More...
 
virtual uint32_t size () const
 Return the number of bundles.
 
void sortRIDs (uint32_t i, uint32_t j)
 Sort RIDs in the range of [i, j)
 
void swapRIDs (uint32_t i, uint32_t j)
 
virtual long truncate (uint32_t keep)=0
 Truncate the list of bundles.
 
virtual long truncate (uint32_t keep, uint32_t start)=0
 Truncate the list of bundles.
 
virtual long truncate (const char *names, uint32_t keep)=0
 Truncate the list of bundle based on specified keys.
 
virtual uint32_t width () const
 Return the width of the bundles.
 
virtual void write (const ibis::query &q) const =0
 Write the bundle to the directory for the query q.
 
virtual int32_t getInt (uint32_t, uint32_t) const
 Retrieve a single value. More...
 
virtual uint32_t getUInt (uint32_t, uint32_t) const
 Return the maximal unsigned int value.
 
virtual int64_t getLong (uint32_t, uint32_t) const
 Return the maximal int value.
 
virtual uint64_t getULong (uint32_t, uint32_t) const
 Return the maximal unsigned int value.
 
virtual float getFloat (uint32_t, uint32_t) const
 Return the maximal float value.
 
virtual double getDouble (uint32_t, uint32_t) const
 Return the maximum double value.
 
virtual std::string getString (uint32_t, uint32_t) const
 Retrieve a string value. More...
 

Static Public Member Functions

static bundlecreate (const ibis::query &, int=0)
 Create new bundle from a query object. More...
 
static bundlecreate (const ibis::query &, const ibis::bitvector &, int=0)
 Create a new bundle from previously stored information.
 
static bundlecreate (const ibis::part &, const ibis::selectClause &, int=0)
 Create a bundle using the all values of the partition.
 
static const ibis::RIDSetreadRIDs (const char *dir, const uint32_t i)
 Return the RIDs related to the ith bundle. More...
 

Protected Member Functions

 bundle (const ibis::selectClause &c)
 
 bundle (const ibis::query &q)
 
 bundle (const ibis::query &q, const ibis::bitvector &hits)
 
 bundle (const ibis::part &t, const ibis::selectClause &s)
 

Protected Attributes

const ibis::selectClausecomps
 
const char * id
 
bool infile
 
ibis::RIDSetrids
 
array_t< uint32_t > * starts
 

Detailed Description

The public interface of bundles.

This is an incore implementation, that is, it stores all relevant values in memory. It is intended to be used only to sort the selected values and immediately write out the content to files.

Given a select clause, its terms are logically re-ordered so that the plain column names are placed before all the functions, such as, "SELECT variable1, variable2, ..., aggregation1, aggregation2, ..." where the relative order of the plain column names are preserved as they appeared on input. The rows/records of the query results are ordered according to the values of the plain columns.

Note
This implementation only works with select clauses containing plain column names and aggregations on plain columns, no arithmetic expressions, no aliases.
The sorting on string-valued columns does NOT produce alphabetical ordering. For categorical values, the sorting is done on the integer version of the data, not on the string values. Therefore, the string will not appear in alphabetically order! However, aggregation functions should still produce correct results. The text values will appear in the order they are in the data files, i.e., the same order as they are inputed. Furthermore, all text values are treated as different because the actual string values are not examined during sorting. DO NOT use text columns with aggregation functions!
When multiple components are selected, a generic version of the sorting algorithm is used. It may be faster to handle special versions separately. For example, if all the selected components are of the same type, it is possible to use a more compact array structure for comparisons. It might be also useful to separate out the cases where there are only two components.

Member Function Documentation

virtual void* ibis::bundle::columnArray ( uint32_t  ) const
inlinevirtual

Return the pointer to the underlying array used to store the jth column of the bundle.

Reimplemented in ibis::bundles, and ibis::bundle1.

virtual ibis::TYPE_T ibis::bundle::columnType ( uint32_t  ) const
inlinevirtual

Return the type used to store the values of the jth column of the bundle.

Reimplemented in ibis::bundles, and ibis::bundle1.

References ibis::UNKNOWN_TYPE.

ibis::bundle * ibis::bundle::create ( const ibis::query q,
int  dir = 0 
)
static

Create new bundle from a query object.

Write info to q.dir().

Parameters
dir
  • > 0 sort RIDs,
  • < 0 do not sort RIDs, leave them in whatever order after sorting the order-by keys,
  • = 0 if FASTBIT_ORDER_OUTPUT_RIDS is defined, sort RIDs, otherwise don't sort.

References ibis::selectClause::aggSize(), ibis::query::components(), ibis::horometer::CPUTime(), ibis::selectClause::empty(), ibis::query::logMessage(), ibis::horometer::realTime(), ibis::horometer::start(), and ibis::horometer::stop().

Referenced by ibis::query::evaluate(), ibis::query::getRIDsInBundle(), ibis::bord::groupbya(), ibis::query::limit(), ibis::query::orderby(), ibis::query::printSelected(), ibis::query::printSelectedWithRID(), and ibis::bord::xgroupby().

int32_t ibis::bundle::getInt ( uint32_t  ,
uint32_t   
) const
virtual

Retrieve a single value.

Return the maximal int value.

Numerical values will be casted into the return type.

Note
Most compilers will emit numerous complains about the potential data loss due to type conversions. User should employ the correct types to avoid actual loss of precision.

Reimplemented in ibis::bundles, and ibis::bundle1.

std::string ibis::bundle::getString ( uint32_t  ,
uint32_t   
) const
virtual

Retrieve a string value.

Return an empty string.

It converts all data types to its string representation through the string stream library.

Note
This is generic, but slow!

Could have thrown an exception, but that seemed to be a little too heavy handed.

Reimplemented in ibis::bundles, and ibis::bundle1.

const ibis::RIDSet * ibis::bundle::readRIDs ( const char *  dir,
const uint32_t  i 
)
static
uint32_t ibis::bundle::rowCounts ( array_t< uint32_t > &  cnt) const

Compute the number of rows in each group(bundle).

Return the number of bundles.

References ibis::array_t< T >::clear(), and ibis::array_t< T >::resize().


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