MCPcopy Create free account
hub / github.com/apache/datafusion / count

Method count

datafusion/functions-aggregate/src/hyperloglog.rs:147–157  ·  view source on GitHub ↗

Guess the number of unique elements seen by the HyperLogLog.

(&self)

Source from the content-addressed store, hash-verified

145
146 /// Guess the number of unique elements seen by the HyperLogLog.
147 pub fn count(&self) -> usize {
148 let histogram = self.get_histogram();
149 let m = NUM_REGISTERS as f64;
150 let mut z = m * hll_tau((m - histogram[HLL_Q + 1] as f64) / m);
151 for i in histogram[1..=HLL_Q].iter().rev() {
152 z += *i as f64;
153 z *= 0.5;
154 }
155 z += m * hll_sigma(histogram[0] as f64 / m);
156 (0.5 / 2_f64.ln() * m * m / z).round() as usize
157 }
158}
159
160/// Helper function sigma as defined in

Callers 15

filter_list_valuesFunction · 0.45
array_dataFunction · 0.45
gen_args_arrayFunction · 0.45
random_substringFunction · 0.45
overlay_oneFunction · 0.45
test_functionsFunction · 0.45
test_functionsFunction · 0.45
character_length_generalFunction · 0.45
byte_offset_to_char_posFunction · 0.45
leading_bytesFunction · 0.45
trailing_bytesFunction · 0.45
count_matchesFunction · 0.45

Calls 4

hll_tauFunction · 0.85
hll_sigmaFunction · 0.85
get_histogramMethod · 0.80
iterMethod · 0.45

Tested by 6

test_functionsFunction · 0.36
test_functionsFunction · 0.36
test_u8Function · 0.36
test_stringFunction · 0.36
test_merge_overlappedFunction · 0.36
test_repetitionFunction · 0.36