ROADMAP v0.5.0 - Add rows to top-K heap for streaming filtering
(&mut self, row: Row, score: f64)
| 141 | /// - Worst case: O(log K) for heap operations |
| 142 | #[allow(dead_code)] // ROADMAP v0.5.0 - Add rows to top-K heap for streaming filtering |
| 143 | pub fn add(&mut self, row: Row, score: f64) { |
| 144 | self.processed_count += 1; |
| 145 | |
| 146 | // If heap not full, always add |
| 147 | if self.heap.len() < self.k { |
| 148 | self.heap.push(ScoredRow { row, score }); |
| 149 | self.would_keep_count += 1; |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | // Heap is full - check if this score beats minimum |
| 154 | if let Some(min_item) = self.heap.peek() { |
| 155 | if score > min_item.score { |
| 156 | // This row is better than current minimum |
| 157 | self.heap.push(ScoredRow { row, score }); |
| 158 | self.heap.pop(); // Remove minimum |
| 159 | self.would_keep_count += 1; |
| 160 | } |
| 161 | // else: score <= min, discard this row |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /// Get the current minimum score in the heap |
| 166 | /// |