qExpr.h
Go to the documentation of this file.
1 // File: $Id$
2 // Author: John Wu <John.Wu at acm.org>
3 // Lawrence Berkeley National Laboratory
4 // Copyright (c) 1998-2016 the Regents of the University of California
5 //
6 // Primary contact: John Wu <John.Wu at acm.org>
7 #ifndef IBIS_EXPR_H
8 #define IBIS_EXPR_H
9 #include "util.h"
13 #include "array_t.h"
14 
15 namespace ibis { // additional names related to qExpr
16  class qRange;
17  class qContinuousRange;
18  class qDiscreteRange;
19  class qString;
20  class qAnyString;
21  class qKeyword;
22  class qAllWords;
23  class compRange;
24  class deprecatedJoin;
25  class qAnyAny;
26  class qLike;
27  class qIntHod;
28  class qUIntHod;
29  class qExists;
30 }
31 
36 class FASTBIT_CXX_DLLSPEC ibis::qExpr {
37 public:
40  enum TYPE {
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,
44  INTHOD, UINTHOD
45  };
47  enum COMPARE {
48  OP_UNDEFINED, OP_LT, OP_GT, OP_LE, OP_GE, OP_EQ
49  };
50 
52  qExpr() : type(LOGICAL_UNDEFINED), left(0), right(0) {}
53 
55  explicit qExpr(TYPE op) : type(op), left(0), right(0) {}
65  qExpr(TYPE op, qExpr* qe1, qExpr* qe2) : type(op), left(qe1), right(qe2) {}
67  qExpr(const qExpr& qe) : type(qe.type),
68  left(qe.left ? qe.left->dup() : 0),
69  right(qe.right ? qe.right->dup() : 0) {}
72  virtual ~qExpr() {delete right; delete left;}
73 
77  void setLeft(qExpr *expr) {delete left; left=expr;}
81  void setRight(qExpr *expr) {delete right; right=expr;}
84  qExpr*& getLeft() {return left;}
88  qExpr*& getRight() {return right;}
89 
91  TYPE getType() const {return type;}
93  const qExpr* getLeft() const {return left;}
95  const qExpr* getRight() const {return right;}
96 
98  void swap(qExpr& rhs) {
99  {TYPE t = type; type = rhs.type; rhs.type = t;}
100  {qExpr* p = left; left = rhs.left; rhs.left = p;}
101  {qExpr* q = right; right = rhs.right; rhs.right = q;}
102  }
103 
105  qExpr& operator=(const qExpr& rhs) {
106  qExpr tmp(rhs); // copy
107  swap(tmp);
108  return *this;
109  }
110 
112  virtual uint32_t nItems() const {
113  return 1 + (left != 0 ? left->nItems() : 0) +
114  (right != 0 ? right->nItems() : 0);}
115 
117  virtual void print(std::ostream&) const;
119  virtual void printFull(std::ostream& out) const;
120 
122  struct weight {
123  virtual double operator()(const qExpr* ex) const = 0;
124  virtual ~weight() {};
125  };
126  double reorder(const weight&);
127  virtual qExpr* dup() const {
129  qExpr* res = new qExpr(type);
130  if (left)
131  res->left = left->dup();
132  if (right)
133  res->right = right->dup();
134  return res;
135  }
136 
139  virtual bool isConstant() const {return false;}
141  bool isTerminal() const {return (left==0 && right==0);}
143  bool directEval() const
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()));}
150 
153  virtual bool isSimple() const {
154  if (left) {
155  if (right) return left->isSimple() && right->isSimple();
156  else return left->isSimple();
157  }
158  else if (right) {
159  return right->isSimple();
160  }
161  else { // the derived classes essentially overrides this case.
162  return true;
163  }
164  }
165 
167  int separateSimple(ibis::qExpr *&simple, ibis::qExpr *&tail) const;
168  void extractDeprecatedJoins(std::vector<const deprecatedJoin*>&) const;
170  virtual void getTableNames(std::set<std::string>& plist) const;
171 
173  qRange* findRange(const char* vname);
174 
176  static void simplify(ibis::qExpr*&);
177 
178  static std::string extractTableName(const char*);
179  static void splitColumnName(const char*, std::string&, std::string&);
180 
183  struct TTN {
184  const qExpr* term;
185  std::set<std::string> tnames;
186  }; // TTN
187  typedef std::vector<TTN> termTableList;
188  void getConjunctiveTerms(termTableList&) const;
189 
190 protected:
198 
200  void adjust();
201 }; // ibis::qExpr
202 
207 class FASTBIT_CXX_DLLSPEC ibis::qRange : public ibis::qExpr {
208 public:
210  virtual const char* colName() const = 0;
213  virtual bool inRange(double val) const = 0;
214 
216  virtual void restrictRange(double left, double right) = 0;
218  virtual double leftBound() const = 0;
220  virtual double rightBound() const = 0;
222  virtual bool empty() const = 0;
223  virtual void getTableNames(std::set<std::string>& plist) const;
224 
225  virtual ~qRange() {}; // nothing to do
226 
227 protected:
228  // reduce the scope of the constructor
229  qRange() : qExpr() {};
230  qRange(TYPE t) : qExpr(t) {};
231 
232 private:
233  qRange(const qRange&) {}; // no copy constructor allowed, must use dup
234  qRange& operator=(const qRange&);
235 }; // ibis::qRange
236 
252 class FASTBIT_CXX_DLLSPEC ibis::qContinuousRange : public ibis::qRange {
253 public:
256  : qRange(ibis::qExpr::RANGE), name(0), lower(0), upper(0),
257  left_op(OP_UNDEFINED), right_op(OP_UNDEFINED) {};
259  qContinuousRange(const char* lstr, COMPARE lop, const char* prop,
260  COMPARE rop, const char* rstr);
262  qContinuousRange(const char* col, COMPARE op, uint32_t val) :
263  qRange(ibis::qExpr::RANGE), name(ibis::util::strnewdup(col)),
264  lower(DBL_MAX), upper(val), left_op(OP_UNDEFINED), right_op(op) {};
267  qRange(ibis::qExpr::RANGE), name(ibis::util::strnewdup(rhs.name)),
268  lower(rhs.lower), upper(rhs.upper), left_op(rhs.left_op),
269  right_op(rhs.right_op) {};
271  qContinuousRange(double lv, COMPARE lop, const char* prop,
272  COMPARE rop, double rv)
273  : qRange(ibis::qExpr::RANGE), name(ibis::util::strnewdup(prop)),
274  lower(lv), upper(rv), left_op(lop), right_op(rop) {};
276  qContinuousRange(const char* prop, COMPARE op, double val)
277  : qRange(ibis::qExpr::RANGE), name(ibis::util::strnewdup(prop)),
278  lower(-DBL_MAX), upper(val), left_op(OP_UNDEFINED), right_op(op) {
279  // prefer to use the operator < and <= rather than > and >=
280  if (right_op == ibis::qExpr::OP_GT) {
281  right_op = ibis::qExpr::OP_UNDEFINED;
282  left_op = ibis::qExpr::OP_LT;
283  lower = upper;
284  upper = DBL_MAX;
285  }
286  else if (right_op == ibis::qExpr::OP_GE) {
287  right_op = ibis::qExpr::OP_UNDEFINED;
288  left_op = ibis::qExpr::OP_LE;
289  lower = upper;
290  upper = DBL_MAX;
291  }
292  };
293 
294  virtual ~qContinuousRange() {delete [] name;}
295 
296  // provide read access to all private variables
297  virtual const char *colName() const {return name;}
298  COMPARE leftOperator() const {return left_op;}
299  COMPARE rightOperator() const {return right_op;}
300  virtual double leftBound() const {return lower;}
301  virtual double rightBound() const {return upper;}
302  // allow one to possibly change the left and right bounds, the left and
303  // right operator
304  double& leftBound() {return lower;}
305  double& rightBound() {return upper;}
306  COMPARE& leftOperator() {return left_op;}
307  COMPARE& rightOperator() {return right_op;}
308 
309  // Fold the boundaries to integers.
310  void foldBoundaries();
311  // Fold the boundaries to unsigned integers.
312  void foldUnsignedBoundaries();
313 
315  virtual qContinuousRange* dup() const {return new qContinuousRange(*this);}
316  virtual bool inRange(double val) const;
317  virtual void restrictRange(double left, double right);
318  virtual bool empty() const;
319 
320  virtual void print(std::ostream&) const;
321  virtual void printFull(std::ostream& out) const;
322 
323  bool overlap(double, double) const;
324  inline bool operator<(const qContinuousRange& y) const;
325 
326 private:
327  char* name;
328  double lower, upper;
329  COMPARE left_op, right_op;
330 
331  qContinuousRange& operator=(const qContinuousRange&);
332  friend void ibis::qExpr::simplify(ibis::qExpr*&);
333 }; // ibis::qContinuousRange
334 
337 class FASTBIT_CXX_DLLSPEC ibis::qDiscreteRange : public ibis::qRange {
338 public:
340  qDiscreteRange() : qRange(DRANGE) {};
341  qDiscreteRange(const char *col, const char *nums);
342  qDiscreteRange(const char *col, const std::vector<uint32_t>& val);
343  qDiscreteRange(const char *col, const std::vector<double>& val);
344  qDiscreteRange(const char *col, ibis::array_t<uint32_t>& val);
345  qDiscreteRange(const char *col, ibis::array_t<double>& val);
346 
349  : qRange(DRANGE), name(dr.name), values(dr.values) {}
350  virtual ~qDiscreteRange() {}; // private variables automatically destructs
351 
353  virtual const char* colName() const {return name.c_str();}
355  const ibis::array_t<double>& getValues() const {return values;}
357  ibis::array_t<double>& getValues() {return values;}
358 
360  virtual qDiscreteRange* dup() const {return new qDiscreteRange(*this);}
361  virtual bool inRange(double val) const;
362  virtual void restrictRange(double left, double right);
363  virtual bool empty() const {return values.empty();}
364  virtual double leftBound() const {
365  return (values.empty() ? DBL_MAX : values.front());}
366  virtual double rightBound() const {
367  return (values.empty() ? -DBL_MAX : values.back());}
368  virtual uint32_t nItems() const {return values.size();}
369 
370  ibis::qExpr* convert() const;
371 
372  bool overlap(double, double) const;
373 
374  virtual void print(std::ostream&) const;
375  virtual void printFull(std::ostream& out) const {print(out);}
376 
377 private:
378  std::string name;
379  ibis::array_t<double> values;
380 
381  qDiscreteRange& operator=(const qDiscreteRange&);
382 }; // ibis::qDiscreteRange
383 
392 class FASTBIT_CXX_DLLSPEC ibis::qIntHod : public ibis::qRange {
393 public:
395  qIntHod() : qRange(INTHOD) {};
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);
400  qIntHod(const char* col, const ibis::array_t<int64_t>& nums);
401 
403  qIntHod(const qIntHod& ih)
404  : qRange(INTHOD), name(ih.name), values(ih.values) {};
405 
407  virtual ~qIntHod() {};
408 
410  const char* colName() const {return name.c_str();}
412  const ibis::array_t<int64_t>& getValues() const {return values;}
414  ibis::array_t<int64_t>& getValues() {return values;}
415 
416  virtual bool inRange(double val) const;
417  virtual bool inRange(int64_t val) const;
418  virtual void restrictRange(double, double);
419  virtual double leftBound() const {
420  return (values.empty() ? DBL_MAX : values.front());}
421  virtual double rightBound() const {
422  return (values.empty() ? -DBL_MAX : values.back());}
423  virtual bool empty() const {return values.empty();}
425  virtual qIntHod* dup() const {return new qIntHod(*this);}
426  virtual uint32_t nItems() const {return values.size();}
427 
428  virtual void print(std::ostream&) const;
429  virtual void printFull(std::ostream&) const;
430 
431 private:
433  std::string name;
436  ibis::array_t<int64_t> values;
437 }; // ibis::qIntHod
438 
447 class FASTBIT_CXX_DLLSPEC ibis::qUIntHod : public ibis::qRange {
448 public:
450  qUIntHod() : qRange(UINTHOD) {};
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);
455  qUIntHod(const char* col, const ibis::array_t<uint64_t>& nums);
456 
458  qUIntHod(const qUIntHod& ih)
459  : qRange(UINTHOD), name(ih.name), values(ih.values) {};
460 
462  virtual ~qUIntHod() {};
463 
465  const char* colName() const {return name.c_str();}
467  const ibis::array_t<uint64_t>& getValues() const {return values;}
469  ibis::array_t<uint64_t>& getValues() {return values;}
470 
471  virtual bool inRange(double val) const;
472  virtual bool inRange(uint64_t val) const;
473  virtual void restrictRange(double, double);
474  virtual double leftBound() const {
475  return (values.empty() ? DBL_MAX : values.front());}
476  virtual double rightBound() const {
477  return (values.empty() ? -DBL_MAX : values.back());}
478  virtual bool empty() const {return values.empty();}
480  virtual qUIntHod* dup() const {return new qUIntHod(*this);}
481  virtual uint32_t nItems() const {return values.size();}
482 
483  virtual void print(std::ostream&) const;
484  virtual void printFull(std::ostream&) const;
485 
486 private:
488  std::string name;
492 }; // ibis::qUIntHod
493 
504 class FASTBIT_CXX_DLLSPEC ibis::qString : public ibis::qExpr {
505 public:
506  // construct the qString from two strings
507  qString() : qExpr(STRING), lstr(0), rstr(0) {};
508  qString(const char* ls, const char* rs);
509  virtual ~qString() {delete [] rstr; delete [] lstr;}
510 
511  const char* leftString() const {return lstr;}
512  const char* rightString() const {return rstr;}
513  void swapLeftRight() {char* tmp = lstr; lstr = rstr; rstr = tmp;}
514 
515  virtual qString* dup() const {return new qString(*this);}
516  virtual void print(std::ostream&) const;
517  virtual void printFull(std::ostream& out) const {print(out);}
518  virtual void getTableNames(std::set<std::string>& plist) const;
519 
520 private:
521  char* lstr;
522  char* rstr;
523 
525  qString(const qString& rhs) : qExpr(STRING),
526  lstr(ibis::util::strnewdup(rhs.lstr)),
527  rstr(ibis::util::strnewdup(rhs.rstr)) {}
528  qString& operator=(const qString&);
529 }; // ibis::qString
530 
536 class FASTBIT_CXX_DLLSPEC ibis::qExists : public ibis::qExpr {
537 public:
538  qExists() : qExpr(EXISTS) {};
539  qExists(const char *col) : qExpr(EXISTS), name(col) {};
540  virtual ~qExists() {}; // name is automatically destroyed
541 
543  virtual qExists* dup() const {return new qExists(name.c_str());}
544  virtual void print(std::ostream& out) const;
545  virtual void printFull(std::ostream& out) const;
546  virtual bool isSimple() const {
547  return true;
548  }
549 
551  const char* colName() const {return name.c_str();}
552 
553 private:
554  std::string name;
555 }; // ibis::qExists
556 
560 class FASTBIT_CXX_DLLSPEC ibis::qAnyString : public ibis::qExpr {
561 public:
562  qAnyString() : qExpr(ANYSTRING) {};
563  qAnyString(const char *col, const char *sval);
564  virtual ~qAnyString() {}; // name and values are automatically destroyed
565 
567  virtual qAnyString* dup() const {return new qAnyString(*this);}
568  virtual void print(std::ostream& out) const;
569  virtual void printFull(std::ostream& out) const {print(out);}
570 
572  const char* colName() const {return name.c_str();}
574  const std::vector<std::string>& valueList() const {return values;}
576  ibis::qExpr* convert() const;
577  virtual void getTableNames(std::set<std::string>& plist) const;
578 
579 private:
580  std::string name;
581  std::vector<std::string> values;
582 }; // ibis::qAnyString
583 
585 class FASTBIT_CXX_DLLSPEC ibis::qLike : public ibis::qExpr {
586 public:
588  qLike() : qExpr(LIKE), lstr(0), rpat(0) {};
589  qLike(const char* ls, const char* rs);
591  virtual ~qLike() {delete [] rpat; delete [] lstr;}
592 
594  const char* colName() const {return lstr;}
596  const char* pattern() const {return rpat;}
597 
598  virtual qLike* dup() const {return new qLike(*this);}
599  virtual void print(std::ostream&) const;
600  virtual void printFull(std::ostream& out) const {print(out);}
601  virtual void getTableNames(std::set<std::string>& plist) const;
602 
603 private:
605  char* lstr;
607  char* rpat;
608 
610  qLike(const qLike& rhs)
611  : qExpr(LIKE), lstr(ibis::util::strnewdup(rhs.lstr)),
612  rpat(ibis::util::strnewdup(rhs.rpat)) {}
613  qLike& operator=(const qLike&);
614 }; // ibis::qLike
615 
621 class FASTBIT_CXX_DLLSPEC ibis::qKeyword : public ibis::qExpr {
622 public:
623  // construct the qKeyword from two strings
624  qKeyword() : qExpr(KEYWORD), name(0), kword(0) {};
625  qKeyword(const char* ls, const char* rs);
626  virtual ~qKeyword() {delete [] kword; delete [] name;}
627 
630  const char* colName() const {return name;}
633  const char* keyword() const {return kword;}
634 
635  virtual qKeyword* dup() const {return new qKeyword(*this);}
636  virtual void print(std::ostream&) const;
637  virtual void printFull(std::ostream& out) const {print(out);}
638  virtual void getTableNames(std::set<std::string>& plist) const;
639 
640 private:
641  char* name;
642  char* kword;
643 
645  qKeyword(const qKeyword& rhs)
646  : qExpr(KEYWORD), name(ibis::util::strnewdup(rhs.name)),
647  kword(ibis::util::strnewdup(rhs.kword)) {}
648  qKeyword& operator=(const qKeyword&);
649 }; // ibis::qKeyword
650 
659 class FASTBIT_CXX_DLLSPEC ibis::qAllWords : public ibis::qExpr {
660 public:
661  qAllWords() : qExpr(ALLWORDS) {};
662  qAllWords(const char *, const char *);
663  qAllWords(const char *, const char *, const char *);
664  virtual ~qAllWords() {}; // name and values automatically destroyed
665 
667  virtual qAllWords* dup() const {return new qAllWords(*this);}
668  virtual void print(std::ostream& out) const;
669  virtual void printFull(std::ostream& out) const {print(out);}
670 
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;
676  ibis::qExpr* convert() const;
677 
678 private:
679  std::string name;
680  std::vector<std::string> values;
681 }; // ibis::qAllWords
682 
683 namespace ibis {
685  namespace math {
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,
701  IS_LTE};
702 
704  extern const char* operator_name[];
706  extern const char* stdfun1_name[];
708  extern const char* stdfun2_name[];
721  extern bool preserveInputExpressions;
722 
728  class term : public ibis::qExpr {
729  public:
730  virtual ~term() {};
731 
732  virtual TERM_TYPE termType() const = 0;
733 
735  virtual double eval() const = 0;
739  virtual bool isTrue() const {return(eval() != 0);}
741  virtual term* dup() const = 0;
743  virtual void print(std::ostream& out) const = 0;
745  virtual void printFull(std::ostream& out) const {print(out);}
749  virtual term* reduce() {return this;};
750 
751  protected:
752  term() : qExpr(MATHTERM) {}; // used by concrete derived classes
753  term(const term &rhs) : qExpr(rhs) {}
754  }; // abstract term
755 
760  class barrel {
761  public:
763  barrel() {};
765  barrel(const term* const t) {recordVariable(t);}
767  virtual ~barrel() {};
768 
769  // access functions to the names and values
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];}
774 
775  void recordVariable(const qExpr* const t);
776  void recordVariable(const term* const t);
777  uint32_t recordVariable(const char* name);
779  bool equivalent(const barrel& rhs) const;
780 
781  protected:
782  // the data structure to store the variable names in a mathematical
783  // expression
784  typedef std::map< const char*, uint32_t, ibis::lessi > termMap;
785 
786  // functions used by the class variable for accessing values of the
787  // variables
788  friend class variable;
789  double getValue(uint32_t i) const {return varvalues[i];}
791  double getValue(const char* nm) const {
792  termMap::const_iterator it = varmap.find(nm);
793  if (it != varmap.end()) {
794  uint32_t i = (*it).second;
795  return varvalues[i];
796  }
797  else {
798  return DBL_MAX;
799  }
800  }
801 
804  termMap varmap;
806  std::vector< double > varvalues;
808  std::vector< const char* > namelist;
809  }; // class barrel
810 
812  class variable : public term {
813  public:
814  // The constructor inserts the variable name to a list in expr and
815  // record the position in private member variable (that is used
816  // later to retrieve value from expr class).
817  variable(const char* var)
818  : name(ibis::util::strnewdup(var)), myBar(0), varind(0) {}
819  variable(const variable& v)
820  : name(ibis::util::strnewdup(v.name)), decor(v.decor),
821  myBar(v.myBar), varind(v.varind) {}
822  virtual ~variable() {delete [] name;}
823 
824  virtual TERM_TYPE termType() const {return VARIABLE;}
825  virtual variable* dup() const {return new variable(*this);}
826  virtual double eval() const {return myBar->getValue(varind);}
827  virtual void getTableNames(std::set<std::string>& plist) const;
828 
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;}
833 
834  void recordVariable(barrel& bar) const {
835  if (name != 0 && *name != 0 && *name != '*') {
836  varind = bar.recordVariable(name);
837  myBar = &bar;
838  }
839  }
840 
841  void addDecoration(const char *, const char*);
842  const char* getDecoration() const {return decor.c_str();}
843 
844  protected:
845  char* name; // the variable name
846  std::string decor; // name=value pairs
847  mutable barrel* myBar;// the barrel containing it
848  mutable uint32_t varind;// the token to retrieve value from myBar
849 
850  private:
851  variable& operator=(const variable&);
852  }; // the variable term
853 
855  class number : public term {
856  public:
857  number(const char* num) : val(atof(num)) {};
858  number(double v) : val(v) {};
859  virtual ~number() {};
860 
861  virtual TERM_TYPE termType() const {return NUMBER;}
862  virtual number* dup() const {return new number(val);}
863  virtual double eval() const {return val;}
864 
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;}
868  virtual bool isConstant() const {return true;}
869  virtual bool isTrue() const {return(val != 0);}
870 
872  void negate() {val = -val;}
874  void invert() {val = 1.0/val;}
875 
876  private:
877  double val;
878  friend class bediener;
879  friend void ibis::qExpr::simplify(ibis::qExpr*&);
880  }; // number
881 
883  class literal : public term {
884  public:
885  literal(const char* s) : str(ibis::util::strnewdup(s)) {};
886  virtual ~literal() {delete [] str;}
887 
888  virtual TERM_TYPE termType() const {return ibis::math::STRING;}
889  virtual literal* dup() const {return new literal(str);}
890  virtual double eval() const {return 0.0;}
891  virtual bool isConstant() const {return true;}
895  virtual bool isTrue() const {
896  return(str != 0 && (*str == 't' || *str == 'T' ||
897  (*str == '1' && *str == 0)));}
898 
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;}
903 
904  private:
905  char* str;
906 
907  literal(const literal&);
908  literal& operator=(const literal&);
909  }; // literal
910 
912  class bediener : public term {
913  public:
914  bediener(ibis::math::OPERADOR op) : operador(op) {};
915  virtual ~bediener() {};
916 
917  virtual TERM_TYPE termType() const {return OPERATOR;}
918  virtual bediener* dup() const {
919  bediener *tmp = new bediener(operador);
920  if (getRight() != 0)
921  tmp->setRight(getRight()->dup());
922  if (getLeft() != 0)
923  tmp->setLeft(getLeft()->dup());
924  return tmp;
925  }
926  virtual double eval() const;
927  virtual void print(std::ostream& out) const;
928  virtual void printFull(std::ostream& out) const {print(out);}
929  virtual term* reduce();
930  OPERADOR getOperator() const {return operador;}
931 
932  private:
933  ibis::math::OPERADOR operador; // Spanish for operator
934 
935  void reorder(); // reorder the tree of operators
936  // place the operands into the list of terms if the operator
937  // matches the specified one.
938  void linearize(const ibis::math::OPERADOR op,
939  std::vector<ibis::math::term*>& terms);
940  // If the right operand is a constant, change operator from - to +
941  // or from / to *.
942  void convertConstants();
943  friend void ibis::qExpr::simplify(ibis::qExpr*&);
944  }; // bediener
945 
947  class stdFunction1 : public term {
948  public:
949  stdFunction1(const char* name);
950  stdFunction1(const STDFUN1 ft) : ftype(ft) {}
951  virtual ~stdFunction1() {}
952 
953  virtual stdFunction1* dup() const {
954  stdFunction1 *tmp = new stdFunction1(ftype);
955  tmp->setLeft(getLeft()->dup());
956  return tmp;
957  }
958  virtual TERM_TYPE termType() const {return STDFUNCTION1;}
959  virtual double eval() const;
960  virtual void print(std::ostream& out) const;
961  virtual void printFull(std::ostream& out) const {print(out);}
962  virtual term* reduce();
963 
964  private:
965  STDFUN1 ftype;
966  }; // stdFunction1
967 
969  class stdFunction2 : public term {
970  public:
971  stdFunction2(const char* name);
972  stdFunction2(const STDFUN2 ft) : ftype(ft) {}
973  virtual ~stdFunction2() {}
974 
975  virtual stdFunction2* dup() const {
976  stdFunction2 *tmp = new stdFunction2(ftype);
977  tmp->setRight(getRight()->dup());
978  tmp->setLeft(getLeft()->dup());
979  return tmp;
980  }
981  virtual TERM_TYPE termType() const {return STDFUNCTION2;}
982  virtual double eval() const;
983  virtual void print(std::ostream& out) const;
984  virtual void printFull(std::ostream& out) const {print(out);}
985  virtual term* reduce();
986 
987  private:
988  STDFUN2 ftype;
989  }; // stdFunction2
990 
995  class func1 {
996  public:
997  virtual ~func1() {};
999  virtual func1* dup() const =0;
1001  virtual double eval(double) const =0;
1003  virtual void printName(std::ostream&) const =0;
1005  virtual void printDecoration(std::ostream&) const =0;
1006  }; // func1
1007 
1012  class sfunc1 {
1013  public:
1014  virtual ~sfunc1() {};
1016  virtual sfunc1* dup() const =0;
1018  virtual std::string eval(double) const =0;
1020  virtual void printName(std::ostream&) const =0;
1022  virtual void printDecoration(std::ostream&) const =0;
1023  }; // sfunc1
1024 
1026  class customFunction1 : public term {
1027  public:
1028  virtual ~customFunction1() {delete fun_;}
1029  customFunction1(const func1 &ft)
1030  : fun_(ft.dup()) {}
1031  customFunction1(const customFunction1 &rhs)
1032  : fun_(rhs.fun_->dup()) {
1033  if (rhs.getLeft() != 0) {
1034  setLeft(rhs.getLeft()->dup());
1035  }
1036  else if (rhs.getRight() != 0) {
1037  setLeft(rhs.getRight()->dup());
1038  }
1039  }
1040 
1041  virtual customFunction1* dup() const {
1042  return new customFunction1(*this);
1043  }
1044  virtual TERM_TYPE termType() const {return CUSTOMFUNCTION1;}
1045  virtual double eval() const;
1046  virtual void print(std::ostream& out) const;
1047  virtual void printFull(std::ostream& out) const {print(out);}
1048  virtual term* reduce() {return this;}
1049 
1050  private:
1051  func1 *fun_;
1052  }; // customFunction1
1053 
1063  class fromUnixTime : public func1 {
1064  public:
1065  virtual ~fromUnixTime() {}
1066  fromUnixTime(const char *f, const char *z=0)
1067  : fmt_(f), tzname_(z!=0?z:"") {}
1068  fromUnixTime(const fromUnixTime& rhs)
1069  : fmt_(rhs.fmt_), tzname_(rhs.tzname_) {}
1070 
1071  virtual fromUnixTime* dup() const {
1072  return new fromUnixTime(*this);
1073  }
1074 
1075  virtual double eval(double) const;
1076  virtual void printName(std::ostream&) const;
1077  virtual void printDecoration(std::ostream&) const;
1078 
1079  private:
1080  std::string fmt_;
1081  std::string tzname_;
1082  }; // fromUnixTime
1083 
1091  class toUnixTime : public func1 {
1092  public:
1093  virtual ~toUnixTime() {}
1094  toUnixTime(const char *z=0) : tzname_(z!=0?z:"") {}
1095  toUnixTime(const toUnixTime& rhs) : tzname_(rhs.tzname_) {}
1096 
1097  virtual toUnixTime* dup() const {
1098  return new toUnixTime(*this);
1099  }
1100 
1101  virtual double eval(double) const;
1102  virtual void printName(std::ostream&) const;
1103  virtual void printDecoration(std::ostream&) const;
1104 
1105  private:
1106  std::string tzname_;
1107  }; // toUnixTime
1108 
1110  class stringFunction1 : public term {
1111  public:
1112  virtual ~stringFunction1() {delete fun_;}
1113  stringFunction1(const sfunc1 &ft)
1114  : fun_(ft.dup()) {}
1115  stringFunction1(const stringFunction1 &rhs)
1116  : fun_(rhs.fun_->dup()) {
1117  if (rhs.getLeft() != 0) {
1118  setLeft(rhs.getLeft()->dup());
1119  }
1120  else if (rhs.getRight() != 0) {
1121  setLeft(rhs.getRight()->dup());
1122  }
1123  }
1124 
1125  virtual stringFunction1* dup() const {
1126  return new stringFunction1(*this);
1127  }
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;
1132  virtual void printFull(std::ostream& out) const {print(out);}
1133  virtual term* reduce() {return this;}
1134 
1135  private:
1136  sfunc1 *fun_;
1137  }; // stringFunction1
1138 
1142  class formatUnixTime : public sfunc1 {
1143  public:
1144  virtual ~formatUnixTime() {}
1145  formatUnixTime(const char *f, const char *z=0)
1146  : fmt_(f), tzname_(z!=0?z:"") {}
1147  formatUnixTime(const formatUnixTime& rhs)
1148  : fmt_(rhs.fmt_), tzname_(rhs.tzname_) {}
1149 
1150  virtual formatUnixTime* dup() const {
1151  return new formatUnixTime(*this);
1152  }
1153 
1154  virtual std::string eval(double) const;
1155  virtual void printName(std::ostream&) const;
1156  virtual void printDecoration(std::ostream&) const;
1157 
1158  private:
1159  std::string fmt_;
1160  std::string tzname_;
1161  }; // formatUnixTime
1162  } // namespace ibis::math
1163 } // namespace ibis
1164 
1167 class FASTBIT_CXX_DLLSPEC ibis::compRange : public ibis::qExpr {
1168 public:
1169 
1171  compRange() : qExpr(ibis::qExpr::COMPRANGE), expr3(0),
1172  op12(ibis::qExpr::OP_UNDEFINED),
1173  op23(ibis::qExpr::OP_UNDEFINED) {;}
1177  ibis::math::term* me2)
1178  : qExpr(ibis::qExpr::COMPRANGE, me1, me2), expr3(0),
1179  op12(lop), op23(ibis::qExpr::OP_UNDEFINED) {;}
1184  ibis::math::term* me3)
1185  : qExpr(ibis::qExpr::COMPRANGE, me1, me2), expr3(me3),
1186  op12(lop), op23(rop) {;}
1188  compRange(const compRange& rhs) :
1189  ibis::qExpr(rhs), expr3(rhs.expr3 ? rhs.expr3->dup() : 0),
1190  op12(rhs.op12), op23(rhs.op23) {};
1192  virtual ~compRange() {delete expr3;}
1193 
1194  // provide read access to the operators
1195  ibis::qExpr::COMPARE leftOperator() const {return op12;}
1196  ibis::qExpr::COMPARE rightOperator() const {return op23;}
1197  ibis::math::term* getTerm3() {return expr3;}
1198  const ibis::math::term* getTerm3() const {return expr3;}
1199  void setTerm3(ibis::math::term* t) {delete expr3; expr3 = t;}
1200 
1202  virtual qExpr* dup() const {return new compRange(*this);}
1204  inline bool inRange() const;
1205 
1206  virtual uint32_t nItems() const {
1207  return ibis::qExpr::nItems() +
1208  (expr3 != 0 ? expr3->nItems() : 0);}
1210  virtual void print(std::ostream&) const;
1211  virtual void printFull(std::ostream& out) const {print(out);}
1212  virtual void getTableNames(std::set<std::string>& plist) const;
1213 
1214  virtual bool isConstant() const {
1215  return ((getLeft() != 0 ? getLeft()->isConstant() : true) &&
1216  (getRight() != 0 ? getRight()->isConstant() : true) &&
1217  (expr3 != 0 ? expr3->isConstant() : true));}
1218  virtual bool isSimple() const {return isSimpleRange();}
1220  inline bool isSimpleRange() const;
1221 
1223  bool maybeStringCompare() const;
1224 
1225  // convert a simple expression to qContinuousRange
1226  ibis::qContinuousRange* simpleRange() const;
1227  static compRange* makeConstantFalse();
1228  static compRange* makeConstantTrue();
1229 
1230 private:
1231  ibis::math::term *expr3; // the right most expression
1232  ibis::qExpr::COMPARE op12; // between qExpr::left and qExpr::right
1233  ibis::qExpr::COMPARE op23; // between qExpr::right and expr3
1234 }; // ibis::compRange
1235 
1241 public:
1242  deprecatedJoin(const char* n1, const char *n2)
1243  : ibis::qExpr(ibis::qExpr::DEPRECATEDJOIN), name1(n1), name2(n2),
1244  expr(0) {};
1245  deprecatedJoin(const char* n1, const char *n2, ibis::math::term *x) :
1246  ibis::qExpr(ibis::qExpr::DEPRECATEDJOIN), name1(n1), name2(n2),
1247  expr(x) {};
1248  virtual ~deprecatedJoin() {delete expr;};
1249 
1250  virtual void print(std::ostream& out) const;
1251  virtual void printFull(std::ostream& out) const {print(out);}
1252  virtual deprecatedJoin* dup() const
1253  {return new deprecatedJoin(name1.c_str(), name2.c_str(), expr->dup());};
1254 
1255  const char* getName1() const {return name1.c_str();}
1256  const char* getName2() const {return name2.c_str();}
1257  ibis::math::term* getRange() {return expr;}
1258  const ibis::math::term* getRange() const {return expr;}
1259  void setRange(ibis::math::term *t) {delete expr; expr = t;}
1260 
1261  virtual uint32_t nItems() const {
1262  return ibis::qExpr::nItems() +
1263  (expr != 0 ? expr->nItems() : 0);}
1264 
1265 private:
1266  std::string name1;
1267  std::string name2;
1268  ibis::math::term *expr;
1269 
1271  deprecatedJoin& operator=(const deprecatedJoin&);
1272 }; // class ibis::deprecatedJoin
1273 
1285 class ibis::qAnyAny : public ibis::qExpr {
1286 public:
1287  qAnyAny() : qExpr(ANYANY) {};
1288  qAnyAny(const char *pre, const double dbl);
1289  qAnyAny(const char *pre, const char *val);
1290  ~qAnyAny() {}; // all data members can delete themselves.
1291 
1292  const char* getPrefix() const {return prefix.c_str();}
1293  const ibis::array_t<double>& getValues() const {return values;}
1294 
1297  virtual qExpr* dup() const {return new qAnyAny(*this);}
1298 
1299  virtual void print(std::ostream& out) const;
1300  virtual void printFull(std::ostream& out) const {print(out);}
1301  virtual void getTableNames(std::set<std::string>& plist) const;
1302 
1303 private:
1304  std::string prefix;
1305  ibis::array_t<double> values;
1306 }; // class ibis::qAnyAny
1307 
1308 inline void ibis::qContinuousRange::foldBoundaries() {
1309  switch (left_op) {
1310  case ibis::qExpr::OP_LT:
1311  lower = floor(lower);
1312  break;
1313  case ibis::qExpr::OP_LE:
1314  lower = ceil(lower);
1315  break;
1316  case ibis::qExpr::OP_GT:
1317  lower = ceil(lower);
1318  break;
1319  case ibis::qExpr::OP_GE:
1320  lower = floor(lower);
1321  break;
1322  case ibis::qExpr::OP_EQ:
1323  if (lower != floor(lower))
1324  left_op = ibis::qExpr::OP_UNDEFINED;
1325  break;
1326  default:
1327  break;
1328  }
1329  switch (right_op) {
1330  case ibis::qExpr::OP_LT:
1331  upper = ceil(upper);
1332  break;
1333  case ibis::qExpr::OP_LE:
1334  upper = floor(upper);
1335  break;
1336  case ibis::qExpr::OP_GT:
1337  upper = floor(upper);
1338  break;
1339  case ibis::qExpr::OP_GE:
1340  upper = ceil(upper);
1341  break;
1342  case ibis::qExpr::OP_EQ:
1343  if (upper != floor(upper))
1344  right_op = ibis::qExpr::OP_UNDEFINED;
1345  break;
1346  default:
1347  break;
1348  }
1349 } //ibis::qContinuousRange::foldBoundaries
1350 
1351 inline void ibis::qContinuousRange::foldUnsignedBoundaries() {
1352  switch (left_op) {
1353  case ibis::qExpr::OP_LT:
1354  if (lower >= 0.0) {
1355  lower = floor(lower);
1356  }
1357  else {
1358  left_op = ibis::qExpr::OP_LE;
1359  lower = 0.0;
1360  }
1361  break;
1362  case ibis::qExpr::OP_LE:
1363  if (lower >= 0.0)
1364  lower = ceil(lower);
1365  else
1366  lower = 0.0;
1367  break;
1368  case ibis::qExpr::OP_GT:
1369  lower = ceil(lower);
1370  break;
1371  case ibis::qExpr::OP_GE:
1372  lower = floor(lower);
1373  break;
1374  case ibis::qExpr::OP_EQ:
1375  if (lower != floor(lower) || lower < 0.0)
1376  left_op = ibis::qExpr::OP_UNDEFINED;
1377  break;
1378  default:
1379  break;
1380  }
1381  switch (right_op) {
1382  case ibis::qExpr::OP_LT:
1383  upper = ceil(upper);
1384  break;
1385  case ibis::qExpr::OP_LE:
1386  upper = floor(upper);
1387  break;
1388  case ibis::qExpr::OP_GT:
1389  if (upper > 0.0) {
1390  upper = floor(upper);
1391  }
1392  else {
1393  right_op = ibis::qExpr::OP_GE;
1394  upper = 0.0;
1395  }
1396  break;
1397  case ibis::qExpr::OP_GE:
1398  if (upper >= 0.0)
1399  upper = ceil(upper);
1400  else
1401  upper = 0.0;
1402  break;
1403  case ibis::qExpr::OP_EQ:
1404  if (upper != floor(upper) || upper < 0.0)
1405  right_op = ibis::qExpr::OP_UNDEFINED;
1406  break;
1407  default:
1408  break;
1409  }
1410 } //ibis::qContinuousRange::foldUnsignedBoundaries
1411 
1415 inline bool
1417  int cmp = strcmp(colName(), y.colName());
1418  if (cmp < 0)
1419  return true;
1420  else if (cmp > 0)
1421  return false;
1422  else if (left_op < y.left_op)
1423  return true;
1424  else if (left_op > y.left_op)
1425  return false;
1426  else if (right_op < y.right_op)
1427  return true;
1428  else if (right_op > y.right_op)
1429  return false;
1430  else if (lower < y.lower)
1431  return true;
1432  else if (lower > y.lower)
1433  return false;
1434  else if (upper < y.upper)
1435  return true;
1436  else
1437  return false;
1438 } // ibis::qContinuousRange::operator<
1439 
1440 inline bool ibis::compRange::isSimpleRange() const {
1441  bool res = false;
1442  if (expr3 == 0 && getLeft() != 0)
1443  res = ((static_cast<const ibis::math::term*>(getLeft())->
1444  termType()==ibis::math::VARIABLE &&
1445  static_cast<const ibis::math::term*>(getRight())->
1446  termType()==ibis::math::NUMBER) ||
1447  (static_cast<const ibis::math::term*>(getLeft())->
1448  termType()==ibis::math::NUMBER &&
1449  static_cast<const ibis::math::term*>(getRight())->
1450  termType()==ibis::math::VARIABLE));
1451  else if (expr3 != 0 && expr3->termType()==ibis::math::NUMBER)
1452  res = (getLeft() == 0 &&
1453  static_cast<const ibis::math::term*>(getRight())->termType()
1454  == ibis::math::VARIABLE) ||
1455  (static_cast<const ibis::math::term*>(getLeft())->
1456  termType()==ibis::math::NUMBER &&
1457  static_cast<const ibis::math::term*>(getRight())->
1458  termType()==ibis::math::VARIABLE);
1459  return res;
1460 } // ibis::compRange::isSimpleRange
1461 
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));
1472 } // ibis::compRange::maybeStringCompare
1473 
1476 inline bool ibis::compRange::inRange() const {
1477  if (getRight() == 0) return false;
1478 
1479  const double tm2 =
1480  static_cast<const ibis::math::term*>(getRight())->eval();
1481  if (op12 == OP_UNDEFINED && op23 == OP_UNDEFINED)
1482  return (tm2 != 0.0);
1483 
1484  bool res = true;
1485  if (getLeft() != 0 && op12 != OP_UNDEFINED) {
1486  const double tm1 =
1487  static_cast<const ibis::math::term*>(getLeft())->eval();
1488  switch (op12) {
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;
1494  default: break;
1495  }
1496  }
1497  if (expr3 != 0 && op23 != OP_UNDEFINED && res == true) {
1498  const double tm3 = expr3->eval();
1499  switch (op23) {
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;
1505  default: break;
1506  }
1507  }
1508  return res;
1509 } // ibis::compRange::inRange
1510 
1515 inline bool ibis::qDiscreteRange::inRange(double val) const {
1516  if (values.empty()) return false;
1517  if (val < values[0] || val > values.back()) return false;
1518 
1519  uint32_t i = 0, j = values.size();
1520  if (j < 32) { // sequential search
1521  // -- because the heavy branch prediction cost, linear search is
1522  // more efficient for fairly large range.
1523  for (i = 0; i < j; ++ i)
1524  if (values[i] == val) return true;
1525  return false;
1526  }
1527  else { // binary search
1528  uint32_t m = (i + j) / 2;
1529  while (i < m) {
1530  if (values[m] == val) return true;
1531  if (values[m] < val)
1532  i = m;
1533  else
1534  j = m;
1535  m = (i + j) / 2;
1536  }
1537  return (values[m] == val);
1538  }
1539 } // ibis::qDiscreteRange::inRange
1540 
1545 inline bool ibis::qIntHod::inRange(double val) const {
1546  if (values.empty()) return false;
1547  if (val < values[0] || val > values.back()) return false;
1548 
1549  uint32_t i = 0, j = values.size();
1550  if (j < 32) { // sequential search
1551  // -- because the heavy branch prediction cost, linear search is
1552  // more efficient for fairly large range.
1553  for (i = 0; i < j; ++ i)
1554  if (values[i] == val) return true;
1555  return false;
1556  }
1557  else { // binary search
1558  uint32_t m = (i + j) / 2;
1559  while (i < m) {
1560  if (values[m] == val) return true;
1561  if (values[m] < val)
1562  i = m;
1563  else
1564  j = m;
1565  m = (i + j) / 2;
1566  }
1567  return (values[m] == val);
1568  }
1569 } // ibis::qIntHod::inRange
1570 
1575 inline bool ibis::qUIntHod::inRange(double val) const {
1576  if (values.empty()) return false;
1577  if (val < values[0] || val > values.back()) return false;
1578 
1579  uint32_t i = 0, j = values.size();
1580  if (j < 32) { // sequential search
1581  // -- because the heavy branch prediction cost, linear search is
1582  // more efficient for fairly large range.
1583  for (i = 0; i < j; ++ i)
1584  if (values[i] == val) return true;
1585  return false;
1586  }
1587  else { // binary search
1588  uint32_t m = (i + j) / 2;
1589  while (i < m) {
1590  if (values[m] == val) return true;
1591  if (values[m] < val)
1592  i = m;
1593  else
1594  j = m;
1595  m = (i + j) / 2;
1596  }
1597  return (values[m] == val);
1598  }
1599 } // ibis::qUIntHod::inRange
1600 
1605 inline bool ibis::qIntHod::inRange(int64_t val) const {
1606  if (values.empty()) return false;
1607  if (val < values[0] || val > values.back()) return false;
1608 
1609  uint32_t i = 0, j = values.size();
1610  if (j < 32) { // sequential search
1611  // -- because the heavy branch prediction cost, linear search is
1612  // more efficient for fairly large range.
1613  for (i = 0; i < j; ++ i)
1614  if (values[i] == val) return true;
1615  return false;
1616  }
1617  else { // binary search
1618  uint32_t m = (i + j) / 2;
1619  while (i < m) {
1620  if (values[m] == val) return true;
1621  if (values[m] < val)
1622  i = m;
1623  else
1624  j = m;
1625  m = (i + j) / 2;
1626  }
1627  return (values[m] == val);
1628  }
1629 } // ibis::qIntHod::inRange
1630 
1635 inline bool ibis::qUIntHod::inRange(uint64_t val) const {
1636  if (values.empty()) return false;
1637  if (val < values[0] || val > values.back()) return false;
1638 
1639  uint32_t i = 0, j = values.size();
1640  if (j < 32) { // sequential search
1641  // -- because the heavy branch prediction cost, linear search is
1642  // more efficient for fairly large range.
1643  for (i = 0; i < j; ++ i)
1644  if (values[i] == val) return true;
1645  return false;
1646  }
1647  else { // binary search
1648  uint32_t m = (i + j) / 2;
1649  while (i < m) {
1650  if (values[m] == val) return true;
1651  if (values[m] < val)
1652  i = m;
1653  else
1654  j = m;
1655  m = (i + j) / 2;
1656  }
1657  return (values[m] == val);
1658  }
1659 } // ibis::qUIntHod::inRange
1660 
1661 namespace std {
1662  inline ostream& operator<<(ostream&, const ibis::qExpr&);
1663  inline ostream& operator<<(ostream&, const ibis::qExpr::COMPARE&);
1664 }
1665 
1669 inline std::ostream& std::operator<<(std::ostream& out, const ibis::qExpr& pn) {
1670  if (ibis::gVerbose > 5)
1671  pn.printFull(out);
1672  else
1673  pn.print(out);
1674  return out;
1675 } // std::operator<<
1676 
1678 inline std::ostream& std::operator<<(std::ostream& out,
1679  const ibis::qExpr::COMPARE& op) {
1680  switch (op) {
1681  default:
1682  case ibis::qExpr::OP_UNDEFINED:
1683  out << "??"; break;
1684  case ibis::qExpr::OP_LT:
1685  out << "<"; break;
1686  case ibis::qExpr::OP_LE:
1687  out << "<="; break;
1688  case ibis::qExpr::OP_GT:
1689  out << ">"; break;
1690  case ibis::qExpr::OP_GE:
1691  out << ">="; break;
1692  case ibis::qExpr::OP_EQ:
1693  out << "=="; break;
1694  }
1695  return out;
1696 } // std::operator<<
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 void printDecoration(std::ostream &) const
Print the decoration on this function.
Definition: qExpr.cpp:4281
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
STL namespace.
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 std::string eval(double) const
Evaluate the function on the given argument.
Definition: qExpr.cpp:4242
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 printName(std::ostream &) const
Print the name of this function.
Definition: qExpr.cpp:4271
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
virtual formatUnixTime * dup() const
Duplicate thyself. Should follow deep-copy semantics.
Definition: qExpr.h:1150
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
Format unix time stamps as strings through the function strftime and then output the leading portion ...
Definition: qExpr.h:1142
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

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