MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_streaming_topk_basic

Function test_streaming_topk_basic

graphlite/src/exec/streaming_topk.rs:288–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

286
287 #[test]
288 fn test_streaming_topk_basic() {
289 let mut topk = StreamingTopK::new(3);
290
291 // Add rows with different scores
292 topk.add(create_test_row(1, 10.0), 10.0);
293 topk.add(create_test_row(2, 20.0), 20.0);
294 topk.add(create_test_row(3, 5.0), 5.0);
295 topk.add(create_test_row(4, 15.0), 15.0);
296
297 let results = topk.into_results();
298
299 assert_eq!(results.len(), 3);
300
301 // Should keep top 3: 20.0, 15.0, 10.0
302 let scores: Vec<f64> = results
303 .iter()
304 .map(|r| r.get_text_score().unwrap())
305 .collect();
306
307 assert_eq!(scores[0], 20.0);
308 assert_eq!(scores[1], 15.0);
309 assert_eq!(scores[2], 10.0);
310 }
311
312 #[test]
313 fn test_streaming_topk_with_many_rows() {

Callers

nothing calls this directly

Calls 6

into_resultsMethod · 0.80
unwrapMethod · 0.80
get_text_scoreMethod · 0.80
create_test_rowFunction · 0.70
addMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected