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

Function make_list_array

arrow/tests/array_cast.rs:379–400  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

377}
378
379fn make_list_array() -> ListArray {
380 // Construct a value array
381 let value_data = ArrayData::builder(DataType::Int32)
382 .len(8)
383 .add_buffer(Buffer::from_slice_ref([0, 1, 2, 3, 4, 5, 6, 7]))
384 .build()
385 .unwrap();
386
387 // Construct a buffer for value offsets, for the nested array:
388 // [[0, 1, 2], [3, 4, 5], [6, 7]]
389 let value_offsets = Buffer::from_slice_ref([0, 3, 6, 8]);
390
391 // Construct a list array from the above two
392 let list_data_type = DataType::List(Arc::new(Field::new_list_field(DataType::Int32, true)));
393 let list_data = ArrayData::builder(list_data_type)
394 .len(3)
395 .add_buffer(value_offsets)
396 .add_child_data(value_data)
397 .build()
398 .unwrap();
399 ListArray::from(list_data)
400}
401
402fn make_large_list_array() -> LargeListArray {
403 // Construct a value array

Callers

nothing calls this directly

Calls 5

add_bufferMethod · 0.80
add_child_dataMethod · 0.80
ListClass · 0.50
buildMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected