alamb commented on code in PR #12223:
URL: https://github.com/apache/arrow-rs/pull/12223#discussion_r4652348235


##########
arrow-select/src/coalesce/byte.rs:
##########
@@ -63,6 +69,48 @@ where
         }
     }
 
+    /// Reuses a byte array as a builder with bounded capacity; errors if 
offsets or values cannot be reused.
+    #[inline(never)]
+    fn into_builder_with_capacity(

Review Comment:
   This is inconsistent with other APIs, which do it more like
   
   ```rust
       pub fn into_builder(self) -> Result<GenericByteBuilder<T>, Self> {
   ```
   
   (aka don't return errors but return Self if the buffers are shared)
   
   
https://github.com/apache/arrow-rs/blob/4ea4d225e4312f968e8cc9ab3922aa460ac377e6/arrow-array/src/array/byte_array.rs#L381



##########
arrow-select/src/coalesce.rs:
##########
@@ -428,12 +442,13 @@ impl BatchCoalescer {
         }
 
         // Direct indexed copying is a fast path for non-null UInt32 selections
-        // that are sparse enough for every column (with a stricter ByteView
+        // that are sparse or use only primitive and byte-array columns (with 
a stricter ByteView
         // threshold). It is only equivalent to `push_batch(take(...))` when 
the
         // materialized batch would not trigger the configured large-batch 
bypass.
         let exceeds_byte_view_threshold = self.has_byte_view_columns
             && !should_use_byte_view_indexed_copy(batch.num_rows(), 
indices.len());
-        let indexed_copy_allowed = should_use_indexed_copy(batch.num_rows(), 
indices.len())
+        let indexed_copy_allowed = (should_use_indexed_copy(batch.num_rows(), 
indices.len())
+            || self.supports_dense_indexed_copy)

Review Comment:
   I wonder if it would be better to check the flag first 
supports_dense_indexed_copy and save a function call



##########
arrow-select/src/coalesce.rs:
##########
@@ -251,6 +253,17 @@ impl BatchCoalescer {
                 DataType::Utf8 | DataType::LargeUtf8 | DataType::Binary | 
DataType::LargeBinary
             )
         });
+        let supports_dense_indexed_copy = has_byte_array_columns

Review Comment:
   if this is checking some property of the in progress arrays, I think it 
should be a method on those implementations so the definitions stay in the same 
spot
   
   something like this perhaps
   
   ```rust
           let supports_dense_indexed_copy = self.arrays.iter().all(|arr| 
arr.supports_desnse_index()))
   ```



-- 
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]

Reply via email to