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

Method from

arrow-array/src/array/run_array.rs:358–397  ·  view source on GitHub ↗

The method assumes the caller already validated the data using `ArrayData::validate_data()`

(data: ArrayData)

Source from the content-addressed store, hash-verified

356impl<R: RunEndIndexType> From<ArrayData> for RunArray<R> {
357 // The method assumes the caller already validated the data using `ArrayData::validate_data()`
358 fn from(data: ArrayData) -> Self {
359 let (data_type, len, _nulls, offset, _buffers, child_data) = data.into_parts();
360
361 match &data_type {
362 DataType::RunEndEncoded(_, _) => {}
363 _ => {
364 panic!(
365 "Invalid data type {data_type:?} for RunArray. Should be DataType::RunEndEncoded"
366 );
367 }
368 }
369
370 let [run_end_child, values_child]: [ArrayData; 2] = child_data
371 .try_into()
372 .expect("RunArray data should have exactly two child arrays");
373
374 // deconstruct the run ends child array
375 let (
376 run_end_data_type,
377 _run_end_len,
378 _run_end_nulls,
379 _run_end_offset,
380 run_end_buffers,
381 _run_end_child_data,
382 ) = run_end_child.into_parts();
383 assert_eq!(run_end_data_type, R::DATA_TYPE, "Incorrect run ends type");
384 let [run_end_buffer]: [arrow_buffer::Buffer; 1] = run_end_buffers
385 .try_into()
386 .expect("Run ends should have exactly one buffer");
387 let scalar = ScalarBuffer::from(run_end_buffer);
388 let run_ends = unsafe { RunEndBuffer::new_unchecked(scalar, offset, len) };
389
390 let values = make_array(values_child);
391
392 Self {
393 data_type,
394 run_ends,
395 values,
396 }
397 }
398}
399
400impl<R: RunEndIndexType> From<RunArray<R>> for ArrayData {

Callers

nothing calls this directly

Calls 8

child_dataMethod · 0.80
make_arrayFunction · 0.70
into_partsMethod · 0.45
lenMethod · 0.45
offsetMethod · 0.45
buffersMethod · 0.45
valuesMethod · 0.45
build_uncheckedMethod · 0.45

Tested by

no test coverage detected