()
| 351 | |
| 352 | #[test] |
| 353 | fn test_streaming_topk_stats() { |
| 354 | let mut topk = StreamingTopK::new(5); |
| 355 | |
| 356 | for i in 0..20 { |
| 357 | topk.add(create_test_row(i, i as f64), i as f64); |
| 358 | } |
| 359 | |
| 360 | let stats = topk.stats(); |
| 361 | |
| 362 | assert_eq!(stats.processed_count, 20); |
| 363 | assert_eq!(stats.kept_count, 5); |
| 364 | assert_eq!(stats.k, 5); |
| 365 | |
| 366 | // Memory savings: kept 5 out of 20 = 25% |
| 367 | assert!((stats.memory_savings_ratio() - 0.25).abs() < 0.01); |
| 368 | |
| 369 | // Discard ratio: discarded 15 out of 20 = 75% |
| 370 | assert!((stats.discard_ratio() - 0.75).abs() < 0.01); |
| 371 | } |
| 372 | |
| 373 | #[test] |
| 374 | fn test_streaming_topk_empty() { |
nothing calls this directly
no test coverage detected