MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / approx_count_distinct_basic

Function approx_count_distinct_basic

nodedb-query/src/msgpack_scan/aggregate.rs:619–634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

617
618 #[test]
619 fn approx_count_distinct_basic() {
620 let docs: Vec<Vec<u8>> = vec![
621 encode(&json!({"region": "us"})),
622 encode(&json!({"region": "eu"})),
623 encode(&json!({"region": "us"})),
624 encode(&json!({"region": "ap"})),
625 ];
626 let refs: Vec<&[u8]> = docs.iter().map(|d| d.as_slice()).collect();
627 let result = compute_aggregate_binary("approx_count_distinct", "region", None, &refs);
628 // HLL may not be exactly 3 but should be close.
629 if let Value::Integer(n) = result {
630 assert!((2..=4).contains(&n), "expected ~3 distinct, got {n}");
631 } else {
632 panic!("expected Integer, got {result:?}");
633 }
634 }
635
636 #[test]
637 fn approx_percentile_basic() {

Callers

nothing calls this directly

Calls 4

compute_aggregate_binaryFunction · 0.85
collectMethod · 0.80
iterMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected