8 #ifndef IBIS_SELECTCLAUSE_H
9 #define IBIS_SELECTCLAUSE_H
124 int parse(
const char *cl);
127 const char*
getString(
void)
const {
return clause_.c_str();}
129 const char*
operator*(
void)
const {
return clause_.c_str();}
132 bool empty()
const {
return atms_.empty();}
134 void printDetails(std::ostream&)
const;
135 void print(std::ostream&)
const;
136 int find(
const char*)
const;
153 const char*
termName(
unsigned i)
const {
return xnames_[i].c_str();}
155 typedef std::map<const char*, const char*, ibis::lessi>
nameMap;
164 enum AGREGADO {NIL_AGGR, AVG, CNT, MAX, MIN, SUM, DISTINCT,
165 VARPOP, VARSAMP, STDPOP, STDSAMP, MEDIAN, CONCAT};
167 uint32_t
aggSize()
const {
return atms_.size();}
179 const char*
aggName(
unsigned i)
const {
return names_[i].c_str();}
211 atms_.swap(rhs.
atms_);
212 aggr_.swap(rhs.
aggr_);
215 xtms_.swap(rhs.
xtms_);
218 clause_.swap(rhs.clause_);
223 friend class variable;
245 friend class ibis::selectParser;
268 virtual void print(std::ostream&)
const;
const ibis::math::term * aggExpr(unsigned i) const
Fetch the ith term inside the select clause.
Definition: selectClause.h:174
const StringToInt & getOrdered() const
Functions related to internal aggregation operations.
Definition: selectClause.h:192
StringToInt xalias_
Aliases.
Definition: selectClause.h:237
const ibis::math::term * termExpr(unsigned i) const
Fetch the ith term visible to the outside. No array bound checking.
Definition: selectClause.h:146
std::string termDescription(unsigned i) const
Produce a string for the jth term of the select clause.
Definition: selectClause.cpp:594
int getGroupbyKeys(std::vector< std::string > &keys) const
Gather the implicit group-by keys into a vector.
Definition: selectClause.cpp:609
void print(std::ostream &) const
Write a string version of the select clause to the specified output stream.
Definition: selectClause.cpp:697
static int verifyTerm(const ibis::math::term &, const ibis::part &, const ibis::selectClause *=0)
Verify the specified term has valid column names.
Definition: selectClause.cpp:847
std::map< const char *, const char *, ibis::lessi > nameMap
Functions related to extenally visible portion of the select clause.
Definition: selectClause.h:155
uint32_t numTerms() const
Number of terms visible to the outside.
Definition: selectClause.h:149
A class to represent the select clause.
Definition: selectClause.h:112
const char * isUnivariate() const
Is the select caluse univariate? If yes, return the pointer to the string value, otherwise return a n...
Definition: selectClause.cpp:405
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
const mathTerms & getTerms() const
Retrieve all top-level arithmetic expressions.
Definition: selectClause.h:144
std::vector< std::string > names_
Names of the variables inside the aggregation functions.
Definition: selectClause.h:231
selectClause & operator=(const selectClause &rhs)
Assignment operator.
Definition: selectClause.h:204
int parse(const char *cl)
Parse a new string.
Definition: selectClause.cpp:86
const char * aggName(unsigned i) const
Name inside the aggregation function.
Definition: selectClause.h:179
uint64_t decodeAName(const char *) const
Determine if the name refers to a term in the list of aggregation functions.
Definition: selectClause.cpp:433
StringToInt ordered_
A ordered version of names_.
Definition: selectClause.h:233
Define the query expression.
virtual void print(std::ostream &) const
Print a human readable version of the expression.
Definition: selectClause.cpp:926
mathTerms atms_
Arithmetic expressions used by aggregators.
Definition: selectClause.h:227
void fillNames()
Fill array names_ and xnames_.
Definition: selectClause.cpp:183
int verify(const ibis::part &) const
Verify the select clause is valid against the given data partition.
Definition: selectClause.cpp:800
A variable.
Definition: qExpr.h:812
std::string aggDescription(unsigned i) const
Produce a string description for the ith aggregation expression.
Definition: selectClause.h:183
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
void addTerm(ibis::math::term *, const std::string *)
Add a top-level term.
Definition: selectClause.cpp:447
int find(const char *) const
Locate the position of the string.
Definition: selectClause.cpp:628
bool isSeparable() const
Can the select clause be evaluated in separate parts? Return true if there is at least one aggregator...
Definition: selectClause.cpp:389
void swap(selectClause &rhs)
Swap the content of two select clauses.
Definition: selectClause.h:210
std::vector< AGREGADO > aggr_
Aggregators.
Definition: selectClause.h:229
std::vector< std::string > xnames_
Names of the top-level terms.
Definition: selectClause.h:239
uint32_t aggSize() const
The number of arithmetic expressions inside the select clause.
Definition: selectClause.h:167
std::vector< ibis::math::term * > mathTerms
Functions related to extenally visible portion of the select clause.
Definition: selectClause.h:142
Defines a new class with the desired lex function for C++ output of bison.
Definition: selectLexer.h:33
const char * operator*(void) const
Dereferences to the string form of the select clause.
Definition: selectClause.h:129
bool needsEval(const ibis::part &) const
Does the data partition need additional processing to process the select clause? If any of the (lower...
Definition: selectClause.cpp:378
void clear(ibis::array_t< ibis::bitvector * > &bv)
Clear an array of bit vectors.
Definition: bitvector.cpp:4662
std::map< std::string, unsigned > StringToInt
Functions related to internal aggregation operations.
Definition: selectClause.h:191
The abstract base class for arithmetic terms.
Definition: qExpr.h:728
int verifySome(const std::vector< uint32_t > &, const ibis::part &) const
Verify the selected terms.
Definition: selectClause.cpp:823
ibis::math::variable * addAgregado(ibis::selectClause::AGREGADO, ibis::math::term *)
Record an aggregation function.
Definition: selectClause.cpp:294
AGREGADO
Functions related to internal aggregation operations.
Definition: selectClause.h:164
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
mathTerms xtms_
Top-level terms. Externally visible arithmetic expressions.
Definition: selectClause.h:235
const char * getString(void) const
Return a pointer to the string form of the select clause.
Definition: selectClause.h:127
int getAliases(nameMap &) const
Map internal column names to external column names.
Definition: selectClause.cpp:272
AGREGADO getAggregator(uint32_t i) const
Return the aggregation function used for the ith term.
Definition: selectClause.h:169
ibis::selectLexer * lexer
!< String version of the select clause.
Definition: selectClause.h:243
virtual variable * dup() const
Make a duplicate copy of the term.
Definition: selectClause.h:267
bool hasAggregation(const ibis::math::term *tm) const
Does the math expression contain any aggregation operations?
Definition: selectClause.cpp:465
const char * termName(unsigned i) const
Name given to the top-level function.
Definition: selectClause.h:153
A specialization of ibis::math::variable.
Definition: selectClause.h:262
selectClause(const char *cl=0)
Parse a new string as a select clause.
Definition: selectClause.cpp:10
uint32_t numGroupbyKeys() const
Number of terms without aggregation functions.
Definition: selectClause.cpp:365
bool empty() const
Returns true if this select clause is empty.
Definition: selectClause.h:132