* Initialize HyperLogLog track state, by error rate * * Instead of specifying bwidth (number of bits used for addressing the * register), this method allows sizing the counter for particular error * rate using a simple formula from the paper: * * e = 1.04 / sqrt(m) * * where 'm' is the number of registers, i.e. (2^bwidth). The method * finds the lowest bwidth with 'e' below the requested
| 125 | * is between ~25% (bwidth=4) and 0.4% (bwidth=16). |
| 126 | */ |
| 127 | void |
| 128 | initHyperLogLogError(hyperLogLogState *cState, double error) |
| 129 | { |
| 130 | uint8 bwidth = 4; |
| 131 | |
| 132 | while (bwidth < 16) |
| 133 | { |
| 134 | double m = (Size) 1 << bwidth; |
| 135 | |
| 136 | if (1.04 / sqrt(m) < error) |
| 137 | break; |
| 138 | bwidth++; |
| 139 | } |
| 140 | |
| 141 | initHyperLogLog(cState, bwidth); |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | * Free HyperLogLog track state |
nothing calls this directly
no test coverage detected