(v: GenericListArray<OffsetSize>)
| 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>( |
nothing calls this directly
no test coverage detected