00001 //File: $Id$ 00002 // Author: John Wu <John.Wu at ACM.org> 00003 // Lawrence Berkeley National Laboratory 00004 // Copyright 2008-2011 the Regents of the University of California 00005 #ifndef IBIS_COUNTQUERY_H 00006 #define IBIS_COUNTQUERY_H 00007 00008 00009 00010 #include "part.h" // class part 00011 #include "whereClause.h" // ibis::whereClause 00012 00013 namespace ibis { 00014 class countQuery; 00015 } 00016 00025 class FASTBIT_CXX_DLLSPEC ibis::countQuery { 00026 public: 00028 virtual ~countQuery() {clear();} 00030 countQuery(const part* et=0, const ibis::selectClause *s=0) 00031 : mypart(et), m_sel(s), hits(0), cand(0) {}; 00032 00034 int setWhereClause(const char *str); 00036 int setWhereClause(const ibis::qExpr*); 00038 const char* getWhereClause() const {return conds.getString();} 00041 int setPartition(const ibis::part* tbl); 00043 const part* getPartition() const {return mypart;} 00045 int setSelectClause(const ibis::selectClause *s); 00047 const selectClause* getSelectClause() const {return m_sel;} 00048 00050 int estimate(); 00052 long getMinNumHits() const; 00054 long getMaxNumHits() const; 00055 00057 int evaluate(); 00059 long getNumHits() const; 00061 long getHitRows(std::vector<uint32_t> &rids) const; 00064 const ibis::bitvector* getHitVector() const {return hits;} 00065 00068 void clear(); 00069 00070 protected: 00071 whereClause conds; 00072 const part* mypart; 00073 const selectClause *m_sel; 00074 ibis::bitvector* hits; 00075 ibis::bitvector* cand; 00076 00078 void doEstimate(const qExpr* term, ibis::bitvector& low, 00079 ibis::bitvector& high) const; 00081 int doEvaluate(const qExpr* term, const ibis::bitvector& mask, 00082 ibis::bitvector& hits) const; 00084 int doScan(const ibis::qExpr* term, const ibis::bitvector& mask, 00085 ibis::bitvector& ht) const; 00086 00087 private: 00088 countQuery(const countQuery&); 00089 countQuery& operator=(const countQuery&); 00090 }; // class ibis::countQuery 00091 00092 inline int ibis::countQuery::setSelectClause(const ibis::selectClause *s) { 00093 if (s == 0) return -1; 00094 m_sel = s; 00095 return 0; 00096 } // ibis::countQuery::setSelectClause 00097 #endif // IBIS_COUNTQUERY_H
![]() |