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

Method finish_helper

arrow-array/src/builder/map_builder.rs:229–280  ·  view source on GitHub ↗
(
        &self,
        keys_arr: Arc<dyn Array>,
        values_arr: Arc<dyn Array>,
        offset_buffer: Buffer,
        nulls: Option<NullBuffer>,
        len: usize,
    )

Source from the content-addressed store, hash-verified

227 }
228
229 fn finish_helper(
230 &self,
231 keys_arr: Arc<dyn Array>,
232 values_arr: Arc<dyn Array>,
233 offset_buffer: Buffer,
234 nulls: Option<NullBuffer>,
235 len: usize,
236 ) -> MapArray {
237 assert!(
238 keys_arr.null_count() == 0,
239 "Keys array must have no null values, found {} null value(s)",
240 keys_arr.null_count()
241 );
242
243 let keys_field = match &self.key_field {
244 Some(f) => {
245 assert!(!f.is_nullable(), "Keys field must not be nullable");
246 f.clone()
247 }
248 None => Arc::new(Field::new(
249 self.field_names.key.as_str(),
250 keys_arr.data_type().clone(),
251 false, // always non-nullable
252 )),
253 };
254 let values_field = match &self.value_field {
255 Some(f) => f.clone(),
256 None => Arc::new(Field::new(
257 self.field_names.value.as_str(),
258 values_arr.data_type().clone(),
259 true,
260 )),
261 };
262
263 let struct_array =
264 StructArray::from(vec![(keys_field, keys_arr), (values_field, values_arr)]);
265
266 let map_field = Arc::new(Field::new(
267 self.field_names.entry.as_str(),
268 struct_array.data_type().clone(),
269 false, // always non-nullable
270 ));
271 let array_data = ArrayData::builder(DataType::Map(map_field, false)) // TODO: support sorted keys
272 .len(len)
273 .add_buffer(offset_buffer)
274 .add_child_data(struct_array.into_data())
275 .nulls(nulls);
276
277 let array_data = unsafe { array_data.build_unchecked() };
278
279 MapArray::from(array_data)
280 }
281
282 /// Returns the current null buffer as a slice
283 pub fn validity_slice(&self) -> Option<&[u8]> {

Callers 3

finishMethod · 0.80
finish_clonedMethod · 0.80

Calls 10

add_child_dataMethod · 0.80
add_bufferMethod · 0.80
MapClass · 0.50
cloneMethod · 0.45
as_strMethod · 0.45
data_typeMethod · 0.45
nullsMethod · 0.45
lenMethod · 0.45
into_dataMethod · 0.45
build_uncheckedMethod · 0.45

Tested by

no test coverage detected