@@ -28,7 +28,6 @@ enum SampleSketchRet {
2828 */
2929class Sketch {
3030 private:
31- static vec_t failure_factor; // Pr(failure) = 1 / factor. Determines number of columns in sketch.
3231 static vec_t n; // Length of the vector this is sketching.
3332 static size_t num_elems; // length of our actual arrays in number of elements
3433 static size_t num_columns; // Portion of array length, number of columns
@@ -49,7 +48,7 @@ class Sketch {
4948 FRIEND_TEST (EXPR_Parallelism, N10kU100k);
5049
5150 // Buckets of this sketch.
52- // Length is column_gen(failure_factor) * guess_gen(n).
51+ // Length is num_columns * guess_gen(n).
5352 // For buckets[i * guess_gen(n) + j], the bucket has a 1/2^j probability
5453 // of containing an index. The first two are pointers into the buckets array.
5554 alignas (vec_t ) char buckets[];
@@ -83,13 +82,12 @@ class Sketch {
8382
8483 /* configure the static variables of sketches
8584 * @param n Length of the vector to sketch. (static variable)
86- * @param failure_factor 1/factor = Failure rate for sketch ( determines column width)
85+ * @param num_columns Column width, determines the failure probability of the sketch
8786 * @return nothing
8887 */
89- inline static void configure (vec_t _n, vec_t _factor ) {
88+ inline static void configure (vec_t _n, vec_t _num_columns ) {
9089 n = _n;
91- failure_factor = _factor;
92- num_columns = column_gen (failure_factor);
90+ num_columns = _num_columns;
9391 num_guesses = guess_gen (n);
9492 num_elems = num_columns * num_guesses + 1 ; // +1 for zero bucket optimization
9593 }
@@ -103,8 +101,6 @@ class Sketch {
103101 return num_elems * (sizeof (vec_t ) + sizeof (vec_hash_t ));
104102 }
105103
106- inline static vec_t get_failure_factor () { return failure_factor; }
107-
108104 inline void reset_queried () { already_queried = false ; }
109105
110106 inline static size_t get_columns () { return num_columns; }
@@ -168,7 +164,7 @@ class Sketch {
168164
169165 // max number of non-zeroes in vector is n/2*n/2=n^2/4
170166 static size_t guess_gen (size_t x) { return double_to_ull (log2 (x) - 2 ); }
171- static size_t column_gen (size_t d) { return double_to_ull ((log2 (d) + 1 )); }
167+ static size_t column_gen (size_t d) { return double_to_ull (ceil (log2 (d))); }
172168};
173169
174170class MultipleQueryException : public std ::exception {
0 commit comments