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

Function test_nested_list

parquet/src/arrow/array_reader/list_array.rs:289–379  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

287 }
288
289 fn test_nested_list<OffsetSize: OffsetSizeTrait>() {
290 // 3 lists, with first and third nullable
291 // [
292 // [
293 // [[1, null], null, [4], []],
294 // [],
295 // [[7]],
296 // [[]],
297 // [[1, 2, 3], [4, null, 6], null]
298 // ],
299 // null,
300 // [],
301 // [[[11]]]
302 // ]
303
304 let l3_item_type = ArrowType::Int32;
305 let l3_type = list_type::<OffsetSize>(l3_item_type, true);
306
307 let l2_item_type = l3_type.clone();
308 let l2_type = list_type::<OffsetSize>(l2_item_type, true);
309
310 let l1_item_type = l2_type.clone();
311 let l1_type = list_type::<OffsetSize>(l1_item_type, false);
312
313 let leaf = PrimitiveArray::<Int32Type>::from_iter(vec![
314 Some(1),
315 None,
316 Some(4),
317 Some(7),
318 Some(1),
319 Some(2),
320 Some(3),
321 Some(4),
322 None,
323 Some(6),
324 Some(11),
325 ]);
326
327 // [[1, null], null, [4], [], [7], [], [1, 2, 3], [4, null, 6], null, [11]]
328 let offsets = to_offsets::<OffsetSize>(vec![0, 2, 2, 3, 3, 4, 4, 7, 10, 10, 11]);
329 let l3 = ArrayDataBuilder::new(l3_type.clone())
330 .len(10)
331 .add_buffer(offsets)
332 .add_child_data(leaf.into_data())
333 .null_bit_buffer(Some(Buffer::from([0b11111101, 0b00000010])))
334 .build()
335 .unwrap();
336
337 // [[[1, null], null, [4], []], [], [[7]], [[]], [[1, 2, 3], [4, null, 6], null], [[11]]]
338 let offsets = to_offsets::<OffsetSize>(vec![0, 4, 4, 5, 6, 9, 10]);
339 let l2 = ArrayDataBuilder::new(l2_type.clone())
340 .len(6)
341 .add_buffer(offsets)
342 .add_child_data(l3)
343 .build()
344 .unwrap();
345
346 let offsets = to_offsets::<OffsetSize>(vec![0, 5, 5, 5, 6]);

Callers

nothing calls this directly

Calls 11

make_int32_page_readerFunction · 0.85
add_child_dataMethod · 0.80
add_bufferMethod · 0.80
from_iterFunction · 0.50
cloneMethod · 0.45
buildMethod · 0.45
null_bit_bufferMethod · 0.45
lenMethod · 0.45
into_dataMethod · 0.45
sliceMethod · 0.45
next_batchMethod · 0.45

Tested by

no test coverage detected