31 mensa() : nrows(0) {};
32 explicit mensa(
const char* dir);
33 mensa(
const char* dir1,
const char* dir2);
36 virtual uint64_t
nRows()
const {
return nrows;}
44 virtual void describe(std::ostream&)
const;
45 virtual void dumpNames(std::ostream&,
const char*)
const;
46 virtual int dump(std::ostream&,
const char*)
const;
47 virtual int dump(std::ostream&, uint64_t,
const char*)
const;
48 virtual int dump(std::ostream&, uint64_t, uint64_t,
const char*)
const;
49 virtual int backup(
const char* dir,
const char* tname=0,
50 const char* tdesc=0)
const;
56 uint64_t =0, uint64_t =0)
const;
75 uint64_t =0, uint64_t =0)
const;
78 uint64_t =0, uint64_t =0)
const;
81 uint64_t =0, uint64_t =0)
const;
86 double,
double,
double,
87 std::vector<uint32_t>&)
const;
89 double,
double,
double,
91 double,
double,
double,
92 std::vector<uint32_t>&)
const;
94 double,
double,
double,
96 double,
double,
double,
98 double,
double,
double,
99 std::vector<uint32_t>&)
const;
101 virtual void estimate(
const char* cond,
102 uint64_t& nmin, uint64_t& nmax)
const;
104 uint64_t& nmin, uint64_t& nmax)
const;
106 virtual table*
select(
const char* sel,
const char* cond)
const;
107 virtual table*
select2(
const char* sel,
const char* cond,
108 const char* pts)
const;
123 virtual int buildIndex(
const char*,
const char*);
126 virtual const char*
indexSpec(
const char*)
const;
127 virtual void indexSpec(
const char*,
const char*);
148 (reinterpret_cast<const ibis::constPartList&>(parts),
164 virtual uint64_t nRows()
const {
return tab.
nRows();}
165 virtual uint32_t nColumns()
const {
return tab.
nColumns();}
171 virtual int fetch(uint64_t);
175 virtual int dump(std::ostream& out,
const char* del)
const;
177 int dumpBlock(std::ostream& out,
const char* del);
178 int dumpSome(std::ostream& out, uint64_t nr,
const char* del);
220 typedef std::map<const char*, uint32_t, ibis::lessi> bufferMap;
221 std::vector<bufferElement> buffer;
225 unsigned preferred_block_size;
235 int dumpIJ(std::ostream&, uint32_t, uint32_t)
const;
254 liga(
const ibis::partList&);
269 if (curRow < 0 || curPart >= tab.
parts.size() || cn == 0 || *cn == 0)
271 bufferMap::const_iterator it = bufmap.find(cn);
272 if (it != bufmap.end())
280 unsigned char& val)
const {
281 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
283 bufferMap::const_iterator it = bufmap.find(cn);
284 if (it != bufmap.end())
285 return getColumnAsUByte((*it).second, val);
292 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
294 bufferMap::const_iterator it = bufmap.find(cn);
295 if (it != bufmap.end())
296 return getColumnAsShort((*it).second, val);
303 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
305 bufferMap::const_iterator it = bufmap.find(cn);
306 if (it != bufmap.end())
307 return getColumnAsUShort((*it).second, val);
314 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
316 bufferMap::const_iterator it = bufmap.find(cn);
317 if (it != bufmap.end())
318 return getColumnAsInt((*it).second, val);
325 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
327 bufferMap::const_iterator it = bufmap.find(cn);
328 if (it != bufmap.end())
329 return getColumnAsUInt((*it).second, val);
336 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
338 bufferMap::const_iterator it = bufmap.find(cn);
339 if (it != bufmap.end())
340 return getColumnAsLong((*it).second, val);
347 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
349 bufferMap::const_iterator it = bufmap.find(cn);
350 if (it != bufmap.end())
351 return getColumnAsULong((*it).second, val);
358 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
360 bufferMap::const_iterator it = bufmap.find(cn);
361 if (it != bufmap.end())
362 return getColumnAsFloat((*it).second, val);
369 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
371 bufferMap::const_iterator it = bufmap.find(cn);
372 if (it != bufmap.end())
373 return getColumnAsDouble((*it).second, val);
380 std::string& val)
const {
381 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
383 bufferMap::const_iterator it = bufmap.find(cn);
384 if (it != bufmap.end())
385 return getColumnAsString((*it).second, val);
392 ibis::opaque& val)
const {
393 if (curRow < 0 || curPart >= tab.parts.size() || cn == 0 || *cn == 0)
395 bufferMap::const_iterator it = bufmap.find(cn);
396 if (it != bufmap.end())
397 return getColumnAsOpaque((*it).second, val);
404 if (
parts.empty() || nr == 0)
return 0;
406 int ierr = cur.
dumpSome(out, nr, del);
412 const char* del)
const {
413 if (
parts.empty() || nr == 0 || off > nrows)
return 0;
415 int ierr = cur.
fetch(off);
416 if (ierr < 0)
return ierr;
421 #endif // IBIS_MENSA_H
void * cval
!< Column type.
Definition: mensa.h:215
virtual int64_t getColumnAsLongs(const char *, int64_t *, uint64_t=0, uint64_t=0) const
Definition: mensa.cpp:1151
virtual int getColumnAsByte(const char *, char &) const
Definition: mensa.h:268
virtual void describe(std::ostream &) const
!< Return data types.
Definition: mensa.cpp:287
virtual int64_t getColumnAsInts(const char *, int32_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: mensa.cpp:942
virtual int64_t getColumnAsUInts(const char *, uint32_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: mensa.cpp:1065
uint64_t bBegin
!< the first row number of the current partition
Definition: mensa.h:227
int64_t curRow
!< end of the current block
Definition: mensa.h:229
virtual int getColumnAsLong(const char *, int64_t &) const
Definition: mensa.h:335
virtual int getColumnAsUShort(const char *, uint16_t &) const
Definition: mensa.h:302
virtual const char * indexSpec(const char *) const
Retrieve the current indexing option.
Definition: mensa.cpp:308
virtual table * groupby(const char *) const
Directly performing group-by on the base data (without selection) is not currently supported...
Definition: mensa.h:121
virtual int fetch()
Points the the next row.
Definition: mensa.cpp:3103
virtual long getHistogram(const char *, const char *, double, double, double, std::vector< uint32_t > &) const
Definition: mensa.cpp:2657
virtual int getColumnAsULong(const char *, uint64_t &) const
Definition: mensa.h:346
virtual int mergeCategories(const ibis::table::stringArray &)
Merge the dictionaries of categorical value from different data partitions.
Definition: mensa.cpp:383
std::map< const char *, ibis::TYPE_T, ibis::lessi > namesTypes
An associative array of names and types.
Definition: table.h:123
The top level query expression object.
Definition: qExpr.h:36
virtual int64_t getColumnAsDoubles(const char *, double *, uint64_t=0, uint64_t=0) const
Definition: mensa.cpp:1551
A simple struct for storing a row of a table.
Definition: table.h:395
ibis::partList parts
List of data partitions.
Definition: mensa.h:138
virtual table * groupby(const stringArray &) const
Directly performing group-by on the base data (without selection) is not currently supported...
Definition: mensa.h:118
void clear()
Clear the existing content.
Definition: mensa.cpp:235
virtual int getColumnAsDouble(const char *, double &) const
Definition: mensa.h:368
virtual int buildIndex(const char *, const char *)
The following functions deal with auxillary data for accelerating query processing, primarily for building indexes.
Definition: mensa.cpp:345
virtual int dump(std::ostream &, const char *) const
Print the values in ASCII form to the specified output stream.
Definition: mensa.cpp:2797
virtual double getColumnMax(const char *) const
Compute the maximum of all valid values in the name column.
Definition: mensa.cpp:2638
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
Cursor class for row-wise data accesses.
Definition: table.h:835
int64_t computeHits(const char *cond) const
Compute the number of hits.
Definition: mensa.h:146
virtual ibis::table::cursor * createCursor() const
Create a cursor object to perform row-wise data access.
Definition: mensa.cpp:2816
virtual uint64_t getCurrentRowNumber() const
Return the current row number.
Definition: mensa.h:174
int dumpSome(std::ostream &out, uint64_t nr, const char *del)
Print the next nr rows of the table to the specified output stream.
Definition: mensa.cpp:3436
virtual void orderby(const stringArray &)=0
Reorder the rows.
void clearBuffers()
!< the current row number
Definition: mensa.cpp:3059
virtual int64_t getColumnAsULongs(const char *, uint64_t *, uint64_t=0, uint64_t=0) const
Definition: mensa.cpp:1319
virtual int64_t getColumnAsStrings(const char *, std::vector< std::string > &, uint64_t=0, uint64_t=0) const
Convert values to their string form.
Definition: mensa.cpp:1967
virtual long getHistogram2D(const char *, const char *, double, double, double, const char *, double, double, double, std::vector< uint32_t > &) const
Compute a two-dimension histogram on columns cname1 and cname2.
Definition: mensa.cpp:2695
A buffer element is a minimal data structure to store a column in memory.
Definition: mensa.h:212
virtual int addPartition(const char *)
Add data partitions defined in the named directory.
Definition: mensa.cpp:123
uint64_t bEnd
!< the first row number of the current block
Definition: mensa.h:228
ibis::table::namesTypes naty
A combined list of columns names.
Definition: mensa.h:140
virtual int64_t getColumnAsOpaques(const char *, std::vector< ibis::opaque > &, uint64_t=0, uint64_t=0) const
Retrieve the blobs as ibis::opaque objects.
Definition: mensa.cpp:2291
int dumpIJ(std::ostream &, uint32_t, uint32_t) const
Print the ith element in the current block for column j.
Definition: mensa.cpp:3503
virtual int addPartition(const char *)
The list of partitions in this class can NOT be expanded or otherwise modified.
Definition: mensa.h:259
static int64_t computeHits(const ibis::constPartList &parts, const char *cond)
Compute the number of rows satisfying the specified conditions.
Definition: mensa.cpp:4752
virtual uint32_t nColumns() const
Number of columns.
Definition: mensa.cpp:254
virtual int64_t getColumnAsFloats(const char *, float *, uint64_t=0, uint64_t=0) const
Definition: mensa.cpp:1427
virtual double getColumnMin(const char *) const
Compute the minimum of all valid values in the name column.
Definition: mensa.cpp:2619
virtual int64_t getColumnAsUBytes(const char *, unsigned char *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: mensa.cpp:783
virtual int getColumnAsUInt(const char *, uint32_t &) const
Definition: mensa.h:324
int fillBuffers() const
Fill the buffers for every column.
Definition: mensa.cpp:2983
virtual table * select2(const char *sel, const char *cond, const char *pts) const
A variation of the function select defined in ibis::table.
Definition: mensa.cpp:638
The abstract table class.
Definition: table.h:77
ibis::array_t< ibis::TYPE_T > typeArray
A list of data types.
Definition: table.h:117
virtual long getHistogram3D(const char *, const char *, double, double, double, const char *, double, double, double, const char *, double, double, double, std::vector< uint32_t > &) const
Compute a three-dimensional histogram on the named columns.
Definition: mensa.cpp:2742
virtual int getColumnAsOpaque(const char *, ibis::opaque &) const
Definition: mensa.h:391
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
TYPE_T
Supported data types.
Definition: table.h:25
virtual int getColumnAsShort(const char *, int16_t &) const
Definition: mensa.h:291
virtual int getPartitions(ibis::constPartList &) const
Retrieve the list of partitions.
Definition: mensa.cpp:222
virtual void orderby(const char *str)
Reorder the rows. The column names are separated by commas.
Definition: mensa.h:112
virtual int dropPartition(const char *)
Remove the named data partition from this data table.
Definition: mensa.cpp:170
virtual int getColumnAsFloat(const char *, float &) const
Definition: mensa.h:357
ibis::array_t< const char * > stringArray
A list of strings.
Definition: table.h:114
~bufferElement()
Destructor for bufferElement.
Definition: mensa.cpp:4239
virtual int buildIndexes(const char *)
Create indexes for every column of the table.
Definition: mensa.cpp:367
Class ibis::mensa contains multiple (horizontal) data partitions (ibis::part) to form a logical data ...
Definition: mensa.h:29
virtual int64_t getColumnAsBytes(const char *, char *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: mensa.cpp:746
virtual int64_t getColumnAsShorts(const char *, int16_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: mensa.cpp:820
int dumpBlock(std::ostream &out, const char *del)
Print out the content of the current block.
Definition: mensa.cpp:3385
virtual int backup(const char *dir, const char *tname=0, const char *tdesc=0) const
Write the current content to the specified output directory in the raw binary format.
Definition: mensa.cpp:2809
~liga()
Ibis::liga does not own the data partitions and does not free the resources in those partitions...
Definition: mensa.cpp:4282
virtual void dumpNames(std::ostream &, const char *) const
Print all column names on one line.
Definition: mensa.cpp:298
A specialization of class mensa.
Definition: mensa.h:251
Unknown type, a place holder. Can not process data of this type!
Definition: table.h:27
virtual uint64_t nRows() const
The number of rows in this table.
Definition: mensa.h:36
virtual table * select(const char *sel, const char *cond) const =0
Given a set of column names and a set of selection conditions, compute another table that represents ...
virtual int64_t getColumnAsUShorts(const char *, uint16_t *, uint64_t=0, uint64_t=0) const
Retrieve all values of the named column.
Definition: mensa.cpp:881
virtual void estimate(const char *cond, uint64_t &nmin, uint64_t &nmax) const
Estimate the number of rows satisfying the selection conditions.
Definition: mensa.cpp:528
virtual int getColumnAsUByte(const char *, unsigned char &) const
Definition: mensa.h:279
virtual void orderby(const stringArray &, const std::vector< bool > &)
Reordering the rows using the specified columns.
Definition: mensa.cpp:733
ibis::TYPE_T ctype
!< Column name.
Definition: mensa.h:214
int fillBuffer(uint32_t) const
Fill the buffer for variable number i.
Definition: mensa.cpp:2885
virtual int dump(std::ostream &out, const char *del) const
Print the current row.
Definition: mensa.cpp:3348
virtual typeArray columnTypes() const
Return the column types in a list.
Definition: mensa.cpp:277
virtual int getColumnAsInt(const char *, int32_t &) const
Definition: mensa.h:313
virtual table * select(const char *sel, const char *cond) const
Given a set of column names and a set of selection conditions, compute another table that represents ...
Definition: mensa.cpp:586
virtual void reverseRows()
Reversing the ordering of the rows on disk requires too much work but has no obvious benefit...
Definition: mensa.h:115
virtual int getColumnAsString(const char *, std::string &) const
Definition: mensa.h:379
bufferElement()
!< Pointer to raw data.
Definition: mensa.h:217
virtual stringArray columnNames() const
Return the column names in a list.
Definition: mensa.cpp:266