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

Method new_unchecked

arrow-array/src/array/union_array.rs:149–172  ·  view source on GitHub ↗

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>,
    )

Source from the content-addressed store, hash-verified

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 ///

Callers

nothing calls this directly

Calls 8

UnionClass · 0.85
child_dataMethod · 0.80
add_bufferMethod · 0.80
collectMethod · 0.80
lenMethod · 0.45
into_innerMethod · 0.45
into_iterMethod · 0.45
build_uncheckedMethod · 0.45

Tested by

no test coverage detected