countQuery.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) 2008-2016 the Regents of the University of California
5 #ifndef IBIS_COUNTQUERY_H
6 #define IBIS_COUNTQUERY_H
7 #include "part.h" // class part
11 #include "whereClause.h" // ibis::whereClause
12 
13 namespace ibis {
14  class countQuery;
15 }
16 
25 class FASTBIT_CXX_DLLSPEC ibis::countQuery {
26 public:
28  virtual ~countQuery() {clear();}
30  countQuery(const part* et=0, const ibis::selectClause *s=0)
31  : mypart(et), m_sel(s), hits(0), cand(0) {};
32 
34  int setWhereClause(const char *str);
36  int setWhereClause(const ibis::qExpr*);
38  const char* getWhereClause() const {return conds.getString();}
41  int setPartition(const ibis::part* tbl);
43  const part* getPartition() const {return mypart;}
45  int setSelectClause(const ibis::selectClause *s);
47  const selectClause* getSelectClause() const {return m_sel;}
48 
50  int estimate();
52  long getMinNumHits() const;
54  long getMaxNumHits() const;
55 
57  int evaluate();
59  long getNumHits() const;
61  long getHitRows(std::vector<uint32_t> &rids) const;
64  const ibis::bitvector* getHitVector() const {return hits;}
67  const ibis::bitvector* getCandVector() const {return cand;}
68 
71  void clear();
72 
73 protected:
74  whereClause conds;
75  const part* mypart;
79 
81  void doEstimate(const qExpr* term, ibis::bitvector& low,
82  ibis::bitvector& high) const;
84  int doEvaluate(const qExpr* term, const ibis::bitvector& mask,
85  ibis::bitvector& hits) const;
87  int doScan(const ibis::qExpr* term, const ibis::bitvector& mask,
88  ibis::bitvector& ht) const;
89 
90 private:
91  countQuery(const countQuery&);
92  countQuery& operator=(const countQuery&);
93 }; // class ibis::countQuery
94 
96  if (s == 0) return -1;
97  m_sel = s;
98  return 0;
99 } // ibis::countQuery::setSelectClause
100 #endif // IBIS_COUNTQUERY_H
int doEvaluate(const qExpr *term, const ibis::bitvector &mask, ibis::bitvector &hits) const
Evaluate one term of a query expression.
Definition: countQuery.cpp:929
A representation of the where clause.
Definition: whereClause.h:161
void clear()
Releases the resources held by the query object and re-initialize the select clause and the where cla...
Definition: countQuery.cpp:1200
ibis::bitvector * hits
!< Select clause.
Definition: countQuery.h:77
const ibis::bitvector * getCandVector() const
Return the pointer to the candidates vector.
Definition: countQuery.h:67
The top level query expression object.
Definition: qExpr.h:36
A class to represent the select clause.
Definition: selectClause.h:112
int estimate()
Functions to perform estimation.
Definition: countQuery.cpp:200
int evaluate()
Computes the exact hits.
Definition: countQuery.cpp:292
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
A simple count query.
Definition: countQuery.h:25
const selectClause * m_sel
!< Data partition used to process the query.
Definition: countQuery.h:76
long getNumHits() const
Return the number of records in the exact solution.
Definition: countQuery.cpp:376
virtual ~countQuery()
Destructor.
Definition: countQuery.h:28
const part * mypart
!< Query conditions.
Definition: countQuery.h:75
const char * getWhereClause() const
Return the where clause string.
Definition: countQuery.h:38
const part * getPartition() const
Return the pointer to the data partition used to process the count.
Definition: countQuery.h:43
int setSelectClause(const ibis::selectClause *s)
Change the select clause.
Definition: countQuery.h:95
int doScan(const ibis::qExpr *term, const ibis::bitvector &mask, ibis::bitvector &ht) const
Evaluate one term using the base data.
Definition: countQuery.cpp:718
int setWhereClause(const char *str)
Specify the where clause in string form.
Definition: countQuery.cpp:81
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
ibis::bitvector * cand
!< Solution in bitvector form (or lower bound)
Definition: countQuery.h:78
const ibis::bitvector * getHitVector() const
Return the pointer to the internal hit vector.
Definition: countQuery.h:64
long getHitRows(std::vector< uint32_t > &rids) const
Get the row numbers of the hits.
Definition: countQuery.cpp:387
countQuery(const part *et=0, const ibis::selectClause *s=0)
Constructor. Generates a new countQuery on the data partition et.
Definition: countQuery.h:30
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
void doEstimate(const qExpr *term, ibis::bitvector &low, ibis::bitvector &high) const
!< Candidate query results.
Definition: countQuery.cpp:423
long getMinNumHits() const
Return the number of records in the lower bound.
Definition: countQuery.cpp:276
Declares ibis::whereClause class.
int setPartition(const ibis::part *tbl)
Resets the data partition used to evaluate the query conditions to the partition specified in the arg...
Definition: countQuery.cpp:34
long getMaxNumHits() const
Return the number of records in the upper bound.
Definition: countQuery.cpp:281
const selectClause * getSelectClause() const
Return the pointer to the select clause.
Definition: countQuery.h:47
Define the class ibis::part.

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