MCPcopy Create free account
hub / github.com/apache/datafusion / deduplicate

Method deduplicate

datafusion/physical-plan/src/recursive_query.rs:481–491  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

push_batchMethod · 0.80

Calls 9

new_groups_maskFunction · 0.85
filter_record_batchFunction · 0.85
reserveMethod · 0.80
columnsMethod · 0.80
try_resizeMethod · 0.80
lenMethod · 0.45
internMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected