tustvold commented on code in PR #3546: URL: https://github.com/apache/arrow-rs/pull/3546#discussion_r1073407198
########## arrow-select/src/concat.rs: ########## @@ -30,24 +30,27 @@ //! assert_eq!(arr.len(), 3); //! ``` +use arrow_array::types::*; use arrow_array::*; +use arrow_buffer::ArrowNativeType; use arrow_data::transform::{Capacities, MutableArrayData}; -use arrow_data::ArrayData; use arrow_schema::{ArrowError, DataType, SchemaRef}; -fn compute_str_values_length<Offset: OffsetSizeTrait>(arrays: &[&ArrayData]) -> usize { - arrays - .iter() - .map(|&data| { - // get the length of the value buffer - let buf_len = data.buffers()[1].len(); - // find the offset of the buffer - // this returns a slice of offsets, starting from the offset of the array - // so we can take the first value - let offset = data.buffer::<Offset>(0)[0]; - buf_len - offset.to_usize().unwrap() - }) - .sum() +fn binary_capacity<T: ByteArrayType>(arrays: &[&dyn Array]) -> Capacities { + let mut item_capacity = 0; + let mut bytes_capacity = 0; + for array in arrays { + let a = array + .as_any() + .downcast_ref::<GenericByteArray<T>>() + .unwrap(); + + let offsets = a.value_offsets(); + bytes_capacity += offsets[offsets.len() - 1].as_usize() - offsets[0].as_usize(); Review Comment: No, because this is guaranteed by the GenericByteArray -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org