17 class qContinuousRange;
41 LOGICAL_UNDEFINED, LOGICAL_NOT, LOGICAL_AND, LOGICAL_OR, LOGICAL_XOR,
42 LOGICAL_MINUS, RANGE, DRANGE, STRING, ANYSTRING, KEYWORD, ALLWORDS,
43 COMPRANGE, MATHTERM, DEPRECATEDJOIN, TOPK, EXISTS, ANYANY, LIKE,
48 OP_UNDEFINED, OP_LT, OP_GT, OP_LE, OP_GE, OP_EQ
52 qExpr() : type(LOGICAL_UNDEFINED), left(0), right(0) {}
55 explicit qExpr(
TYPE op) : type(op), left(0), right(0) {}
68 left(qe.left ? qe.left->dup() : 0),
69 right(qe.right ? qe.right->dup() : 0) {}
113 return 1 + (left != 0 ? left->nItems() : 0) +
114 (right != 0 ? right->nItems() : 0);}
117 virtual void print(std::ostream&)
const;
119 virtual void printFull(std::ostream& out)
const;
123 virtual double operator()(
const qExpr* ex)
const = 0;
144 {
return (type==RANGE || type==STRING || type==COMPRANGE ||
145 type==DRANGE || type==ANYSTRING || type==ANYANY ||
146 type==INTHOD || type==UINTHOD || type==EXISTS ||
147 type==KEYWORD || type==ALLWORDS || type==LIKE ||
148 type==LOGICAL_UNDEFINED || type==TOPK || type==ANYANY ||
149 (type==LOGICAL_NOT && left && left->directEval()));}
155 if (right)
return left->isSimple() && right->isSimple();
156 else return left->isSimple();
159 return right->isSimple();
170 virtual void getTableNames(std::set<std::string>& plist)
const;
185 std::set<std::string> tnames;
187 typedef std::vector<TTN> termTableList;
210 virtual const char*
colName()
const = 0;
213 virtual bool inRange(
double val)
const = 0;
222 virtual bool empty()
const = 0;
223 virtual void getTableNames(std::set<std::string>& plist)
const;
257 left_op(OP_UNDEFINED), right_op(OP_UNDEFINED) {};
260 COMPARE rop,
const char* rstr);
264 lower(DBL_MAX), upper(val), left_op(OP_UNDEFINED), right_op(op) {};
268 lower(rhs.lower), upper(rhs.upper), left_op(rhs.left_op),
269 right_op(rhs.right_op) {};
274 lower(lv), upper(rv), left_op(lop), right_op(rop) {};
278 lower(-DBL_MAX), upper(val), left_op(OP_UNDEFINED), right_op(op) {
280 if (right_op == ibis::qExpr::OP_GT) {
281 right_op = ibis::qExpr::OP_UNDEFINED;
282 left_op = ibis::qExpr::OP_LT;
286 else if (right_op == ibis::qExpr::OP_GE) {
287 right_op = ibis::qExpr::OP_UNDEFINED;
288 left_op = ibis::qExpr::OP_LE;
297 virtual const char *
colName()
const {
return name;}
298 COMPARE leftOperator()
const {
return left_op;}
299 COMPARE rightOperator()
const {
return right_op;}
306 COMPARE& leftOperator() {
return left_op;}
307 COMPARE& rightOperator() {
return right_op;}
310 void foldBoundaries();
312 void foldUnsignedBoundaries();
316 virtual bool inRange(
double val)
const;
318 virtual bool empty()
const;
320 virtual void print(std::ostream&)
const;
321 virtual void printFull(std::ostream& out)
const;
323 bool overlap(
double,
double)
const;
329 COMPARE left_op, right_op;
342 qDiscreteRange(
const char *col,
const std::vector<uint32_t>& val);
349 :
qRange(DRANGE), name(dr.name), values(dr.values) {}
353 virtual const char*
colName()
const {
return name.c_str();}
361 virtual bool inRange(
double val)
const;
363 virtual bool empty()
const {
return values.empty();}
365 return (values.empty() ? DBL_MAX : values.front());}
367 return (values.empty() ? -DBL_MAX : values.back());}
368 virtual uint32_t
nItems()
const {
return values.size();}
372 bool overlap(
double,
double)
const;
374 virtual void print(std::ostream&)
const;
396 qIntHod(
const char* col, int64_t v1);
397 qIntHod(
const char* col, int64_t v1, int64_t v2);
398 qIntHod(
const char* col,
const char* nums);
399 qIntHod(
const char* col,
const std::vector<int64_t>& nums);
404 :
qRange(INTHOD), name(ih.name), values(ih.values) {};
410 const char*
colName()
const {
return name.c_str();}
416 virtual bool inRange(
double val)
const;
417 virtual bool inRange(int64_t val)
const;
420 return (values.empty() ? DBL_MAX : values.front());}
422 return (values.empty() ? -DBL_MAX : values.back());}
423 virtual bool empty()
const {
return values.empty();}
426 virtual uint32_t
nItems()
const {
return values.size();}
428 virtual void print(std::ostream&)
const;
429 virtual void printFull(std::ostream&)
const;
451 qUIntHod(
const char* col, uint64_t v1);
452 qUIntHod(
const char* col, uint64_t v1, uint64_t v2);
453 qUIntHod(
const char* col,
const char* nums);
454 qUIntHod(
const char* col,
const std::vector<uint64_t>& nums);
459 :
qRange(UINTHOD), name(ih.name), values(ih.values) {};
465 const char*
colName()
const {
return name.c_str();}
471 virtual bool inRange(
double val)
const;
472 virtual bool inRange(uint64_t val)
const;
475 return (values.empty() ? DBL_MAX : values.front());}
477 return (values.empty() ? -DBL_MAX : values.back());}
478 virtual bool empty()
const {
return values.empty();}
481 virtual uint32_t
nItems()
const {
return values.size();}
483 virtual void print(std::ostream&)
const;
484 virtual void printFull(std::ostream&)
const;
508 qString(
const char* ls,
const char* rs);
509 virtual ~
qString() {
delete [] rstr;
delete [] lstr;}
511 const char* leftString()
const {
return lstr;}
512 const char* rightString()
const {
return rstr;}
513 void swapLeftRight() {
char* tmp = lstr; lstr = rstr; rstr = tmp;}
516 virtual void print(std::ostream&)
const;
518 virtual void getTableNames(std::set<std::string>& plist)
const;
544 virtual void print(std::ostream& out)
const;
545 virtual void printFull(std::ostream& out)
const;
551 const char*
colName()
const {
return name.c_str();}
563 qAnyString(
const char *col,
const char *sval);
568 virtual void print(std::ostream& out)
const;
572 const char*
colName()
const {
return name.c_str();}
574 const std::vector<std::string>&
valueList()
const {
return values;}
577 virtual void getTableNames(std::set<std::string>& plist)
const;
581 std::vector<std::string> values;
589 qLike(
const char* ls,
const char* rs);
591 virtual ~qLike() {
delete [] rpat;
delete [] lstr;}
599 virtual void print(std::ostream&)
const;
601 virtual void getTableNames(std::set<std::string>& plist)
const;
625 qKeyword(
const char* ls,
const char* rs);
626 virtual ~
qKeyword() {
delete [] kword;
delete [] name;}
636 virtual void print(std::ostream&)
const;
638 virtual void getTableNames(std::set<std::string>& plist)
const;
663 qAllWords(
const char *,
const char *,
const char *);
668 virtual void print(std::ostream& out)
const;
672 const char*
colName()
const {
return name.c_str();}
674 const std::vector<std::string>&
valueList()
const {
return values;}
675 virtual void getTableNames(std::set<std::string>& plist)
const;
680 std::vector<std::string> values;
687 enum TERM_TYPE {UNDEF_TERM, VARIABLE, NUMBER, STRING, OPERATOR,
688 STDFUNCTION1, STDFUNCTION2,
689 CUSTOMFUNCTION1, CUSTOMFUNCTION2,
690 STRINGFUNCTION1, STRINGFUNCTION2};
693 enum OPERADOR {UNKNOWN=0, BITOR, BITAND, PLUS, MINUS, MULTIPLY,
694 DIVIDE, REMAINDER, NEGATE, POWER};
696 enum STDFUN1 {ACOS=0, ASIN, ATAN, CEIL, COS, COSH, EXP, FABS, FLOOR,
697 FREXP, LOG10, LOG, MODF, ROUND, SIN, SINH, SQRT, TAN,
698 TANH, TRUNC, IS_ZERO, IS_NONZERO};
700 enum STDFUN2 {ATAN2=0, FMOD, LDEXP, ROUND2, POW, IS_EQL, IS_GTE,
735 virtual double eval()
const = 0;
743 virtual void print(std::ostream& out)
const = 0;
753 term(
const term &rhs) :
qExpr(rhs) {}
770 uint32_t size()
const {
return varmap.size();}
771 const char* name(uint32_t i)
const {
return namelist[i];}
772 const double& value(uint32_t i)
const {
return varvalues[i];}
773 double& value(uint32_t i) {
return varvalues[i];}
784 typedef std::map< const char*, uint32_t, ibis::lessi > termMap;
788 friend class variable;
789 double getValue(uint32_t i)
const {
return varvalues[i];}
792 termMap::const_iterator it =
varmap.find(nm);
794 uint32_t i = (*it).second;
821 myBar(v.myBar), varind(v.varind) {}
822 virtual ~
variable() {
delete [] name;}
824 virtual TERM_TYPE termType()
const {
return VARIABLE;}
826 virtual double eval()
const {
return myBar->getValue(varind);}
827 virtual void getTableNames(std::set<std::string>& plist)
const;
829 virtual uint32_t
nItems()
const {
return 1U;}
830 virtual void print(std::ostream& out)
const {out << name;}
831 virtual void printFull(std::ostream& out)
const;
832 const char* variableName()
const {
return name;}
834 void recordVariable(barrel& bar)
const {
835 if (name != 0 && *name != 0 && *name !=
'*') {
836 varind = bar.recordVariable(name);
841 void addDecoration(
const char *,
const char*);
842 const char* getDecoration()
const {
return decor.c_str();}
847 mutable barrel* myBar;
848 mutable uint32_t varind;
851 variable& operator=(
const variable&);
857 number(
const char* num) : val(atof(num)) {};
858 number(
double v) : val(v) {};
861 virtual TERM_TYPE termType()
const {
return NUMBER;}
863 virtual double eval()
const {
return val;}
865 virtual uint32_t
nItems()
const {
return 1U;}
866 virtual void print(std::ostream& out)
const {out << val;}
867 virtual void printFull(std::ostream& out)
const {out << val;}
869 virtual bool isTrue()
const {
return(val != 0);}
886 virtual ~
literal() {
delete [] str;}
888 virtual TERM_TYPE termType()
const {
return ibis::math::STRING;}
890 virtual double eval()
const {
return 0.0;}
896 return(str != 0 && (*str ==
't' || *str ==
'T' ||
897 (*str ==
'1' && *str == 0)));}
899 virtual uint32_t
nItems()
const {
return 1U;}
900 virtual void print(std::ostream& out)
const {out << str;}
901 virtual void printFull(std::ostream& out)
const {out << str;}
902 operator const char* ()
const {
return str;}
907 literal(
const literal&);
908 literal& operator=(
const literal&);
917 virtual TERM_TYPE termType()
const {
return OPERATOR;}
926 virtual double eval()
const;
927 virtual void print(std::ostream& out)
const;
930 OPERADOR getOperator()
const {
return operador;}
939 std::vector<ibis::math::term*>& terms);
942 void convertConstants();
958 virtual TERM_TYPE termType()
const {
return STDFUNCTION1;}
959 virtual double eval()
const;
960 virtual void print(std::ostream& out)
const;
981 virtual TERM_TYPE termType()
const {
return STDFUNCTION2;}
982 virtual double eval()
const;
983 virtual void print(std::ostream& out)
const;
1001 virtual double eval(
double)
const =0;
1003 virtual void printName(std::ostream&)
const =0;
1018 virtual std::string
eval(
double)
const =0;
1020 virtual void printName(std::ostream&)
const =0;
1032 : fun_(rhs.fun_->
dup()) {
1044 virtual TERM_TYPE termType()
const {
return CUSTOMFUNCTION1;}
1045 virtual double eval()
const;
1046 virtual void print(std::ostream& out)
const;
1067 : fmt_(f), tzname_(z!=0?z:
"") {}
1069 : fmt_(rhs.fmt_), tzname_(rhs.tzname_) {}
1075 virtual double eval(
double)
const;
1076 virtual void printName(std::ostream&)
const;
1081 std::string tzname_;
1094 toUnixTime(
const char *z=0) : tzname_(z!=0?z:
"") {}
1101 virtual double eval(
double)
const;
1102 virtual void printName(std::ostream&)
const;
1106 std::string tzname_;
1116 : fun_(rhs.fun_->
dup()) {
1128 virtual TERM_TYPE termType()
const {
return STRINGFUNCTION1;}
1129 virtual double eval()
const {
return FASTBIT_DOUBLE_NULL;}
1130 virtual std::string sval()
const;
1131 virtual void print(std::ostream& out)
const;
1146 : fmt_(f), tzname_(z!=0?z:
"") {}
1148 : fmt_(rhs.fmt_), tzname_(rhs.tzname_) {}
1154 virtual std::string
eval(
double)
const;
1155 virtual void printName(std::ostream&)
const;
1160 std::string tzname_;
1179 op12(lop), op23(
ibis::
qExpr::OP_UNDEFINED) {;}
1186 op12(lop), op23(rop) {;}
1189 ibis::
qExpr(rhs), expr3(rhs.expr3 ? rhs.expr3->dup() : 0),
1190 op12(rhs.op12), op23(rhs.op23) {};
1208 (expr3 != 0 ? expr3->nItems() : 0);}
1210 virtual void print(std::ostream&)
const;
1212 virtual void getTableNames(std::set<std::string>& plist)
const;
1217 (expr3 != 0 ? expr3->isConstant() :
true));}
1243 :
ibis::qExpr(ibis::qExpr::DEPRECATEDJOIN), name1(n1), name2(n2),
1246 ibis::qExpr(ibis::qExpr::DEPRECATEDJOIN), name1(n1), name2(n2),
1250 virtual void print(std::ostream& out)
const;
1255 const char* getName1()
const {
return name1.c_str();}
1256 const char* getName2()
const {
return name2.c_str();}
1263 (expr != 0 ? expr->
nItems() : 0);}
1288 qAnyAny(
const char *pre,
const double dbl);
1289 qAnyAny(
const char *pre,
const char *val);
1292 const char* getPrefix()
const {
return prefix.c_str();}
1299 virtual void print(std::ostream& out)
const;
1301 virtual void getTableNames(std::set<std::string>& plist)
const;
1308 inline void ibis::qContinuousRange::foldBoundaries() {
1310 case ibis::qExpr::OP_LT:
1311 lower = floor(lower);
1313 case ibis::qExpr::OP_LE:
1314 lower = ceil(lower);
1316 case ibis::qExpr::OP_GT:
1317 lower = ceil(lower);
1319 case ibis::qExpr::OP_GE:
1320 lower = floor(lower);
1322 case ibis::qExpr::OP_EQ:
1323 if (lower != floor(lower))
1324 left_op = ibis::qExpr::OP_UNDEFINED;
1330 case ibis::qExpr::OP_LT:
1331 upper = ceil(upper);
1333 case ibis::qExpr::OP_LE:
1334 upper = floor(upper);
1336 case ibis::qExpr::OP_GT:
1337 upper = floor(upper);
1339 case ibis::qExpr::OP_GE:
1340 upper = ceil(upper);
1342 case ibis::qExpr::OP_EQ:
1343 if (upper != floor(upper))
1344 right_op = ibis::qExpr::OP_UNDEFINED;
1351 inline void ibis::qContinuousRange::foldUnsignedBoundaries() {
1353 case ibis::qExpr::OP_LT:
1355 lower = floor(lower);
1358 left_op = ibis::qExpr::OP_LE;
1362 case ibis::qExpr::OP_LE:
1364 lower = ceil(lower);
1368 case ibis::qExpr::OP_GT:
1369 lower = ceil(lower);
1371 case ibis::qExpr::OP_GE:
1372 lower = floor(lower);
1374 case ibis::qExpr::OP_EQ:
1375 if (lower != floor(lower) || lower < 0.0)
1376 left_op = ibis::qExpr::OP_UNDEFINED;
1382 case ibis::qExpr::OP_LT:
1383 upper = ceil(upper);
1385 case ibis::qExpr::OP_LE:
1386 upper = floor(upper);
1388 case ibis::qExpr::OP_GT:
1390 upper = floor(upper);
1393 right_op = ibis::qExpr::OP_GE;
1397 case ibis::qExpr::OP_GE:
1399 upper = ceil(upper);
1403 case ibis::qExpr::OP_EQ:
1404 if (upper != floor(upper) || upper < 0.0)
1405 right_op = ibis::qExpr::OP_UNDEFINED;
1417 int cmp = strcmp(colName(), y.
colName());
1422 else if (left_op < y.left_op)
1424 else if (left_op > y.left_op)
1426 else if (right_op < y.right_op)
1428 else if (right_op > y.right_op)
1430 else if (lower < y.lower)
1432 else if (lower > y.lower)
1434 else if (upper < y.upper)
1442 if (expr3 == 0 && getLeft() != 0)
1444 termType()==ibis::math::VARIABLE &&
1446 termType()==ibis::math::NUMBER) ||
1447 (static_cast<const ibis::math::term*>(getLeft())->
1448 termType()==ibis::math::NUMBER &&
1450 termType()==ibis::math::VARIABLE));
1451 else if (expr3 != 0 && expr3->termType()==ibis::math::NUMBER)
1452 res = (getLeft() == 0 &&
1454 == ibis::math::VARIABLE) ||
1455 (static_cast<const ibis::math::term*>(getLeft())->
1456 termType()==ibis::math::NUMBER &&
1458 termType()==ibis::math::VARIABLE);
1463 return (expr3 == 0 && op12==OP_EQ && getLeft() != 0 && getRight() != 0 &&
1464 (static_cast<const ibis::math::term*>(getLeft())->termType()
1465 ==ibis::math::VARIABLE ||
1466 static_cast<const ibis::math::term*>(getLeft())->termType()
1467 ==ibis::math::STRING) &&
1468 (static_cast<const ibis::math::term*>(getRight())->termType()
1469 ==ibis::math::VARIABLE ||
1470 static_cast<const ibis::math::term*>(getRight())->termType()
1471 ==ibis::math::STRING));
1477 if (getRight() == 0)
return false;
1481 if (op12 == OP_UNDEFINED && op23 == OP_UNDEFINED)
1482 return (tm2 != 0.0);
1485 if (getLeft() != 0 && op12 != OP_UNDEFINED) {
1489 case OP_LT: res = (tm1 < tm2);
break;
1490 case OP_LE: res = (tm1 <= tm2);
break;
1491 case OP_GT: res = (tm1 > tm2);
break;
1492 case OP_GE: res = (tm1 >= tm2);
break;
1493 case OP_EQ: res = (tm1 == tm2);
break;
1497 if (expr3 != 0 && op23 != OP_UNDEFINED && res ==
true) {
1498 const double tm3 = expr3->
eval();
1500 case OP_LT: res = (tm2 < tm3);
break;
1501 case OP_LE: res = (tm2 <= tm3);
break;
1502 case OP_GT: res = (tm2 > tm3);
break;
1503 case OP_GE: res = (tm2 >= tm3);
break;
1504 case OP_EQ: res = (tm2 == tm3);
break;
1516 if (values.empty())
return false;
1517 if (val < values[0] || val > values.back())
return false;
1519 uint32_t i = 0, j = values.size();
1523 for (i = 0; i < j; ++ i)
1524 if (values[i] == val)
return true;
1528 uint32_t m = (i + j) / 2;
1530 if (values[m] == val)
return true;
1531 if (values[m] < val)
1537 return (values[m] == val);
1546 if (values.empty())
return false;
1547 if (val < values[0] || val > values.back())
return false;
1549 uint32_t i = 0, j = values.size();
1553 for (i = 0; i < j; ++ i)
1554 if (values[i] == val)
return true;
1558 uint32_t m = (i + j) / 2;
1560 if (values[m] == val)
return true;
1561 if (values[m] < val)
1567 return (values[m] == val);
1576 if (values.empty())
return false;
1577 if (val < values[0] || val > values.back())
return false;
1579 uint32_t i = 0, j = values.size();
1583 for (i = 0; i < j; ++ i)
1584 if (values[i] == val)
return true;
1588 uint32_t m = (i + j) / 2;
1590 if (values[m] == val)
return true;
1591 if (values[m] < val)
1597 return (values[m] == val);
1606 if (values.empty())
return false;
1607 if (val < values[0] || val > values.back())
return false;
1609 uint32_t i = 0, j = values.size();
1613 for (i = 0; i < j; ++ i)
1614 if (values[i] == val)
return true;
1618 uint32_t m = (i + j) / 2;
1620 if (values[m] == val)
return true;
1621 if (values[m] < val)
1627 return (values[m] == val);
1636 if (values.empty())
return false;
1637 if (val < values[0] || val > values.back())
return false;
1639 uint32_t i = 0, j = values.size();
1643 for (i = 0; i < j; ++ i)
1644 if (values[i] == val)
return true;
1648 uint32_t m = (i + j) / 2;
1650 if (values[m] == val)
return true;
1651 if (values[m] < val)
1657 return (values[m] == val);
1662 inline ostream& operator<<(ostream&,
const ibis::qExpr&);
1669 inline std::ostream& std::operator<<(std::ostream& out,
const ibis::qExpr& pn) {
1670 if (ibis::gVerbose > 5)
1678 inline std::ostream& std::operator<<(std::ostream& out,
1682 case ibis::qExpr::OP_UNDEFINED:
1684 case ibis::qExpr::OP_LT:
1686 case ibis::qExpr::OP_LE:
1688 case ibis::qExpr::OP_GT:
1690 case ibis::qExpr::OP_GE:
1692 case ibis::qExpr::OP_EQ:
1697 #endif // IBIS_EXPR_H
virtual sfunc1 * dup() const =0
Duplicate thyself. Should follow deep-copy semantics.
virtual void printName(std::ostream &) const
Print the name of this function.
Definition: qExpr.cpp:4122
The class qKeyword encapsulates a search for a single keyword in a text field.
Definition: qExpr.h:621
virtual double rightBound() const =0
The upper bound of the range.
const ibis::array_t< uint64_t > & getValues() const
Reference to the values.
Definition: qExpr.h:467
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:569
virtual term * reduce()
Shorten the expression by evaluating the constants.
Definition: qExpr.cpp:2224
A class to represent simple range conditions.
Definition: qExpr.h:207
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:1132
virtual double eval() const
Evaluate the term.
Definition: qExpr.h:826
void recordVariable(const qExpr *const t)
Record the variable names appear in the query expression.
Definition: qExpr.cpp:1978
virtual void printName(std::ostream &) const =0
Print the name of this function.
virtual double eval() const
Evaluate the term.
Definition: qExpr.cpp:4080
void swap(qExpr &rhs)
Swap the content. No exception expected.
Definition: qExpr.h:98
qExpr *& getLeft()
Return a pointer to the left child.
Definition: qExpr.h:84
TYPE getType() const
Return the node type.
Definition: qExpr.h:91
virtual term * reduce()
Shorten the expression by evaluating the constants.
Definition: qExpr.h:749
A user specifies this type of query expression with the following syntax,.
Definition: qExpr.h:1285
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.h:900
void setLeft(qExpr *expr)
Change the left child.
Definition: qExpr.h:77
This data structure holds a single name.
Definition: qExpr.h:536
virtual double eval() const
Evaluate the term.
Definition: qExpr.h:863
char * strnewdup(const char *s)
Duplicate string content with C++ default new operator.
Definition: util.cpp:1420
virtual bool isConstant() const
Is this expression a constant? A constant remains the same not matter which row it is applied to...
Definition: qExpr.h:1214
virtual void printName(std::ostream &) const
Print the name of this function.
Definition: qExpr.cpp:4194
virtual double eval() const
Evaluate one-argument standard functions from math.h.
Definition: qExpr.cpp:2353
A string literal.
Definition: qExpr.h:883
static void splitColumnName(const char *, std::string &, std::string &)
Split the incoming name into data partition name and column name.
Definition: qExpr.cpp:1392
STDFUN2
Standard 2-argument functions.
Definition: qExpr.h:700
virtual qContinuousRange * dup() const
Duplicate *this.
Definition: qExpr.h:315
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:745
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:928
A barrel to hold a list of variables.
Definition: qExpr.h:760
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:112
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.cpp:4208
virtual void print(std::ostream &) const
Print the query expression.
Definition: qExpr.cpp:2934
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:637
virtual ~compRange()
Destructor.
Definition: qExpr.h:1192
virtual double leftBound() const
The lower bound of the range.
Definition: qExpr.h:474
Simple range condition.
Definition: qExpr.h:252
compRange(ibis::math::term *me1, ibis::qExpr::COMPARE lop, ibis::math::term *me2, ibis::qExpr::COMPARE rop, ibis::math::term *me3)
Constructor with three arithmetic expressions.
Definition: qExpr.h:1182
virtual qKeyword * dup() const
!< Reorder the expressions tree.
Definition: qExpr.h:635
virtual fromUnixTime * dup() const
Duplicate thyself. Should follow deep-copy semantics.
Definition: qExpr.h:1071
virtual qDiscreteRange * dup() const
Duplicate thy self.
Definition: qExpr.h:360
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.h:830
The class qAllWords encapsulates a search for many keywords.
Definition: qExpr.h:659
ibis::array_t< uint64_t > & getValues()
Reference to the values.
Definition: qExpr.h:469
virtual bediener * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:918
const char * operator_name[]
String form of the operators.
Definition: qExpr.cpp:24
The top level query expression object.
Definition: qExpr.h:36
virtual deprecatedJoin * dup() const
!< Reorder the expressions tree.
Definition: qExpr.h:1252
virtual void printDecoration(std::ostream &) const
Print the decoration on this function.
Definition: qExpr.cpp:4204
virtual bool isConstant() const
Is this expression a constant? A constant remains the same not matter which row it is applied to...
Definition: qExpr.h:868
const std::vector< std::string > & valueList() const
Return the string values in the parentheses as a vector.
Definition: qExpr.h:674
Functor to convert ISO 8601 style date time value to a unix time stamp.
Definition: qExpr.h:1091
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:375
void setRight(qExpr *expr)
Change the right child.
Definition: qExpr.h:81
virtual ~barrel()
Destructor. Member variables clean themselves.
Definition: qExpr.h:767
virtual double eval(double) const =0
Evaluate the function on the given argument.
std::vector< const char * > namelist
List of variable names.
Definition: qExpr.h:808
An operator. Bediener is German for operator.
Definition: qExpr.h:912
virtual number * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:862
A functor to be used by the function reorder.
Definition: qExpr.h:122
This query expression has similar meaning as ibis::qDiscreteRange, however, it stores the values as s...
Definition: qExpr.h:392
The column contains one of the values in a list.
Definition: qExpr.h:560
virtual bool isSimple() const
Is the expression simple? A simple expression contains only range conditions connected with logical o...
Definition: qExpr.h:153
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.cpp:2920
static std::string extractTableName(const char *)
Extract the data partition name from the column name cn.
Definition: qExpr.cpp:1375
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.cpp:945
bool equivalent(const barrel &rhs) const
Is the given barrel of variables equivalent to this one?
Definition: qExpr.cpp:2066
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.cpp:4055
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.cpp:2926
virtual double eval() const
Evaluate the 2-argument standard functions.
Definition: qExpr.cpp:2489
virtual double eval() const =0
Evaluate the term.
const char * stdfun1_name[]
String form of the one-argument standard functions.
Definition: qExpr.cpp:27
virtual bool isSimple() const
Is the expression simple? A simple expression contains only range conditions connected with logical o...
Definition: qExpr.h:546
virtual double leftBound() const
The lower bound of the range.
Definition: qExpr.h:419
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:1047
double getValue(const char *nm) const
Return the value of the named variable.
Definition: qExpr.h:791
TYPE type
The type of node.
Definition: qExpr.h:193
virtual func1 * dup() const =0
Duplicate thyself. Should follow deep-copy semantics.
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:1206
ibis::array_t< int64_t > & getValues()
Reference to the values.
Definition: qExpr.h:414
const char * keyword() const
Return the keyword looking for.
Definition: qExpr.h:633
qIntHod(const qIntHod &ih)
Copy constructor.
Definition: qExpr.h:403
std::vector< double > varvalues
Cast values to double.
Definition: qExpr.h:806
virtual double rightBound() const
The upper bound of the range.
Definition: qExpr.h:301
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:829
bool isSimpleRange() const
Is this a simple range expression that can be stored as ibis::qRange?
Definition: qExpr.h:1440
virtual const char * colName() const
Name of the column.
Definition: qExpr.h:353
qExpr *& getRight()
Return a pointer to the right child.
Definition: qExpr.h:88
void getConjunctiveTerms(termTableList &) const
Extract the top-level conjunctive terms.
Definition: qExpr.cpp:1354
barrel(const term *const t)
Constructor.
Definition: qExpr.h:765
qContinuousRange(double lv, COMPARE lop, const char *prop, COMPARE rop, double rv)
Construct a range expression from double-precision boundaries.
Definition: qExpr.h:271
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.cpp:2530
virtual variable * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:825
virtual void getTableNames(std::set< std::string > &plist) const
Identify the data partitions involved in the query expression.
Definition: qExpr.cpp:1412
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.cpp:1911
const ibis::array_t< double > & getValues() const
Reference to the values.
Definition: qExpr.h:355
TYPE
Definition of node types.
Definition: qExpr.h:40
const char * colName() const
Name of the column involved.
Definition: qExpr.h:465
virtual bool empty() const =0
Is the current range empty?
virtual double leftBound() const
The lower bound of the range.
Definition: qExpr.h:300
static compRange * makeConstantTrue()
Create a constant expression that always evaluates to true.
Definition: qExpr.cpp:3257
The class qString encapsulates information for comparing string values.
Definition: qExpr.h:504
qExpr(const qExpr &qe)
Copy Constructor. Deep copy.
Definition: qExpr.h:67
qExpr & operator=(const qExpr &rhs)
Assignment operator.
Definition: qExpr.h:105
virtual term * dup() const =0
Make a duplicate copy of the term.
int separateSimple(ibis::qExpr *&simple, ibis::qExpr *&tail) const
Separate an expression tree into two connected with an AND operator.
Definition: qExpr.cpp:1195
const qExpr * getRight() const
Return a const pointer to the right child.
Definition: qExpr.h:95
One-argument standard functions.
Definition: qExpr.h:947
const std::vector< std::string > & valueList() const
Return the string values in the parentheses as a vector.
Definition: qExpr.h:574
qContinuousRange()
Construct an empty range expression.
Definition: qExpr.h:255
virtual bool inRange(double val) const
Is the argument val one of the values stored ? Return true or false.
Definition: qExpr.h:1575
TERM_TYPE
Types of terms allowed in the mathematical expressions.
Definition: qExpr.h:687
Pure virtual base function for 1-argument functions.
Definition: qExpr.h:1012
virtual void printDecoration(std::ostream &) const =0
Print the decoration on this function.
const char * colName() const
Return the column name.
Definition: qExpr.h:630
virtual void print(std::ostream &out) const
Print a human readable version of the expression.
Definition: qExpr.h:866
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:481
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:1251
double reorder(const weight &)
After reordering, the lightest weight is one the left side of a group of commutable operators...
Definition: qExpr.cpp:1022
qContinuousRange(const qContinuousRange &rhs)
Copy constructor.
Definition: qExpr.h:266
termMap varmap
Associate a variable name with a position in varvalues and namelist.
Definition: qExpr.h:804
virtual const char * colName() const =0
Returns the name of the attribute involved.
virtual ~qIntHod()
Destructor.
Definition: qExpr.h:407
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:1300
virtual stdFunction1 * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:953
virtual void printName(std::ostream &) const =0
Print the name of this function.
const ibis::array_t< int64_t > & getValues() const
Reference to the values.
Definition: qExpr.h:412
virtual double eval() const
Evaluate the term.
Definition: qExpr.h:890
virtual term * reduce()
Shorten the expression by evaluating the constants.
Definition: qExpr.cpp:2549
virtual qExpr * dup() const
Duplicate this.
Definition: qExpr.h:1297
compRange()
Default constructor.
Definition: qExpr.h:1171
ibis::qExpr * convert() const
Convert to a sequence of qContinuousRange.
Definition: qExpr.cpp:3450
virtual stringFunction1 * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:1125
virtual term * reduce()
Shorten the expression by evaluating the constants.
Definition: qExpr.h:1048
qIntHod()
Default constructor.
Definition: qExpr.h:395
A data structure including a query expression and the list of table names mentioned in the expression...
Definition: qExpr.h:183
virtual qExpr * dup() const
!< Reorder the expressions tree.
Definition: qExpr.h:128
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:867
Functor for converting a unix time stamp into date-time format throught strftime. ...
Definition: qExpr.h:1063
virtual bool isSimple() const
Is the expression simple? A simple expression contains only range conditions connected with logical o...
Definition: qExpr.h:1218
virtual void printDecoration(std::ostream &) const =0
Print the decoration on this function.
virtual bool empty() const
Is the current range empty?
Definition: qExpr.h:363
virtual bool empty() const
Is the current range empty?
Definition: qExpr.h:423
virtual qUIntHod * dup() const
Duplicate thy self.
Definition: qExpr.h:480
virtual double eval(double) const
Evaluate the function on the given argument.
Definition: qExpr.cpp:4136
virtual bool isTrue() const
Should the value be treated as true? This implementation captures the normal case, where an arithmetic expression is treated as 'true' if it is not zero.
Definition: qExpr.h:739
static compRange * makeConstantFalse()
Create a constant expression that always evaluates to false.
Definition: qExpr.cpp:3264
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:1261
virtual term * reduce()
Shorten the expression by evaluating the constants.
Definition: qExpr.h:1133
COMPARE
Comparison operator supported in RANGE.
Definition: qExpr.h:47
const char * pattern() const
The string form of the pattern.
Definition: qExpr.h:596
bool inRange() const
Evaluate the logical expression.
Definition: qExpr.h:1476
A variable.
Definition: qExpr.h:812
virtual double eval() const
Evaluate the term.
Definition: qExpr.h:1129
virtual qExists * dup() const
Duplicate the object.
Definition: qExpr.h:543
Defines minor utility functions and common classes used by FastBit.
qContinuousRange(const char *prop, COMPARE op, double val)
Construct a one-side range expression.
Definition: qExpr.h:276
This query expression has similar meaning as ibis::qDiscreteRange, however, it stores the values as u...
Definition: qExpr.h:447
const char * colName() const
Return the column name.
Definition: qExpr.h:551
bool isTerminal() const
Is this expression a terminal node of an expression tree?
Definition: qExpr.h:141
virtual bool empty() const
Is the current range empty?
Definition: qExpr.h:478
virtual double eval(double) const
Evaluate the function on the given argument.
Definition: qExpr.cpp:4089
Pure virtual base function for 1-argument functions.
Definition: qExpr.h:995
bool preserveInputExpressions
Whether to keep arithmetic expression as user inputed them.
Definition: qExpr.cpp:35
One-argument string functions.
Definition: qExpr.h:1110
Two-argument standard functions.
Definition: qExpr.h:969
compRange(const compRange &rhs)
Copy constructor. Deep copy – actually copy the math expressions.
Definition: qExpr.h:1188
virtual void getTableNames(std::set< std::string > &plist) const
Identify the data partitions involved in the query expression.
Definition: qExpr.cpp:3270
virtual qIntHod * dup() const
Duplicate thy self.
Definition: qExpr.h:425
virtual const char * colName() const
Returns the name of the attribute involved.
Definition: qExpr.h:297
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:901
A number.
Definition: qExpr.h:855
virtual void printDecoration(std::ostream &) const
Print the decoration on this function.
Definition: qExpr.cpp:4132
const char * colName() const
Name of the column to be searched.
Definition: qExpr.h:594
STDFUN1
Standard 1-argument functions.
Definition: qExpr.h:696
bool maybeStringCompare() const
Is the expression possibly a simple string comparison?
Definition: qExpr.h:1462
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:899
qDiscreteRange()
Construct an empty dicrete range expression.
Definition: qExpr.h:340
void extractDeprecatedJoins(std::vector< const deprecatedJoin * > &) const
Extract conjunctive terms of the deprecated joins.
Definition: qExpr.cpp:1421
void negate()
To negate the value.
Definition: qExpr.h:872
const char * colName() const
Return the column name, the left hand side of the IN operator.
Definition: qExpr.h:672
void invert()
To invert the value.
Definition: qExpr.h:874
virtual bool inRange(double val) const =0
Given a value, determine whether it is in the range defined.
virtual bool isConstant() const
Is this expression a constant? A constant remains the same not matter which row it is applied to...
Definition: qExpr.h:139
The abstract base class for arithmetic terms.
Definition: qExpr.h:728
virtual customFunction1 * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:1041
virtual qAnyString * dup() const
Duplicate the object. Using the compiler generated copy constructor.
Definition: qExpr.h:567
virtual stdFunction2 * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:975
void adjust()
Adjust the tree to favor the sequential evaluation order.
Definition: qExpr.cpp:992
One-argument custom functions.
Definition: qExpr.h:1026
virtual qLike * dup() const
!< Reorder the expressions tree.
Definition: qExpr.h:598
virtual void restrictRange(double left, double right)=0
Reduce the range to be no more than [left, right].
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:368
const qExpr * getLeft() const
Return a const pointer to the left child.
Definition: qExpr.h:93
virtual double eval() const
Evaluate an operator.
Definition: qExpr.cpp:2081
virtual ~qUIntHod()
Destructor.
Definition: qExpr.h:462
qUIntHod()
Default constructor.
Definition: qExpr.h:450
qExpr()
Default constructor. It generates a node of undefined type.
Definition: qExpr.h:52
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:961
virtual double leftBound() const
The lower bound of the range.
Definition: qExpr.h:364
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:669
virtual void print(std::ostream &) const
Print out the node in the string form.
Definition: qExpr.cpp:910
virtual double rightBound() const
The upper bound of the range.
Definition: qExpr.h:476
virtual void print(std::ostream &out) const
Print out the node in the string form.
Definition: qExpr.cpp:3911
qExpr(TYPE op)
Construct a node of specified type. Not for implicit type conversion.
Definition: qExpr.h:55
bool directEval() const
Can the expression be directly evaluated?
Definition: qExpr.h:143
qContinuousRange(const char *col, COMPARE op, uint32_t val)
Construct a range expression with an integer boundary.
Definition: qExpr.h:262
virtual std::string eval(double) const =0
Evaluate the function on the given argument.
ibis::array_t< double > & getValues()
Reference to the values.
Definition: qExpr.h:357
virtual qExpr * dup() const
Duplicate this object. Return a pointer to the new copy.
Definition: qExpr.h:1202
qLike()
Default constructor.
Definition: qExpr.h:588
virtual void print(std::ostream &out) const
Print out the node in the string form.
Definition: qExpr.cpp:3865
const char * colName() const
Return the column name, the left hand side of the IN operator.
Definition: qExpr.h:572
const char * colName() const
Name of the column involved.
Definition: qExpr.h:410
virtual ~qExpr()
Destructor.
Definition: qExpr.h:72
static void simplify(ibis::qExpr *&)
Attempt to simplify the query expressions.
Definition: qExpr.cpp:51
qDiscreteRange(const qDiscreteRange &dr)
Copy constructor.
Definition: qExpr.h:348
virtual qString * dup() const
!< Reorder the expressions tree.
Definition: qExpr.h:515
virtual bool isConstant() const
Is this expression a constant? A constant remains the same not matter which row it is applied to...
Definition: qExpr.h:891
compRange(ibis::math::term *me1, COMPARE lop, ibis::math::term *me2)
Constructor with two arithmetic expressions.
Definition: qExpr.h:1176
qUIntHod(const qUIntHod &ih)
Copy constructor.
Definition: qExpr.h:458
A discrete range expression.
Definition: qExpr.h:337
virtual term * reduce()
Shorten the expression by evaluating the constants.
Definition: qExpr.cpp:2415
virtual void printFull(std::ostream &out) const
Same as print.
Definition: qExpr.h:984
virtual toUnixTime * dup() const
Duplicate thyself. Should follow deep-copy semantics.
Definition: qExpr.h:1097
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:426
qExpr(TYPE op, qExpr *qe1, qExpr *qe2)
Construct a full specified node.
Definition: qExpr.h:65
qExpr * left
The left child.
Definition: qExpr.h:195
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:517
virtual uint32_t nItems() const
Count the number of items in the query expression.
Definition: qExpr.h:865
virtual bool inRange(double val) const
Is the argument val one of the values stored ? Return true or false.
Definition: qExpr.h:1515
virtual double rightBound() const
The upper bound of the range.
Definition: qExpr.h:421
qExpr * right
The right child.
Definition: qExpr.h:197
virtual void getTableNames(std::set< std::string > &plist) const
Identify the data partitions involved in the query expression.
Definition: qExpr.cpp:1951
virtual ~qLike()
Destructor.
Definition: qExpr.h:591
OPERADOR
All supported arithmetic operators.
Definition: qExpr.h:693
virtual void getTableNames(std::set< std::string > &plist) const
Identify the data partitions involved in the query expression.
Definition: qExpr.cpp:3926
ibis::qExpr * convert() const
Convert into a sequence of qString objects.
Definition: qExpr.cpp:3842
Representing the operator 'LIKE'.
Definition: qExpr.h:585
const char * stdfun2_name[]
String form of the two-argument standard functions.
Definition: qExpr.cpp:32
virtual double rightBound() const
The upper bound of the range.
Definition: qExpr.h:366
virtual bool inRange(double val) const
Is the argument val one of the values stored ? Return true or false.
Definition: qExpr.h:1545
virtual double leftBound() const =0
The lower bound of the range.
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:600
bool operator<(const qContinuousRange &y) const
An operator for comparing two query expressions.
Definition: qExpr.h:1416
virtual literal * dup() const
Make a duplicate copy of the term.
Definition: qExpr.h:889
virtual qAllWords * dup() const
Duplicate the object. Using the compiler generated copy constructor.
Definition: qExpr.h:667
barrel()
Constructor.
Definition: qExpr.h:763
The class compRange stores computed ranges.
Definition: qExpr.h:1167
virtual bool isTrue() const
Should the value be treated as true? This implementation captures the normal case, where an arithmetic expression is treated as 'true' if it is not zero.
Definition: qExpr.h:869
A join is defined by two names and a numerical expression.
Definition: qExpr.h:1240
qRange * findRange(const char *vname)
Find the first range condition involving the named variable.
Definition: qExpr.cpp:1327
virtual void printFull(std::ostream &out) const
Print out the full expression.
Definition: qExpr.h:1211
virtual void print(std::ostream &out) const =0
Print a human readable version of the expression.
virtual bool isTrue() const
Should the string literal be interpreted as true? A string literal is interpretted as true if it star...
Definition: qExpr.h:895