whereClause.h
Go to the documentation of this file.
1 // $Id$
2 // Author: John Wu <John.Wu at acm.org>
3 // Lawrence Berkeley National Laboratory
4 // Copyright (c) 2007-2016 the Regents of the University of California
8 #ifndef IBIS_WHERECLAUSE_H
9 #define IBIS_WHERECLAUSE_H
10 #include "qExpr.h"
11 
12 namespace ibis {
13  class selectClause;
14  class whereClause;
15  class whereLexer;
16  class whereParser;
17 }
18 
162 public:
164  explicit whereClause(const char *cl=0);
166  whereClause(const whereClause&);
168  ~whereClause();
169 
171  int parse(const char *cl);
173  void resetString() {
174  if (expr_ != 0) {
175  std::ostringstream oss;
176  oss << *expr_;
177  clause_ = oss.str();
178  }
179  else {
180  clause_.clear();
181  }
182  }
185  void setExpr(const ibis::qExpr *ex) {
186  clause_.clear();
187  delete expr_;
188  expr_ = ex->dup();
189  }
190  void addExpr(const ibis::qExpr *);
191  void addConditions(const char *);
192 
194  void clear() throw ();
196  bool empty() const {return (expr_ == 0);}
197 
199  const char* getString(void) const {
200  if (clause_.empty())
201  return "";
202  else
203  return clause_.c_str();
204  }
209  const ibis::qExpr* getExpr(void) const {return expr_;}
214  ibis::qExpr* getExpr(void) {return expr_;}
217  int verify(const ibis::part& p0, const ibis::selectClause *sel=0) const;
218  void getNullMask(const ibis::part&, ibis::bitvector&) const;
219 
223  const ibis::qExpr* operator->() const {return expr_;}
224 
228  void swap(whereClause& rhs) throw () {
229  clause_.swap(rhs.clause_);
230  ibis::qExpr* tmp = rhs.expr_;
231  rhs.expr_ = expr_;
232  expr_ = tmp;
233  }
234 
235  static int verifyExpr(const ibis::qExpr*, const ibis::part&,
236  const ibis::selectClause *);
237  static int verifyExpr(ibis::qExpr*&, const ibis::part&,
238  const ibis::selectClause *);
239  static int removeAlias(ibis::qContinuousRange*&, const ibis::column*);
240 
241 protected:
242  std::string clause_;
244 
245  void amplify(const ibis::part&);
246 
247 private:
248  ibis::whereLexer *lexer; // hold a pointer for the parser
249 
250  friend class ibis::whereParser;
251 }; // class ibis::whereClause
252 
253 namespace std {
254  inline ostream& operator<<(ostream& out, const ibis::whereClause& wc) {
255  if (!wc.empty())
256  wc->print(out);
257  return out;
258  } // std::operator<<
259 }
260 #endif
whereClause & operator=(const whereClause &)
Assignment operator.
Definition: whereClause.cpp:25
ibis::qExpr * operator->()
Member access operator redefined to point to ibis::qExpr.
Definition: whereClause.h:221
A representation of the where clause.
Definition: whereClause.h:161
Simple range condition.
Definition: qExpr.h:252
const ibis::qExpr * operator->() const
Member access operator redefined to point to const ibis::qExpr.
Definition: whereClause.h:223
static int removeAlias(ibis::qContinuousRange *&, const ibis::column *)
Create a simple range expression as the replacement of the incoming oldr.
Definition: whereClause.cpp:860
The top level query expression object.
Definition: qExpr.h:36
A class to represent the select clause.
Definition: selectClause.h:112
STL namespace.
const char * getString(void) const
Return a pointer to the string form of the where clause.
Definition: whereClause.h:199
void addConditions(const char *)
Append a set of conditions to the existing where clause.
Definition: whereClause.cpp:76
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
The class to represent a column of a data partition.
Definition: column.h:65
void addExpr(const ibis::qExpr *)
Append a set of conditions to the existing where clause.
Definition: whereClause.cpp:105
void simplify()
Simplify the query expression.
Definition: whereClause.h:216
void swap(whereClause &rhs)
Swap the contents of two where clauses.
Definition: whereClause.h:228
Define the query expression.
Defines a new class with the desired lex function for C++ output of bison.
Definition: whereLexer.h:41
virtual qExpr * dup() const
!< Reorder the expressions tree.
Definition: qExpr.h:128
bool empty() const
The where clause is considered empty if the expr_ is a nil pointer.
Definition: whereClause.h:196
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
void setExpr(const ibis::qExpr *ex)
Assign a new set of conditions directly.
Definition: whereClause.h:185
ibis::qExpr * expr_
!< String version of the where clause.
Definition: whereClause.h:243
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
virtual void print(std::ostream &) const
Print out the node in the string form.
Definition: qExpr.cpp:910
int parse(const char *cl)
Parse a new string.
Definition: whereClause.cpp:31
ibis::qExpr * getExpr(void)
Return a pointer to the root of the expression tree for the where clause.
Definition: whereClause.h:214
int verify(const ibis::part &p0, const ibis::selectClause *sel=0) const
Verify that the names exist in the data partition.
Definition: whereClause.cpp:245
void resetString()
Regenerate the string version of the query conditions.
Definition: whereClause.h:173
static void simplify(ibis::qExpr *&)
Attempt to simplify the query expressions.
Definition: qExpr.cpp:51
void clear()
Clear the existing content.
Definition: whereClause.cpp:119
void amplify(const ibis::part &)
!< The expression tree.
Definition: whereClause.cpp:128
const ibis::qExpr * getExpr(void) const
Return a pointer to the root of the expression tree for the where clause.
Definition: whereClause.h:209
~whereClause()
Destructor.
Definition: whereClause.cpp:11
whereClause(const char *cl=0)
Construct a where clause from a string.
Definition: whereClause.cpp:15

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