54#define POW_2_32 (4294967296.0)
55#define NEG_POW_2_32 (-4294967296.0)
70 if (bwidth < 4 || bwidth > 16)
71 elog(
ERROR,
"bit width must be between 4 and 16 inclusive");
101 alpha = 0.7213 / (1.0 + 1.079 / cState->
nRegisters);
134 double m = (
Size) 1 << bwidth;
136 if (1.04 / sqrt(m) <
error)
198 result = cState->
alphaMM / sum;
200 if (result <= (5.0 / 2.0) * cState->
nRegisters)
215 else if (result > (1.0 / 30.0) *
POW_2_32)
Assert(PointerIsAligned(start, uint64))
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
void initHyperLogLogError(hyperLogLogState *cState, double error)
static uint8 rho(uint32 x, uint8 b)
double estimateHyperLogLog(hyperLogLogState *cState)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
void freeHyperLogLog(hyperLogLogState *cState)
void pfree(void *pointer)
void * palloc0(Size size)
static int pg_leftmost_one_pos32(uint32 word)
static unsigned hash(unsigned *uv, int n)