Creates a new `UnionArray`. Accepts type ids, child arrays and optionally offsets (for dense unions) to create a new `UnionArray`. This method makes no attempt to validate the data provided by the caller and assumes that each of the components are correct and consistent with each other. See `try_new` for an alternative that validates the data provided. # Safety The `type_ids` values should be
(
fields: UnionFields,
type_ids: ScalarBuffer<i8>,
offsets: Option<ScalarBuffer<i32>>,
children: Vec<ArrayRef>,
)
| 147 | /// In both cases above we use signed integer types to maintain compatibility with other |
| 148 | /// Arrow implementations. |
| 149 | pub unsafe fn new_unchecked( |
| 150 | fields: UnionFields, |
| 151 | type_ids: ScalarBuffer<i8>, |
| 152 | offsets: Option<ScalarBuffer<i32>>, |
| 153 | children: Vec<ArrayRef>, |
| 154 | ) -> Self { |
| 155 | let mode = if offsets.is_some() { |
| 156 | UnionMode::Dense |
| 157 | } else { |
| 158 | UnionMode::Sparse |
| 159 | }; |
| 160 | |
| 161 | let len = type_ids.len(); |
| 162 | let builder = ArrayData::builder(DataType::Union(fields, mode)) |
| 163 | .add_buffer(type_ids.into_inner()) |
| 164 | .child_data(children.into_iter().map(Array::into_data).collect()) |
| 165 | .len(len); |
| 166 | |
| 167 | let data = match offsets { |
| 168 | Some(offsets) => unsafe { builder.add_buffer(offsets.into_inner()).build_unchecked() }, |
| 169 | None => unsafe { builder.build_unchecked() }, |
| 170 | }; |
| 171 | Self::from(data) |
| 172 | } |
| 173 | |
| 174 | /// Attempts to create a new `UnionArray`, validating the inputs provided. |
| 175 | /// |
nothing calls this directly
no test coverage detected