61 FASTBIT_CXX_DLLSPEC
extern const char**
TYPESTRING;
103 virtual const char*
name()
const {
return name_.c_str();}
107 virtual uint64_t
nRows()
const =0;
109 virtual uint32_t
nColumns()
const =0;
115 typedef std::vector<const char*> stringVector;
123 typedef std::map<const char*, ibis::TYPE_T, ibis::lessi>
namesTypes;
125 virtual stringArray columnNames()
const =0;
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;
151 virtual void estimate(
const char* cond,
152 uint64_t& nmin, uint64_t& nmax)
const =0;
156 uint64_t& nmin, uint64_t& nmax)
const =0;
159 virtual table*
select(
const char* sel,
const char* cond)
const =0;
165 static table*
select(
const ibis::constPartList& parts,
166 const char* sel,
const char* cond);
168 static table*
select(
const ibis::constPartList& parts,
171 static int64_t
computeHits(
const ibis::constPartList& parts,
174 static int64_t
computeHits(
const ibis::constPartList& parts,
194 virtual void orderby(
const stringArray&)=0;
195 virtual void orderby(
const stringArray&,
const std::vector<bool>&)=0;
197 virtual void orderby(
const char*);
242 virtual int buildIndex(
const char* colname,
const char* option=0) =0;
251 virtual const char*
indexSpec(
const char* colname=0)
const =0;
254 virtual void indexSpec(
const char* opt,
const char* colname=0) =0;
292 uint64_t begin=0, uint64_t end=0)
const =0;
295 uint64_t begin=0, uint64_t end=0)
const =0;
298 uint64_t begin=0, uint64_t end=0)
const =0;
301 uint64_t begin=0, uint64_t end=0)
const =0;
304 uint64_t begin=0, uint64_t end=0)
const =0;
307 uint64_t begin=0, uint64_t end=0)
const =0;
310 uint64_t begin=0, uint64_t end=0)
const =0;
313 uint64_t begin=0, uint64_t end=0)
const =0;
316 uint64_t begin=0, uint64_t end=0)
const =0;
319 uint64_t begin=0, uint64_t end=0)
const =0;
322 uint64_t begin=0, uint64_t end=0)
const =0;
328 uint64_t begin=0, uint64_t end=0)
const =0;
333 uint64_t begin=0, uint64_t end=0)
const =0;
340 virtual double getColumnMin(
const char* cname)
const =0;
346 virtual double getColumnMax(
const char* cname)
const =0;
364 double begin,
double end,
double stride,
365 std::vector<uint32_t>& counts)
const =0;
374 double begin1,
double end1,
double stride1,
376 double begin2,
double end2,
double stride2,
377 std::vector<uint32_t>& counts)
const =0;
386 double begin1,
double end1,
double stride1,
388 double begin2,
double end2,
double stride2,
390 double begin3,
double end3,
double stride3,
391 std::vector<uint32_t>& counts)
const =0;
396 std::vector<std::string> bytesnames;
398 std::vector<std::string> ubytesnames;
400 std::vector<std::string> shortsnames;
402 std::vector<std::string> ushortsnames;
404 std::vector<std::string> intsnames;
406 std::vector<std::string> uintsnames;
408 std::vector<std::string> longsnames;
410 std::vector<std::string> ulongsnames;
412 std::vector<std::string> floatsnames;
414 std::vector<std::string> doublesnames;
416 std::vector<std::string> catsnames;
418 std::vector<std::string> textsnames;
420 std::vector<std::string> blobsnames;
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();}
447 static void parseNames(
char* in, stringVector& out);
448 static void parseNames(
char* in, stringArray& out);
450 std::vector<bool>& direc);
462 table(
const char* na,
const char* de)
463 : name_(na?na:
""), desc_(de?de:na?na:
"") {};
494 const char* cdesc=0,
const char* idx=0) =0;
516 virtual int append(
const char* cname, uint64_t begin, uint64_t end,
562 virtual int appendRows(
const std::vector<ibis::table::row>&) =0;
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;
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;
709 virtual uint32_t
mRows()
const =0;
711 virtual uint32_t
mColumns()
const =0;
713 virtual void describe(std::ostream&)
const =0;
720 virtual table*
toTable(
const char* nm=0,
const char* de=0) =0;
753 typedef std::map< const char*, ibis::table*, ibis::lessi > tableSet;
754 typedef tableSet::const_iterator iterator;
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();}
771 tableSet::const_iterator it = tables.find(tname);
772 if (it != tables.end())
784 tableSet::iterator it = tables.find(tb->
name());
785 if (it == tables.end()) {
786 tables[tb->
name()] = tb;
791 tables[tb->
name()] = tb;
799 void remove(
const char* tname) {
800 tableSet::iterator it = tables.find(tname);
801 if (it != tables.end()) {
813 while (! tables.empty()) {
814 tableSet::iterator it = tables.begin();
838 virtual uint64_t nRows()
const =0;
839 virtual uint32_t nColumns()
const =0;
844 virtual int fetch() =0;
848 virtual int fetch(uint64_t rownum) =0;
863 virtual int dump(std::ostream& out,
const char* del=
", ")
const =0;
926 ushortsnames.clear();
938 doublesnames.clear();
950 ubytesvalues.clear();
951 shortsvalues.clear();
952 ushortsvalues.clear();
956 ulongsvalues.clear();
957 floatsvalues.clear();
958 doublesvalues.clear();
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