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

Function test_array_decoding

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

Source from the content-addressed store, hash-verified

3379
3380 #[test]
3381 fn test_array_decoding() {
3382 let item_dt = avro_from_codec(Codec::Int32);
3383 let list_dt = avro_from_codec(Codec::List(Arc::new(item_dt)));
3384 let mut decoder = Decoder::try_new(&list_dt).unwrap();
3385 let mut row1 = Vec::new();
3386 row1.extend_from_slice(&encode_avro_long(2));
3387 row1.extend_from_slice(&encode_avro_int(10));
3388 row1.extend_from_slice(&encode_avro_int(20));
3389 row1.extend_from_slice(&encode_avro_long(0));
3390 let row2 = encode_avro_long(0);
3391 let mut cursor = AvroCursor::new(&row1);
3392 decoder.decode(&mut cursor).unwrap();
3393 let mut cursor2 = AvroCursor::new(&row2);
3394 decoder.decode(&mut cursor2).unwrap();
3395 let array = decoder.flush(None).unwrap();
3396 let list_arr = array.as_any().downcast_ref::<ListArray>().unwrap();
3397 assert_eq!(list_arr.len(), 2);
3398 let offsets = list_arr.value_offsets();
3399 assert_eq!(offsets, &[0, 2, 2]);
3400 let values = list_arr.values();
3401 let int_arr = values.as_primitive::<Int32Type>();
3402 assert_eq!(int_arr.len(), 2);
3403 assert_eq!(int_arr.value(0), 10);
3404 assert_eq!(int_arr.value(1), 20);
3405 }
3406
3407 #[test]
3408 fn test_array_decoding_with_negative_block_count() {

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
extend_from_sliceMethod · 0.80
ListClass · 0.50
decodeMethod · 0.45
flushMethod · 0.45
as_anyMethod · 0.45
value_offsetsMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected