Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
histogram.hh
Go to the documentation of this file.
1 #ifndef __HISTOGRAM__
2 #define __HISTOGRAM__
3 
4 #include <iostream>
5 #include <ctime>
6 
7 #define MAX_UINT 4294967295
8 
9 // EM-KDE
10 #ifndef ALPHA
11 #define ALPHA 0.001
12 #endif
13 
14 #ifndef KERNELWIDTH
15 #define KERNELWIDTH 2 // number of bins affected by count_query() function: 1 + 2*KERNELWIDTH (except the boundary bins)
16 #endif
17 
18 using namespace std;
19 
20 class Histogram
21 {
22  private:
23  int numserver; // number of server
24  int numbin; // number of bin -> number of histogram bin
25  // int digit; // number of digits to represent the problem space
26  double* querycount; // the data access count to each
27  uint32_t* boundaries; // the index of end point of each node
28 
29  public:
30  Histogram(); // constructs an uninitialized object
31  Histogram (int numserver, int numbin); // number of bin and number of digits
32  ~Histogram();
33 
34  void initialize(); // partition the problem space equally to each bin
35  void init_count(); // initialize the all query counts to zero
36  unsigned get_boundary (int index);
37  void set_boundary (int index, unsigned int boundary);
38  double get_count (int index);
39  void set_count (int index, double count);
40  int get_index (unsigned query); // return the dedicated node index of query
41  int count_query (unsigned query);
42  void updateboundary();
43  uint32_t random_within_boundaries(unsigned int);
44 
45  void set_numbin (int num);
46  int get_numbin();
47 
48  void set_numserver (int num);
49  int get_numserver();
50 };
51 
52 #endif
Definition: histogram.hh:20