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

Method from_list

arrow-array/src/array/binary_array.rs:39–75  ·  view source on GitHub ↗
(v: GenericListArray<OffsetSize>)

Source from the content-addressed store, hash-verified

37 }
38
39 fn from_list(v: GenericListArray<OffsetSize>) -> Self {
40 let v = v.into_data();
41 assert_eq!(
42 v.child_data().len(),
43 1,
44 "BinaryArray can only be created from list array of u8 values \
45 (i.e. List<PrimitiveArray<u8>>)."
46 );
47 let child_data = &v.child_data()[0];
48
49 assert_eq!(
50 child_data.child_data().len(),
51 0,
52 "BinaryArray can only be created from list array of u8 values \
53 (i.e. List<PrimitiveArray<u8>>)."
54 );
55 assert_eq!(
56 child_data.data_type(),
57 &DataType::UInt8,
58 "BinaryArray can only be created from List<u8> arrays, mismatched data types."
59 );
60 assert_eq!(
61 child_data.null_count(),
62 0,
63 "The child array cannot contain null values."
64 );
65
66 let builder = ArrayData::builder(Self::DATA_TYPE)
67 .len(v.len())
68 .offset(v.offset())
69 .add_buffer(v.buffers()[0].clone())
70 .add_buffer(child_data.buffers()[0].slice(child_data.offset()))
71 .nulls(v.nulls().cloned());
72
73 let data = unsafe { builder.build_unchecked() };
74 Self::from(data)
75 }
76
77 /// Returns an iterator that returns the values of `array.value(i)` for an iterator with each element `i`
78 pub fn take_iter<'a>(

Callers

nothing calls this directly

Calls 10

child_dataMethod · 0.80
add_bufferMethod · 0.80
into_dataMethod · 0.45
nullsMethod · 0.45
offsetMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
buffersMethod · 0.45
sliceMethod · 0.45
build_uncheckedMethod · 0.45

Tested by

no test coverage detected