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

Function approx_percentile_basic

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

Source from the content-addressed store, hash-verified

635
636 #[test]
637 fn approx_percentile_basic() {
638 let docs: Vec<Vec<u8>> = (1..=100).map(|i| encode(&json!({"val": i}))).collect();
639 let refs: Vec<&[u8]> = docs.iter().map(|d| d.as_slice()).collect();
640 let result = compute_aggregate_binary("approx_percentile", "0.5:val", None, &refs);
641 if let Value::Float(f) = result {
642 assert!(
643 (f - 50.0).abs() < 10.0,
644 "p50 of 1..100 should be ~50, got {f}"
645 );
646 } else {
647 panic!("expected Float, got {result:?}");
648 }
649 }
650
651 #[test]
652 fn approx_topk_basic() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected