MCPcopy Create free account
hub / github.com/apache/arrow-rs / interleave_bytes

Function interleave_bytes

arrow-select/src/interleave.rs:216–246  ·  view source on GitHub ↗
(
    values: &[&dyn Array],
    indices: &[(usize, usize)],
)

Source from the content-addressed store, hash-verified

214}
215
216fn interleave_bytes<T: ByteArrayType>(
217 values: &[&dyn Array],
218 indices: &[(usize, usize)],
219) -> Result<ArrayRef, ArrowError> {
220 let interleaved = Interleave::<'_, GenericByteArray<T>>::new(values, indices);
221
222 let mut capacity = 0;
223 let mut offsets = Vec::with_capacity(indices.len() + 1);
224 offsets.push(T::Offset::from_usize(0).unwrap());
225 for (a, b) in indices {
226 let o = interleaved.arrays[*a].value_offsets();
227 let element_len = o[*b + 1].as_usize() - o[*b].as_usize();
228 capacity += element_len;
229 offsets.push(
230 T::Offset::from_usize(capacity)
231 .ok_or_else(|| ArrowError::OffsetOverflowError(capacity))?,
232 );
233 }
234
235 let mut values = Vec::with_capacity(capacity);
236 for (a, b) in indices {
237 values.extend_from_slice(interleaved.arrays[*a].value(*b).as_ref());
238 }
239
240 // Safety: safe by construction
241 let array = unsafe {
242 let offsets = OffsetBuffer::new_unchecked(offsets.into());
243 GenericByteArray::<T>::new_unchecked(offsets, values.into(), interleaved.nulls)
244 };
245 Ok(Arc::new(array))
246}
247
248fn interleave_dictionaries<K: ArrowDictionaryKeyType>(
249 arrays: &[&dyn Array],

Callers

nothing calls this directly

Calls 7

as_usizeMethod · 0.80
extend_from_sliceMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45
value_offsetsMethod · 0.45
as_refMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected