00001 //File: $Id$ 00002 // Author: John Wu <John.Wu at ACM.org> 00003 // Lawrence Berkeley National Laboratory 00004 // Copyright 2008-2012 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;} 00067 const ibis::bitvector* getCandVector() const {return cand;} 00068 00071 void clear(); 00072 00073 protected: 00074 whereClause conds; 00075 const part* mypart; 00076 const selectClause *m_sel; 00077 ibis::bitvector* hits; 00078 ibis::bitvector* cand; 00079 00081 void doEstimate(const qExpr* term, ibis::bitvector& low, 00082 ibis::bitvector& high) const; 00084 int doEvaluate(const qExpr* term, const ibis::bitvector& mask, 00085 ibis::bitvector& hits) const; 00087 int doScan(const ibis::qExpr* term, const ibis::bitvector& mask, 00088 ibis::bitvector& ht) const; 00089 00090 private: 00091 countQuery(const countQuery&); 00092 countQuery& operator=(const countQuery&); 00093 }; // class ibis::countQuery 00094 00095 inline int ibis::countQuery::setSelectClause(const ibis::selectClause *s) { 00096 if (s == 0) return -1; 00097 m_sel = s; 00098 return 0; 00099 } // ibis::countQuery::setSelectClause 00100 #endif // IBIS_COUNTQUERY_H
![]() |