MCPcopy Create free account
hub / github.com/apache/cloudberry / initHyperLogLogError

Function initHyperLogLogError

src/backend/lib/hyperloglog.c:127–142  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

125 * is between ~25% (bwidth=4) and 0.4% (bwidth=16).
126 */
127void
128initHyperLogLogError(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

Callers

nothing calls this directly

Calls 1

initHyperLogLogFunction · 0.85

Tested by

no test coverage detected