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

Function approx_topk_basic

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

Source from the content-addressed store, hash-verified

650
651 #[test]
652 fn approx_topk_basic() {
653 let mut docs: Vec<Vec<u8>> = Vec::new();
654 for _ in 0..10 {
655 docs.push(encode(&json!({"cat": "a"})));
656 }
657 for _ in 0..5 {
658 docs.push(encode(&json!({"cat": "b"})));
659 }
660 for _ in 0..1 {
661 docs.push(encode(&json!({"cat": "c"})));
662 }
663 let refs: Vec<&[u8]> = docs.iter().map(|d| d.as_slice()).collect();
664 let result = compute_aggregate_binary("approx_topk", "3:cat", None, &refs);
665 if let Value::Array(arr) = result {
666 assert!(!arr.is_empty(), "should have top-k results");
667 } else {
668 panic!("expected Array, got {result:?}");
669 }
670 }
671}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected