table.h
Go to the documentation of this file.
1 // File: $Id$
2 // Author: John Wu <John.Wu at ACM.org>
3 // Copyright (c) 2007-2016 the Regents of the University of California
4 #ifndef IBIS_TABLE_H
5 #define IBIS_TABLE_H
6 
16 #include <iostream> // std::ostream
17 #include <vector> // std::vector
18 #include <map> // std::map
19 #include <string> // std::string
20 #include "const.h" // intxx_t, uintxx_t, ... from stdint.h
21 
22 namespace ibis {
23 
25  enum TYPE_T {
29  OID,
30  BYTE,
34  INT,
35  UINT,
36  LONG,
40  BIT,
41  CATEGORY,
59  };
61  FASTBIT_CXX_DLLSPEC extern const char** TYPESTRING;
62 
63  class table;
64  class tablex;
65  class tableList;
66 } // namespace ibis
67 
77 class FASTBIT_CXX_DLLSPEC ibis::table {
78 public:
82  static ibis::table* create(ibis::part&);
86  static ibis::table* create(const ibis::partList&);
90  static ibis::table* create(const char* dir);
96  static ibis::table* create(const char* dir1, const char* dir2);
97 
99  virtual ~table() {};
100 
103  virtual const char* name() const {return name_.c_str();}
105  virtual const char* description() const {return desc_.c_str();}
107  virtual uint64_t nRows() const =0;
109  virtual uint32_t nColumns() const =0;
110 
115  typedef std::vector<const char*> stringVector;
123  typedef std::map<const char*, ibis::TYPE_T, ibis::lessi> namesTypes;
124 
125  virtual stringArray columnNames() const =0;
126  virtual typeArray columnTypes() const =0;
127 
129  virtual void describe(std::ostream&) const =0;
131  virtual void dumpNames(std::ostream& out, const char* del=", ") const =0;
135  virtual int dump(std::ostream& out, const char* del=", ") const =0;
137  virtual int dump(std::ostream& out, uint64_t nr,
138  const char* del=", ") const =0;
141  virtual int dump(std::ostream& out, uint64_t offset, uint64_t nr,
142  const char* del=", ") const =0;
146  virtual int backup(const char* dir, const char* tname=0,
147  const char* tdesc=0) const =0;
148 
151  virtual void estimate(const char* cond,
152  uint64_t& nmin, uint64_t& nmax) const =0;
155  virtual void estimate(const ibis::qExpr* cond,
156  uint64_t& nmin, uint64_t& nmax) const =0;
159  virtual table* select(const char* sel, const char* cond) const =0;
162  virtual table* select(const char* sel, const ibis::qExpr* cond) const;
163 
165  static table* select(const ibis::constPartList& parts,
166  const char* sel, const char* cond);
168  static table* select(const ibis::constPartList& parts,
169  const char* sel, const ibis::qExpr* cond);
171  static int64_t computeHits(const ibis::constPartList& parts,
172  const char* cond);
174  static int64_t computeHits(const ibis::constPartList& parts,
175  const ibis::qExpr* cond);
176 
183  virtual table* groupby(const stringArray&) const =0;
186  virtual table* groupby(const char*) const;
194  virtual void orderby(const stringArray&)=0;
195  virtual void orderby(const stringArray&, const std::vector<bool>&)=0;
197  virtual void orderby(const char*);
199  virtual void reverseRows()=0;
200 
213  virtual int addPartition(const char*) {return -1;}
223  virtual int dropPartition(const char*) {return -1;}
225  virtual int getPartitions(ibis::constPartList&) const {
226  return -1;}
227 
242  virtual int buildIndex(const char* colname, const char* option=0) =0;
247  virtual int buildIndexes(const char* options) =0;
248  virtual int buildIndexes(const stringArray&) =0;
251  virtual const char* indexSpec(const char* colname=0) const =0;
254  virtual void indexSpec(const char* opt, const char* colname=0) =0;
266  virtual int mergeCategories(const stringArray&) {return 0;}
268 
290  virtual int64_t
291  getColumnAsBytes(const char* cname, char* vals,
292  uint64_t begin=0, uint64_t end=0) const =0;
293  virtual int64_t
294  getColumnAsUBytes(const char* cname, unsigned char* vals,
295  uint64_t begin=0, uint64_t end=0) const =0;
296  virtual int64_t
297  getColumnAsShorts(const char* cname, int16_t* vals,
298  uint64_t begin=0, uint64_t end=0) const =0;
299  virtual int64_t
300  getColumnAsUShorts(const char* cname, uint16_t* vals,
301  uint64_t begin=0, uint64_t end=0) const =0;
302  virtual int64_t
303  getColumnAsInts(const char* cname, int32_t* vals,
304  uint64_t begin=0, uint64_t end=0) const =0;
305  virtual int64_t
306  getColumnAsUInts(const char* cname, uint32_t* vals,
307  uint64_t begin=0, uint64_t end=0) const =0;
308  virtual int64_t
309  getColumnAsLongs(const char* cname, int64_t* vals,
310  uint64_t begin=0, uint64_t end=0) const =0;
311  virtual int64_t
312  getColumnAsULongs(const char* cname, uint64_t* vals,
313  uint64_t begin=0, uint64_t end=0) const =0;
314  virtual int64_t
315  getColumnAsFloats(const char* cname, float* vals,
316  uint64_t begin=0, uint64_t end=0) const =0;
317  virtual int64_t
318  getColumnAsDoubles(const char* cname, double* vals,
319  uint64_t begin=0, uint64_t end=0) const =0;
320  virtual int64_t
321  getColumnAsDoubles(const char* cname, std::vector<double>& vals,
322  uint64_t begin=0, uint64_t end=0) const =0;
326  virtual int64_t
327  getColumnAsStrings(const char* cname, std::vector<std::string>& vals,
328  uint64_t begin=0, uint64_t end=0) const =0;
331  virtual int64_t
332  getColumnAsOpaques(const char* cname, std::vector<ibis::opaque>& vals,
333  uint64_t begin=0, uint64_t end=0) const =0;
334 
340  virtual double getColumnMin(const char* cname) const =0;
346  virtual double getColumnMax(const char* cname) const =0;
348 
362  virtual long getHistogram(const char* constraints,
363  const char* cname,
364  double begin, double end, double stride,
365  std::vector<uint32_t>& counts) const =0;
372  virtual long getHistogram2D(const char* constraints,
373  const char* cname1,
374  double begin1, double end1, double stride1,
375  const char* cname2,
376  double begin2, double end2, double stride2,
377  std::vector<uint32_t>& counts) const =0;
384  virtual long getHistogram3D(const char* constraints,
385  const char* cname1,
386  double begin1, double end1, double stride1,
387  const char* cname2,
388  double begin2, double end2, double stride2,
389  const char* cname3,
390  double begin3, double end3, double stride3,
391  std::vector<uint32_t>& counts) const =0;
393 
395  struct row {
396  std::vector<std::string> bytesnames;
397  std::vector<signed char> bytesvalues;
398  std::vector<std::string> ubytesnames;
399  std::vector<unsigned char> ubytesvalues;
400  std::vector<std::string> shortsnames;
401  std::vector<int16_t> shortsvalues;
402  std::vector<std::string> ushortsnames;
403  std::vector<uint16_t> ushortsvalues;
404  std::vector<std::string> intsnames;
405  std::vector<int32_t> intsvalues;
406  std::vector<std::string> uintsnames;
407  std::vector<uint32_t> uintsvalues;
408  std::vector<std::string> longsnames;
409  std::vector<int64_t> longsvalues;
410  std::vector<std::string> ulongsnames;
411  std::vector<uint64_t> ulongsvalues;
412  std::vector<std::string> floatsnames;
413  std::vector<float> floatsvalues;
414  std::vector<std::string> doublesnames;
415  std::vector<double> doublesvalues;
416  std::vector<std::string> catsnames;
417  std::vector<std::string> catsvalues;
418  std::vector<std::string> textsnames;
419  std::vector<std::string> textsvalues;
420  std::vector<std::string> blobsnames;
421  std::vector<ibis::opaque> blobsvalues;
422 
424  void clear();
426  void clearValues();
428  uint32_t nColumns() const {
429  return bytesvalues.size() + ubytesvalues.size() +
430  shortsvalues.size() + ushortsvalues.size() +
431  intsvalues.size() + uintsvalues.size() +
432  longsvalues.size() + ulongsvalues.size() +
433  floatsvalues.size() + doublesvalues.size() +
434  catsvalues.size() + textsvalues.size() + blobsvalues.size();}
435  }; // struct row
436 
437  // Cursor class for row-wise data accesses.
438  class cursor;
440  virtual cursor* createCursor() const =0;
441 
442  static void* allocateBuffer(ibis::TYPE_T, size_t);
443  static void freeBuffer(void* buffer, ibis::TYPE_T type);
444  static void freeBuffers(bufferArray&, typeArray&);
445 
446 
447  static void parseNames(char* in, stringVector& out);
448  static void parseNames(char* in, stringArray& out);
449  static void parseOrderby(char* in, stringArray& out,
450  std::vector<bool>& direc);
451  static bool isValidName(const char*);
452  static void consecrateName(char*);
453 
454 protected:
455 
456  std::string name_;
457  std::string desc_;
458 
460  table() {};
462  table(const char* na, const char* de)
463  : name_(na?na:""), desc_(de?de:na?na:"") {};
464 
465 private:
466  // re-enforce the prohibitions on copying and assignment.
467  table(const table&);
468  table& operator=(const table&);
469 }; // class ibis::table
470 
483 class FASTBIT_CXX_DLLSPEC ibis::tablex {
484 public:
486  static ibis::tablex* create();
487 // /// Make the incoming table expandable. Not yet implemented
488 // static ibis::tablex* makeExtensible(ibis::table* t);
489 
490  virtual ~tablex() {}; // nothing to do.
491 
493  virtual int addColumn(const char* cname, ibis::TYPE_T ctype,
494  const char* cdesc=0, const char* idx=0) =0;
495 
516  virtual int append(const char* cname, uint64_t begin, uint64_t end,
517  void* values) =0;
518 
548  virtual int appendRow(const ibis::table::row&) =0;
554  virtual int appendRow(const char* line, const char* delimiters=0) = 0;
562  virtual int appendRows(const std::vector<ibis::table::row>&) =0;
563 
597  virtual int readCSV(const char* inputfile, int memrows=0,
598  const char* outputdir=0, const char* delimiters=0) =0;
612  virtual int readSQLDump(const char* inputfile, std::string& tname,
613  int memrows=0, const char* outputdir=0) =0;
614 
616  virtual int readNamesAndTypes(const char* filename);
618  virtual int parseNamesAndTypes(const char* txt);
619 
660  virtual int write(const char* dir, const char* tname=0,
661  const char* tdesc=0, const char* idx=0,
662  const char* nvpairs=0) const =0;
676  virtual int writeMetaData(const char* dir, const char* tname=0,
677  const char* tdesc=0, const char* idx=0,
678  const char* nvpairs=0) const =0;
679 
683  virtual void clearData() =0;
695  virtual int32_t reserveBuffer(uint32_t) {return 0;}
705  virtual uint32_t bufferCapacity() const {return 0;}
706 
709  virtual uint32_t mRows() const =0;
711  virtual uint32_t mColumns() const =0;
713  virtual void describe(std::ostream&) const =0;
714 
720  virtual table* toTable(const char* nm=0, const char* de=0) =0;
721 
723  virtual void setPartitionMax(uint32_t m) {maxpart=m;}
725  virtual uint32_t getPartitionMax() const {return maxpart;}
728  virtual void setASCIIDictionary(const char*, const char*) =0;
731  virtual const char* getASCIIDictionary(const char*) const =0;
732 
733 protected:
736  tablex() : maxpart(0), ipart(0) {};
737 
739  uint32_t maxpart;
741  mutable uint32_t ipart;
742 
743 private:
744  tablex(const tablex&); // no copying
745  tablex& operator=(const tablex&); // no assignment
746 }; // class ibis::tablex
747 
751 class FASTBIT_CXX_DLLSPEC ibis::tableList {
752 public:
753  typedef std::map< const char*, ibis::table*, ibis::lessi > tableSet;
754  typedef tableSet::const_iterator iterator;
755 
758  bool empty() const {return tables.empty();}
760  uint32_t size() const {return tables.size();}
762  iterator begin() const {return tables.begin();}
766  iterator end() const {return tables.end();}
767 
770  const ibis::table* operator[](const char* tname) const {
771  tableSet::const_iterator it = tables.find(tname);
772  if (it != tables.end())
773  return (*it).second;
774  else
775  return 0;
776  }
777 
783  void add(ibis::table*& tb) {
784  tableSet::iterator it = tables.find(tb->name());
785  if (it == tables.end()) {
786  tables[tb->name()] = tb;
787  tb=0;
788  }
789  else {
790  ibis::table* tmp = (*it).second;
791  tables[tb->name()] = tb;
792  tb = tmp;
793  }
794  }
795 
799  void remove(const char* tname) {
800  tableSet::iterator it = tables.find(tname);
801  if (it != tables.end()) {
802  ibis::table* tmp = (*it).second;
803  tables.erase(it);
804  delete tmp;
805  }
806  }
807 
809  tableList() {};
810 
813  while (! tables.empty()) {
814  tableSet::iterator it = tables.begin();
815  ibis::table* tmp = (*it).second;
816  tables.erase(it);
817  delete tmp;
818  }
819  }
820 
821 private:
823  tableSet tables;
824 
825  // Can not copy or assign.
826  tableList(const tableList&);
827  tableList& operator=(const tableList&);
828 }; // ibis::tableList
829 
835 class FASTBIT_CXX_DLLSPEC ibis::table::cursor {
836 public:
837  virtual ~cursor() {};
838  virtual uint64_t nRows() const =0;
839  virtual uint32_t nColumns() const =0;
840  virtual ibis::table::typeArray columnTypes() const =0;
841  virtual ibis::table::stringArray columnNames() const =0;
844  virtual int fetch() =0;
848  virtual int fetch(uint64_t rownum) =0;
853  virtual uint64_t getCurrentRowNumber() const =0;
854 
857  virtual int fetch(ibis::table::row&) =0;
860  virtual int fetch(uint64_t rownum, ibis::table::row&) =0;
861 
863  virtual int dump(std::ostream& out, const char* del=", ") const =0;
864 
874  virtual int getColumnAsByte(const char* cname, char&) const =0;
875  virtual int getColumnAsUByte(const char* cname, unsigned char&) const =0;
876  virtual int getColumnAsShort(const char* cname, int16_t&) const =0;
877  virtual int getColumnAsUShort(const char* cname, uint16_t&) const =0;
878  virtual int getColumnAsInt(const char* cname, int32_t&) const =0;
879  virtual int getColumnAsUInt(const char* cname, uint32_t&) const =0;
880  virtual int getColumnAsLong(const char* cname, int64_t&) const =0;
881  virtual int getColumnAsULong(const char* cname, uint64_t&) const =0;
882  virtual int getColumnAsFloat(const char* cname, float&) const =0;
883  virtual int getColumnAsDouble(const char* cname, double&) const =0;
884  virtual int getColumnAsString(const char* cname, std::string&) const =0;
885  virtual int getColumnAsOpaque(const char* cname, ibis::opaque&) const =0;
887 
899  virtual int getColumnAsByte(uint32_t cnum, char& val) const =0;
900  virtual int getColumnAsUByte(uint32_t cnum, unsigned char& val) const =0;
901  virtual int getColumnAsShort(uint32_t cnum, int16_t& val) const =0;
902  virtual int getColumnAsUShort(uint32_t cnum, uint16_t& val) const =0;
903  virtual int getColumnAsInt(uint32_t cnum, int32_t& val) const =0;
904  virtual int getColumnAsUInt(uint32_t cnum, uint32_t& val) const =0;
905  virtual int getColumnAsLong(uint32_t cnum, int64_t& val) const =0;
906  virtual int getColumnAsULong(uint32_t cnum, uint64_t& val) const =0;
907  virtual int getColumnAsFloat(uint32_t cnum, float& val) const =0;
908  virtual int getColumnAsDouble(uint32_t cnum, double& val) const =0;
909  virtual int getColumnAsString(uint32_t cnum, std::string& val) const =0;
910  virtual int getColumnAsOpaque(uint32_t cnum, ibis::opaque& val) const =0;
912 
913 protected:
914  cursor() {};
915  cursor(const cursor&); // not implemented
916  cursor& operator=(const cursor&) ; // not implemented
917 }; // ibis::table::cursor
918 
919 inline void ibis::table::row::clear() {
920  bytesnames.clear();
921  bytesvalues.clear();
922  ubytesnames.clear();
923  ubytesvalues.clear();
924  shortsnames.clear();
925  shortsvalues.clear();
926  ushortsnames.clear();
927  ushortsvalues.clear();
928  intsnames.clear();
929  intsvalues.clear();
930  uintsnames.clear();
931  uintsvalues.clear();
932  longsnames.clear();
933  longsvalues.clear();
934  ulongsnames.clear();
935  ulongsvalues.clear();
936  floatsnames.clear();
937  floatsvalues.clear();
938  doublesnames.clear();
939  doublesvalues.clear();
940  catsnames.clear();
941  catsvalues.clear();
942  textsnames.clear();
943  textsvalues.clear();
944  blobsnames.clear();
945  blobsvalues.clear();
946 } // ibis::table::row::clear
947 
949  bytesvalues.clear();
950  ubytesvalues.clear();
951  shortsvalues.clear();
952  ushortsvalues.clear();
953  intsvalues.clear();
954  uintsvalues.clear();
955  longsvalues.clear();
956  ulongsvalues.clear();
957  floatsvalues.clear();
958  doublesvalues.clear();
959  catsvalues.clear();
960  textsvalues.clear();
961  blobsvalues.clear();
962 } // ibis::table::row::clearValues
963 #endif // IBIS_TABLE_H
std::vector< unsigned char > ubytesvalues
!< For ibis::UBYTE.
Definition: table.h:399
std::vector< double > doublesvalues
!< For ibis::DOUBLE.
Definition: table.h:415
std::vector< ibis::opaque > blobsvalues
!< For ibis::BLOB
Definition: table.h:421
virtual int backup(const char *dir, const char *tname=0, const char *tdesc=0) const =0
Write the current content to the specified output directory in the raw binary format.
virtual int appendRow(const ibis::table::row &)=0
Add one row.
static bool isValidName(const char *)
Is the given string a valid FastBit name for a data column?
Definition: mensa.cpp:4595
!< One bit per record, represented by a bit vector.
Definition: table.h:44
virtual int dropPartition(const char *)
Remove the named data partition from this data table.
Definition: table.h:223
virtual int dump(std::ostream &out, const char *del=", ") const =0
Print the values in ASCII form to the specified output stream.
std::vector< int32_t > intsvalues
!< For ibis::INT.
Definition: table.h:405
std::string desc_
!< Name of the table.
Definition: table.h:457
virtual int64_t getColumnAsULongs(const char *cname, uint64_t *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual int dump(std::ostream &out, const char *del=", ") const =0
Print out the values of the current row.
static ibis::tablex * create()
Create a minimalistic table exclusively for entering new records.
Definition: tafel.cpp:3943
User-defined type. FastBit does not know much about it.
Definition: table.h:58
virtual void describe(std::ostream &) const =0
!< Return data types.
virtual long getHistogram2D(const char *constraints, const char *cname1, double begin1, double end1, double stride1, const char *cname2, double begin2, double end2, double stride2, std::vector< uint32_t > &counts) const =0
Compute a two-dimension histogram on columns cname1 and cname2.
virtual int mergeCategories(const stringArray &)
Merge the dictionaries of categorical value from different data partitions.
Definition: table.h:266
iterator end() const
Return the iterator to the end of the list.
Definition: table.h:766
virtual void describe(std::ostream &) const =0
Print a description of the table to the specified output stream.
virtual table * groupby(const stringArray &) const =0
Perform aggregate functions on the current table.
static void consecrateName(char *)
Remove unallowed characters from the given string to produce a valid column name. ...
Definition: mensa.cpp:4618
tablex()
Protected default constructor.
Definition: table.h:736
virtual int getColumnAsInt(const char *cname, int32_t &) const =0
virtual int getColumnAsUInt(const char *cname, uint32_t &) const =0
std::vector< std::string > textsvalues
!< For ibis::TEXT.
Definition: table.h:419
virtual int64_t getColumnAsFloats(const char *cname, float *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual double getColumnMax(const char *cname) const =0
Compute the maximum of all valid values in the name column.
virtual void clearData()=0
Remove all data recorded.
virtual int readSQLDump(const char *inputfile, std::string &tname, int memrows=0, const char *outputdir=0)=0
Read a SQL dump from database systems such as MySQL.
std::map< const char *, ibis::TYPE_T, ibis::lessi > namesTypes
An associative array of names and types.
Definition: table.h:123
!< Four-byte signed integers, internally int32_t.
Definition: table.h:35
The top level query expression object.
Definition: qExpr.h:36
static ibis::table * create(ibis::part &)
Create a simple of container of a partition.
Definition: mensa.cpp:4371
A simple struct for storing a row of a table.
Definition: table.h:395
virtual int buildIndexes(const char *options)=0
Create indexes for every column of the table.
static void parseNames(char *in, stringVector &out)
Parse the incoming string into a set of names.
Definition: mensa.cpp:4483
bool empty() const
Is the list empty? Returns true if the list is empty, otherwise returns false.
Definition: table.h:758
virtual void setASCIIDictionary(const char *, const char *)=0
Set the name of the ASCII dictionary file for a column of categorical values.
virtual uint32_t getPartitionMax() const
Get the recommended number of rows in a data partition.
Definition: table.h:725
Byte array.
Definition: table.h:56
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
std::vector< uint64_t > ulongsvalues
!< For ibis::ULONG.
Definition: table.h:411
Cursor class for row-wise data accesses.
Definition: table.h:835
!< Eight-byte unsigned integers, internally uint64_t.
Definition: table.h:38
tableList()
Default constructor.
Definition: table.h:809
static void freeBuffers(bufferArray &, typeArray &)
Freeing a list of buffers.
Definition: bord.cpp:5155
virtual int getColumnAsShort(const char *cname, int16_t &) const =0
virtual int write(const char *dir, const char *tname=0, const char *tdesc=0, const char *idx=0, const char *nvpairs=0) const =0
Write the in-memory data records to the specified directory and update the metadata on disk...
virtual uint32_t mColumns() const =0
The number of columns in this table.
uint32_t maxpart
Recommended size of data partitions to be created.
Definition: table.h:736
virtual void orderby(const stringArray &)=0
Reorder the rows.
void clearValues()
Clear the content of arrays of values. Leave the names alone.
Definition: table.h:948
!< Two-byte unsigned integers, internally uint16_t.
Definition: table.h:34
uint32_t nColumns() const
The number of columns in the row.
Definition: table.h:428
virtual int getColumnAsUByte(const char *cname, unsigned char &) const =0
virtual const char * name() const
Name of the table.
Definition: table.h:103
virtual int buildIndex(const char *colname, const char *option=0)=0
The following functions deal with auxillary data for accelerating query processing, primarily for building indexes.
The class for expandable tables.
Definition: table.h:483
virtual int getColumnAsLong(const char *cname, int64_t &) const =0
virtual int32_t reserveBuffer(uint32_t)
Reserve enough buffer space for the specified number of rows.
Definition: table.h:695
std::vector< signed char > bytesvalues
!< For ibis::BYTE.
Definition: table.h:397
virtual void reverseRows()=0
Reverse the order of the rows.
Arbitrary null-terminated strings.
Definition: table.h:51
virtual uint64_t getCurrentRowNumber() const =0
Return the current row number.
virtual int getColumnAsString(const char *cname, std::string &) const =0
virtual int append(const char *cname, uint64_t begin, uint64_t end, void *values)=0
Add values to the named column.
void add(ibis::table *&tb)
Add a new table object to the list.
Definition: table.h:783
virtual int writeMetaData(const char *dir, const char *tname=0, const char *tdesc=0, const char *idx=0, const char *nvpairs=0) const =0
Write out the information about the columns.
!< Two-byte signed integers, internally int16_t.
Definition: table.h:33
!< Eight-byte signed integers, internally int64_t.
Definition: table.h:37
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 int parseNamesAndTypes(const char *txt)
Parse names and data types in string form.
Definition: tafel.cpp:4085
!< One-byte unsigned integers, internally unsigned char.
Definition: table.h:32
iterator begin() const
Return the iterator to the first table.
Definition: table.h:762
virtual int64_t getColumnAsInts(const char *cname, int32_t *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual ~table()
Destructor.
Definition: table.h:99
std::vector< uint32_t > uintsvalues
!< For ibis::UINT.
Definition: table.h:407
std::vector< int64_t > longsvalues
!< For ibis::LONG.
Definition: table.h:409
The abstract table class.
Definition: table.h:77
!< Four-byte IEEE floating-point numbers, internally float.
Definition: table.h:39
ibis::array_t< ibis::TYPE_T > typeArray
A list of data types.
Definition: table.h:117
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
TYPE_T
Supported data types.
Definition: table.h:25
void clear()
Clear all names and values.
Definition: table.h:919
virtual int64_t getColumnAsUInts(const char *cname, uint32_t *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual int64_t getColumnAsUShorts(const char *cname, uint16_t *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual int getColumnAsByte(const char *cname, char &) const =0
virtual int64_t getColumnAsUBytes(const char *cname, unsigned char *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
!< Eight-byte IEEE floating-point numbers, internally double.
Definition: table.h:40
virtual int getColumnAsDouble(const char *cname, double &) const =0
virtual const char * indexSpec(const char *colname=0) const =0
Retrieve the current indexing option.
std::vector< uint16_t > ushortsvalues
!< For ibis::USHORT.
Definition: table.h:403
table()
!< Description of the table.
Definition: table.h:460
ibis::array_t< const char * > stringArray
A list of strings.
Definition: table.h:114
static void parseOrderby(char *in, stringArray &out, std::vector< bool > &direc)
Parse the incoming string as an order-by clause.
Definition: mensa.cpp:4402
virtual int64_t getColumnAsShorts(const char *cname, int16_t *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual int64_t getColumnAsBytes(const char *cname, char *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
table(const char *na, const char *de)
Constructor. Use the user-supplied name and description.
Definition: table.h:462
A special eight-byte ID type for internal use.
Definition: table.h:29
const ibis::table * operator[](const char *tname) const
Find the named table.
Definition: table.h:770
virtual long getHistogram3D(const char *constraints, const char *cname1, double begin1, double end1, double stride1, const char *cname2, double begin2, double end2, double stride2, const char *cname3, double begin3, double end3, double stride3, std::vector< uint32_t > &counts) const =0
Compute a three-dimensional histogram on the named columns.
std::vector< float > floatsvalues
!< For ibis::FLOAT.
Definition: table.h:413
Defines common data types, constants and macros.
void clear(ibis::array_t< ibis::bitvector * > &bv)
Clear an array of bit vectors.
Definition: bitvector.cpp:4662
static void freeBuffer(void *buffer, ibis::TYPE_T type)
Freeing a buffer for storing in-memory values.
Definition: bord.cpp:5099
virtual double getColumnMin(const char *cname) const =0
Compute the minimum of all valid values in the name column.
virtual int getColumnAsUShort(const char *cname, uint16_t &) const =0
virtual void setPartitionMax(uint32_t m)
Set the recommended number of rows in a data partition.
Definition: table.h:723
virtual const char * description() const
Free text description. May return a null pointer.
Definition: table.h:105
virtual int64_t getColumnAsDoubles(const char *cname, double *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual typeArray columnTypes() const =0
!< Return column names.
Unknown type, a place holder. Can not process data of this type!
Definition: table.h:27
virtual const char * getASCIIDictionary(const char *) const =0
Retrieve the name of the ASCII dictionary file associated with a column of categorical values...
virtual int addPartition(const char *)
Add a data partition defined in the named directory.
Definition: table.h:213
virtual void estimate(const char *cond, uint64_t &nmin, uint64_t &nmax) const =0
Estimate the number of rows satisfying the selection conditions.
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 ...
A list of tables.
Definition: table.h:751
std::vector< int16_t > shortsvalues
!< For ibis::SHORT.
Definition: table.h:401
uint32_t ipart
Current partition number being used for writing.
Definition: table.h:741
!< One-byte signed integers, internally char.
Definition: table.h:31
virtual void dumpNames(std::ostream &out, const char *del=", ") const =0
Print all column names on one line.
const char * delimiters
Delimiters used to separate a string of names.
Definition: util.cpp:71
virtual int getColumnAsOpaque(const char *cname, ibis::opaque &) const =0
virtual int getColumnAsULong(const char *cname, uint64_t &) const =0
virtual int64_t getColumnAsLongs(const char *cname, int64_t *vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve all values of the named column.
virtual uint32_t mRows() const =0
The number of rows in memory.
virtual table * toTable(const char *nm=0, const char *de=0)=0
Stop expanding the current set of data records.
virtual int getPartitions(ibis::constPartList &) const
Retrieve the list of partitions.
Definition: table.h:225
const char ** TYPESTRING
Human readable version of the enumeration types.
Definition: column.cpp:39
virtual int fetch()=0
Make the next row of the data set available for retrieval.
std::vector< std::string > catsvalues
!< For ibis::CATEGORY.
Definition: table.h:417
!< Four-byte unsigned integers, internally uint32_t.
Definition: table.h:36
virtual int64_t getColumnAsOpaques(const char *cname, std::vector< ibis::opaque > &vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve the blobs as ibis::opaque objects.
virtual int readNamesAndTypes(const char *filename)
Read a file containing the names and types of columns.
Definition: tafel.cpp:3956
virtual uint32_t bufferCapacity() const
Capacity of the memory buffer.
Definition: table.h:705
virtual uint64_t nRows() const =0
The number of rows in this table.
virtual long getHistogram(const char *constraints, const char *cname, double begin, double end, double stride, std::vector< uint32_t > &counts) const =0
virtual int getColumnAsFloat(const char *cname, float &) const =0
ibis::array_t< void * > bufferArray
A list to hold the in-memory buffers.
Definition: table.h:121
virtual int64_t getColumnAsStrings(const char *cname, std::vector< std::string > &vals, uint64_t begin=0, uint64_t end=0) const =0
Retrieve the null-terminated strings as a vector of std::string objects.
uint32_t size() const
Return the number of tables in the list.
Definition: table.h:760
virtual int readCSV(const char *inputfile, int memrows=0, const char *outputdir=0, const char *delimiters=0)=0
Read the content of the named file as comma-separated values.
~tableList()
Destructor. Delete all table objects.
Definition: table.h:812
virtual cursor * createCursor() const =0
Create a cursor object to perform row-wise data access.
virtual int appendRows(const std::vector< ibis::table::row > &)=0
Add multiple rows.
virtual int addColumn(const char *cname, ibis::TYPE_T ctype, const char *cdesc=0, const char *idx=0)=0
Add a column.
virtual uint32_t nColumns() const =0
The number of columns in this table.
static void * allocateBuffer(ibis::TYPE_T, size_t)
Allocate a buffer of the specified type and size.
Definition: bord.cpp:5032

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive