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

Function test_nested_array_decoding

arrow-avro/src/reader/record.rs:3432–3458  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3430
3431 #[test]
3432 fn test_nested_array_decoding() {
3433 let inner_ty = avro_from_codec(Codec::List(Arc::new(avro_from_codec(Codec::Int32))));
3434 let nested_ty = avro_from_codec(Codec::List(Arc::new(inner_ty.clone())));
3435 let mut decoder = Decoder::try_new(&nested_ty).unwrap();
3436 let mut buf = Vec::new();
3437 buf.extend(encode_avro_long(1));
3438 buf.extend(encode_avro_long(2));
3439 buf.extend(encode_avro_int(5));
3440 buf.extend(encode_avro_int(6));
3441 buf.extend(encode_avro_long(0));
3442 buf.extend(encode_avro_long(0));
3443 let mut cursor = AvroCursor::new(&buf);
3444 decoder.decode(&mut cursor).unwrap();
3445 let arr = decoder.flush(None).unwrap();
3446 let outer = arr.as_any().downcast_ref::<ListArray>().unwrap();
3447 assert_eq!(outer.len(), 1);
3448 assert_eq!(outer.value_length(0), 1);
3449 let inner = outer.values().as_any().downcast_ref::<ListArray>().unwrap();
3450 assert_eq!(inner.len(), 1);
3451 assert_eq!(inner.value_length(0), 2);
3452 let values = inner
3453 .values()
3454 .as_any()
3455 .downcast_ref::<Int32Array>()
3456 .unwrap();
3457 assert_eq!(values.values(), &[5, 6]);
3458 }
3459
3460 #[test]
3461 fn test_array_decoding_empty_array() {

Callers

nothing calls this directly

Calls 11

avro_from_codecFunction · 0.85
try_newFunction · 0.85
encode_avro_longFunction · 0.85
encode_avro_intFunction · 0.85
ListClass · 0.50
cloneMethod · 0.45
extendMethod · 0.45
decodeMethod · 0.45
flushMethod · 0.45
as_anyMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected