Remove duplicated rows from the given batch, keeping a state between batches. We use a hash table to allocate new group ids for the new rows. [`GroupValues`] allocate increasing group ids. Hence, if groups (i.e., rows) are new, then they have ids >= length before interning, we keep them. We also detect duplicates by enforcing that group ids are increasing.
(&mut self, batch: &RecordBatch)
| 479 | /// Hence, if groups (i.e., rows) are new, then they have ids >= length before interning, we keep them. |
| 480 | /// We also detect duplicates by enforcing that group ids are increasing. |
| 481 | fn deduplicate(&mut self, batch: &RecordBatch) -> Result<RecordBatch> { |
| 482 | let size_before = self.group_values.len(); |
| 483 | self.intern_output_buffer.reserve(batch.num_rows()); |
| 484 | self.group_values |
| 485 | .intern(batch.columns(), &mut self.intern_output_buffer)?; |
| 486 | let mask = new_groups_mask(&self.intern_output_buffer, size_before); |
| 487 | self.intern_output_buffer.clear(); |
| 488 | // We update the reservation to reflect the new size of the hash table. |
| 489 | self.reservation.try_resize(self.group_values.size())?; |
| 490 | Ok(filter_record_batch(batch, &mask)?) |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | /// Return a mask, each element being true if, and only if, the element is greater than all previous elements and greater or equal than the provided max_already_seen_group_id |
no test coverage detected