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

Method from

arrow-array/src/array/byte_array.rs:552–582  ·  view source on GitHub ↗
(data: ArrayData)

Source from the content-addressed store, hash-verified

550
551impl<T: ByteArrayType> From<ArrayData> for GenericByteArray<T> {
552 fn from(data: ArrayData) -> Self {
553 let (data_type, len, nulls, offset, mut buffers, _child_data) = data.into_parts();
554 assert_eq!(
555 data_type,
556 Self::DATA_TYPE,
557 "{}{}Array expects DataType::{}",
558 T::Offset::PREFIX,
559 T::PREFIX,
560 Self::DATA_TYPE
561 );
562 assert_eq!(
563 buffers.len(),
564 2,
565 "{}{}Array data should contain 2 buffers only (offsets and values)",
566 T::Offset::PREFIX,
567 T::PREFIX,
568 );
569 // buffers are offset then value, so pop in reverse
570 let value_data = buffers.pop().expect("checked above");
571 let offset_buffer = buffers.pop().expect("checked above");
572
573 // SAFETY:
574 // ArrayData is valid, and verified type above
575 let value_offsets = unsafe { get_offsets_from_buffer(offset_buffer, offset, len) };
576 Self {
577 value_offsets,
578 value_data,
579 data_type,
580 nulls,
581 }
582 }
583}
584
585impl<T: ByteArrayType> From<GenericByteArray<T>> for ArrayData {

Callers

nothing calls this directly

Calls 7

get_offsets_from_bufferFunction · 0.85
into_partsMethod · 0.45
lenMethod · 0.45
into_innerMethod · 0.45
nullsMethod · 0.45
buffersMethod · 0.45
build_uncheckedMethod · 0.45

Tested by

no test coverage detected