pepijnve commented on code in PR #10161:
URL: https://github.com/apache/arrow-rs/pull/10161#discussion_r3450771163


##########
arrow-string/src/concat_elements.rs:
##########
@@ -221,6 +221,170 @@ pub fn concat_elements_fixed_size_binary(
     Ok(result.finish())
 }
 
+struct ConcatByteViewBuilder<T>
+where
+    T: ByteViewType,
+{
+    views: Vec<u128>,
+    data: Vec<u8>,
+    inline: Vec<u8>,
+    phantom: PhantomData<T>,
+}
+
+impl<T> ConcatByteViewBuilder<T>
+where
+    T: ByteViewType,
+{
+    /// Returns the elementwise concatenation of two [`GenericByteViewArray`]s.
+    fn concat_elements_view_array(
+        left: &GenericByteViewArray<T>,
+        right: &GenericByteViewArray<T>,
+    ) -> Result<GenericByteViewArray<T>, ArrowError> {
+        let len = left.len();
+        if len != right.len() {
+            return Err(ArrowError::ComputeError(format!(
+                "Arrays must have the same length: {} != {}",
+                len,
+                right.len()
+            )));
+        }
+
+        let mut null_buffer = NullBuffer::union(left.nulls(), right.nulls());
+        if let Some(n) = &null_buffer {
+            if n.null_count() == 0 {
+                null_buffer = None
+            }
+        }
+
+        match null_buffer {
+            None => {
+                let data_size = left
+                    .lengths()
+                    .zip(right.lengths())
+                    .map(|(l, r)| l + r)
+                    .filter(|len| *len > MAX_INLINE_VIEW_LEN)
+                    .map(|len| len as usize)
+                    .sum();
+
+                if data_size > u32::MAX as usize {

Review Comment:
   Indeed, https://github.com/apache/arrow-rs/issues/6172 has the relevant spec 
citation for view:
   
   > All integers (length, buffer index, and offset) are signed.
   
   So we should indeed limit to `i32::MAX`.



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