kumarUjjawal commented on code in PR #23565:
URL: https://github.com/apache/datafusion/pull/23565#discussion_r3734842301


##########
datafusion/physical-plan/src/spill/mod.rs:
##########
@@ -420,6 +420,20 @@ pub(crate) fn gc_view_arrays(batch: &RecordBatch) -> 
Result<RecordBatch> {
     }
 }
 
+/// Garbage collect and deduplicate a string view before writing it out to disk
+///
+/// This is to avoid inflating disk usage and also to ensure that 
deduplication reduces memory pressure when reading back.
+fn gc_dedup_view<T: ByteViewType>(
+    array: &GenericByteViewArray<T>,
+) -> GenericByteViewArray<T> {
+    let mut builder = GenericByteViewBuilder::<T>::with_capacity(array.len())

Review Comment:
   Every qualifying Utf8View and BinaryView now allocates a hash table sized 
for all rows and hashes every non-inline value. This is valuable for repeated 
values, but  unique strings or large binary values get no disk reduction over 
gc() while paying extra CPU and peak memory during spilling.



##########
datafusion/physical-plan/src/spill/mod.rs:
##########
@@ -1345,7 +1359,7 @@ mod tests {
         let size_without_gc: usize = array_without_gc
             .data_buffers()
             .iter()
-            .map(|buffer| buffer.capacity())
+            .map(|buffer| buffer.len())

Review Comment:
   Keep coverage for both length and capacity.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to