This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-12399-ddaedbb6476d9e7bea9817a75011915519b6d728
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git

commit fc5a8ee45af1537dcf94689f28f552ff601cc98b
Author: RIchard Baah <[email protected]>
AuthorDate: Tue Nov 24 23:54:42 2026 +0000

    refactor(coalesce): expose dense indexed copy support (#12399)
    
    # Which issue does this PR close?
    
    - Relates to #12223.
    
    # Rationale for this change
    
    Keep indexed-copy capabilities with their implementations, as suggested
    in [this review
    comment](https://github.com/apache/arrow-rs/pull/12223/changes#r4656794087).
    
    # What changes are included in this PR?
    
    Adds `supports_dense_indexed_copy` to `InProgressArray`, with `true` for
    implementations that specialize `copy_rows_by_indices`.
    
    # Are these changes tested?
    
    A table-driven unit test covers each in-progress array implementation.
    
    # Are there any significant user-facing changes?
    
    No.
---
 arrow-select/src/coalesce.rs            | 33 +++++++++++++++++++++++++++++++++
 arrow-select/src/coalesce/boolean.rs    |  4 ++++
 arrow-select/src/coalesce/byte_view.rs  |  4 ++++
 arrow-select/src/coalesce/dictionary.rs |  4 ++++
 arrow-select/src/coalesce/primitive.rs  |  4 ++++
 5 files changed, 49 insertions(+)

diff --git a/arrow-select/src/coalesce.rs b/arrow-select/src/coalesce.rs
index a5f8adb770..2aa80f6c00 100644
--- a/arrow-select/src/coalesce.rs
+++ b/arrow-select/src/coalesce.rs
@@ -1009,6 +1009,12 @@ fn check_filter_len(filter: &FilterPredicate, 
source_len: usize) -> Result<(), A
 ///
 /// [`StringViewArray`]: arrow_array::StringViewArray
 trait InProgressArray: std::fmt::Debug + Send + Sync {
+    /// Returns true if this implementation supports dense indexed copying.
+    #[cfg_attr(not(test), expect(dead_code))]
+    fn supports_dense_indexed_copy(&self) -> bool {
+        false
+    }
+
     /// Set the source array.
     ///
     /// Calls to [`Self::copy_rows`] will copy rows from this array into the
@@ -2073,6 +2079,33 @@ mod tests {
         assert!(!coalescer.has_non_specialized_filter_columns);
     }
 
+    #[test]
+    fn test_dense_indexed_copy_capability() {
+        let cases = [
+            (DataType::Int32, true),
+            (DataType::Utf8View, true),
+            (DataType::BinaryView, true),
+            (
+                DataType::Dictionary(Box::new(DataType::UInt8), 
Box::new(DataType::Utf8)),
+                true,
+            ),
+            (DataType::Boolean, true),
+            (DataType::Utf8, false),
+            (DataType::FixedSizeBinary(4), false),
+            (DataType::new_list(DataType::Int32, true), false),
+            (DataType::Null, false),
+        ];
+
+        for (data_type, expected) in cases {
+            let in_progress = create_in_progress_array(&data_type, 100);
+            assert_eq!(
+                in_progress.supports_dense_indexed_copy(),
+                expected,
+                "unexpected capability for {data_type}"
+            );
+        }
+    }
+
     fn sparse_filter_byte_array_input() -> (RecordBatch, BooleanArray) {
         let mut strings = vec![Some("padding"); 4096];
         strings[..4].copy_from_slice(&[Some("zero"), None, Some("two"), 
Some("three")]);
diff --git a/arrow-select/src/coalesce/boolean.rs 
b/arrow-select/src/coalesce/boolean.rs
index 87ce4f6ac4..4cd2fb690b 100644
--- a/arrow-select/src/coalesce/boolean.rs
+++ b/arrow-select/src/coalesce/boolean.rs
@@ -130,6 +130,10 @@ impl InProgressBooleanArray {
 }
 
 impl InProgressArray for InProgressBooleanArray {
+    fn supports_dense_indexed_copy(&self) -> bool {
+        true
+    }
+
     fn set_source(&mut self, source: Option<ArrayRef>) {
         self.source = source;
     }
diff --git a/arrow-select/src/coalesce/byte_view.rs 
b/arrow-select/src/coalesce/byte_view.rs
index 53984d97a9..eef329be5f 100644
--- a/arrow-select/src/coalesce/byte_view.rs
+++ b/arrow-select/src/coalesce/byte_view.rs
@@ -630,6 +630,10 @@ unsafe fn selected_non_inline_bytes(
 }
 
 impl<B: ByteViewType> InProgressArray for InProgressByteViewArray<B> {
+    fn supports_dense_indexed_copy(&self) -> bool {
+        true
+    }
+
     fn set_source(&mut self, source: Option<ArrayRef>) {
         // If used values from source, add only the size that was used
         self.completed_buffers_size += 
self.size_of_completed_buffers_from_current_source;
diff --git a/arrow-select/src/coalesce/dictionary.rs 
b/arrow-select/src/coalesce/dictionary.rs
index ad62a293eb..0c369ca3d8 100644
--- a/arrow-select/src/coalesce/dictionary.rs
+++ b/arrow-select/src/coalesce/dictionary.rs
@@ -184,6 +184,10 @@ impl<K: ArrowDictionaryKeyType> 
InProgressDictionaryArray<K> {
 }
 
 impl<K: ArrowDictionaryKeyType> InProgressArray for 
InProgressDictionaryArray<K> {
+    fn supports_dense_indexed_copy(&self) -> bool {
+        true
+    }
+
     fn set_source(&mut self, source: Option<ArrayRef>) {
         self.source = source;
     }
diff --git a/arrow-select/src/coalesce/primitive.rs 
b/arrow-select/src/coalesce/primitive.rs
index 38d84f4659..28150e4c0f 100644
--- a/arrow-select/src/coalesce/primitive.rs
+++ b/arrow-select/src/coalesce/primitive.rs
@@ -147,6 +147,10 @@ fn append_filtered_nulls(
 }
 
 impl<T: ArrowPrimitiveType + Debug> InProgressArray for 
InProgressPrimitiveArray<T> {
+    fn supports_dense_indexed_copy(&self) -> bool {
+        true
+    }
+
     fn set_source(&mut self, source: Option<ArrayRef>) {
         self.source = source;
     }

Reply via email to