idirekte.h
Go to the documentation of this file.
1 //File: $Id$
2 // Author: John Wu <John.Wu at ACM.org>
3 // Copyright (c) 2006-2016 the Regents of the University of California
4 #ifndef IBIS_DIREKTE_H
5 #define IBIS_DIREKTE_H
6 #include "index.h"
11 
17 class ibis::direkte : public ibis::index {
18 public:
19  virtual INDEX_TYPE type() const {return DIREKTE;}
20  virtual const char* name() const {return "direct";}
21 
24  virtual long evaluate(const ibis::qContinuousRange& expr,
25  ibis::bitvector& hits) const;
26  virtual void estimate(const ibis::qContinuousRange& expr,
27  ibis::bitvector& lower,
28  ibis::bitvector& upper) const;
29  virtual uint32_t estimate(const ibis::qContinuousRange& expr) const;
30  virtual float undecidable(const ibis::qContinuousRange& expr,
31  ibis::bitvector& iffy) const {
32  iffy.clear();
33  return 0.0;
34  }
35 
36  virtual long evaluate(const ibis::qDiscreteRange& expr,
37  ibis::bitvector& hits) const;
38  virtual void estimate(const ibis::qDiscreteRange& expr,
39  ibis::bitvector& lower,
40  ibis::bitvector& upper) const;
41  virtual uint32_t estimate(const ibis::qDiscreteRange& expr) const;
42  virtual float undecidable(const ibis::qDiscreteRange& expr,
43  ibis::bitvector& iffy) const {
44  iffy.clear();
45  return 0.0;
46  }
47 
48  virtual double estimateCost(const ibis::qContinuousRange& expr) const;
49  virtual double estimateCost(const ibis::qDiscreteRange& expr) const;
50 
51  virtual long select(const ibis::qContinuousRange&, void*) const {
52  return -1;}
53  virtual long select(const ibis::qContinuousRange&, void*,
54  ibis::bitvector&) const {
55  return -1;}
56 
57  virtual void print(std::ostream& out) const;
58  virtual void serialSizes(uint64_t&, uint64_t&, uint64_t&) const;
59  virtual int write(ibis::array_t<double> &,
61  ibis::array_t<uint32_t> &) const;
62  virtual int write(const char* name) const;
63  virtual int read(const char* name);
64  virtual int read(ibis::fileManager::storage* st);
65 
66  virtual long append(const char* dt, const char* df, uint32_t nnew);
67 
68  long append(const ibis::direkte& tail);
69  long append(const array_t<uint32_t>& ind);
70 
71  void ints(array_t<uint32_t>&) const;
73  array_t<uint32_t>* keys(const ibis::bitvector& mask) const;
74 
77  virtual void speedTest(std::ostream& out) const {};
78 
79  virtual void binBoundaries(std::vector<double>&) const;
80  virtual void binWeights(std::vector<uint32_t>&) const;
81 
82  virtual double getMin() const {return 0.0;}
83  virtual double getMax() const {return(bits.size()-1.0);}
84  virtual double getSum() const;
85  virtual long getCumulativeDistribution
86  (std::vector<double>& bds, std::vector<uint32_t>& cts) const;
87  virtual long getDistribution
88  (std::vector<double>& bbs, std::vector<uint32_t>& cts) const;
89 
90  virtual index* dup() const;
91  virtual ~direkte() {clear();}
92  direkte(const direkte &rhs) : index(rhs) {};
93  direkte(const ibis::column* c, const char* f = 0);
94  direkte(const ibis::column* c, ibis::fileManager::storage* st);
95  direkte(const ibis::column* c, uint32_t popu, uint32_t ntpl=0);
96  direkte(const ibis::column* c, uint32_t card, array_t<uint32_t>& ints);
97 
98 protected:
99  template <typename T>
100  int construct(const char* f);
101  template <typename T>
102  int construct0(const char* f);
103 
104  void locate(const ibis::qContinuousRange& expr,
105  uint32_t& hit0, uint32_t& hit1) const;
106  virtual size_t getSerialSize() const throw();
107 
108  direkte();
109  direkte& operator=(const direkte&);
110 }; // ibis::direkte
111 
112 #endif
virtual double getSum() const
Compute the approximate sum of all the values indexed.
Definition: idirekte.cpp:1757
virtual size_t getSerialSize() const
Estimate the size of the index file.
Definition: idirekte.cpp:1816
void ints(array_t< uint32_t > &) const
Convert the bitvector into integer values.
Definition: idirekte.cpp:1016
size_t size() const
Definition: array_t.h:69
Definition of the common functions of an index.
virtual int write(ibis::array_t< double > &, ibis::array_t< int64_t > &, ibis::array_t< uint32_t > &) const
Save index to three arrays. Serialize the index in memory.
Definition: idirekte.cpp:786
Simple range condition.
Definition: qExpr.h:252
The storage class treats all memory as char*.
Definition: fileManager.h:237
array_t< ibis::bitvector * > bits
A list of bitvectors.
Definition: index.h:414
virtual void estimate(const ibis::qContinuousRange &, ibis::bitvector &lower, ibis::bitvector &upper) const
Computes an approximation of hits as a pair of lower and upper bounds.
Definition: index.h:191
The class to represent a column of a data partition.
Definition: column.h:65
virtual long evaluate(const ibis::qContinuousRange &expr, ibis::bitvector &hits) const =0
To evaluate the exact hits.
virtual long evaluate(const ibis::qContinuousRange &expr, ibis::bitvector &hits) const
To evaluate the exact hits.
Definition: idirekte.cpp:1356
virtual long getDistribution(std::vector< double > &bbs, std::vector< uint32_t > &cts) const
Binned distribution of the data.
Definition: idirekte.cpp:1800
virtual long select(const ibis::qContinuousRange &, void *) const
Evaluate the range condition and select values.
Definition: idirekte.h:51
virtual long select(const ibis::qContinuousRange &, void *, ibis::bitvector &) const
Evaluate the range condition, select values, and record the positions.
Definition: idirekte.h:53
virtual double estimateCost(const ibis::qContinuousRange &expr) const
Estimate the cost of evaluating a range condition.
Definition: idirekte.cpp:1432
The base index class.
Definition: index.h:82
virtual long getCumulativeDistribution(std::vector< double > &bds, std::vector< uint32_t > &cts) const
Cumulative distribution of the data.
Definition: idirekte.cpp:1785
virtual void clear()
Clear the existing content.
Definition: index.cpp:1313
virtual INDEX_TYPE type() const
Returns an index type identifier.
Definition: idirekte.h:19
INDEX_TYPE
The integer values of this enum type are used in the index files to differentiate the indexes...
Definition: index.h:86
virtual index * dup() const
Duplicate the content of an index object.
Definition: idirekte.cpp:198
virtual void speedTest(std::ostream &out) const
Time some logical operations and print out their speed.
Definition: idirekte.h:77
virtual void print(std::ostream &out) const
The printing function.
Definition: idirekte.cpp:581
virtual void estimate(const ibis::qContinuousRange &expr, ibis::bitvector &lower, ibis::bitvector &upper) const
Computes an approximation of hits as a pair of lower and upper bounds.
Definition: idirekte.cpp:1364
virtual void serialSizes(uint64_t &, uint64_t &, uint64_t &) const
Compute the size of arrays that would be generated by the serializatioin function (write)...
Definition: idirekte.cpp:812
virtual double getMax() const
The maximum value recorded in the index.
Definition: idirekte.h:83
int remapKeys(const ibis::array_t< uint32_t > &)
Change the key values to a new set of numbers.
Definition: idirekte.cpp:958
virtual int read(const char *name)
Read index from the specified location.
Definition: idirekte.cpp:833
virtual const char * name() const
Returns the name of the index, similar to the function type, but returns a string instead...
Definition: idirekte.h:20
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
virtual void binBoundaries(std::vector< double > &) const
The function binBoundaries and binWeights return bin boundaries and counts of each bin respectively...
Definition: idirekte.cpp:1767
index(const ibis::column *c=0)
Default constructor.
Definition: index.h:423
virtual long append(const char *dt, const char *df, uint32_t nnew)
Append the index in df to the one in dt.
Definition: idirekte.cpp:1498
array_t< uint32_t > * keys(const ibis::bitvector &mask) const
Convert the bitvector mask into key values.
Definition: idirekte.cpp:1049
void clear()
Remove the existing content of a bitvector.
Definition: bitvector.cpp:243
A discrete range expression.
Definition: qExpr.h:337
A version of precise index that directly uses the integer values.
Definition: idirekte.h:17
ibis::direkte, hash value to bitmaps.
Definition: index.h:136
virtual double getMin() const
The minimum value recorded in the index.
Definition: idirekte.h:82
virtual float undecidable(const ibis::qContinuousRange &expr, ibis::bitvector &iffy) const
Mark the position of the rows that can not be decided with this index.
Definition: idirekte.h:30

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