-
Notifications
You must be signed in to change notification settings - Fork 15
/
randhhh1D.h
48 lines (34 loc) · 1.12 KB
/
randhhh1D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Implementation of the 1-dimensional Randomized Hierarchical Heavy Hitters algorithm (RHHH) for IP addresses
-Ran Ben Basat (sran@cs.technion.ac.il) 2017-05-25
-Based on the "Hierarchical Heavy Hitters with the Space Saving Algorithm" paper implementation by Thomas Steinke -- http://people.seas.harvard.edu/~tsteinke/hhh/
*/
#ifndef RANDHHH1D_H
#define RANDHHH1D_H
#include "ulossycount.h"
#ifndef SEED
#define SEED 3421
#endif
//#define FASTRAND 1
#ifndef NUM_MASKS
#define NUM_MASKS 5
#endif
#define NUM_COUNTERS NUM_MASKS
//The masks associated with the counters
//Note that we must ensure that they are in increasing order of generality
extern LCLitem_t masks[NUM_COUNTERS];
extern int leveleps[NUM_COUNTERS];
//initialise
void init(double SSepsilon, double prob);
//deinitialise
void deinit();
void update(LCLitem_t item, int count);
//struct to store a heavy hitter output
typedef struct heavyhitter {
LCLitem_t item;
int mask; //The item & mask
int upper, lower; //Upper and lower count bounds
} HeavyHitter;
//the one-dimensional output
HeavyHitter * output(int threshold, int * numhitters, int streamLen);
#endif