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

Function test_decoder_partial

parquet/src/arrow/push_decoder/mod.rs:1012–1048  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1010 /// Decode the entire file incrementally, simulating partial reads
1011 #[test]
1012 fn test_decoder_partial() {
1013 let mut decoder = ParquetPushDecoderBuilder::try_new_decoder(test_file_parquet_metadata())
1014 .unwrap()
1015 .build()
1016 .unwrap();
1017
1018 // First row group, expect a single request for all data needed to read "a" and "b"
1019 let ranges = expect_needs_data(decoder.try_decode());
1020 push_ranges_to_decoder(&mut decoder, ranges);
1021
1022 let batch1 = expect_data(decoder.try_decode());
1023 let expected1 = TEST_BATCH.slice(0, 200);
1024 assert_eq!(batch1, expected1);
1025
1026 // Second row group, this time provide the data in two steps
1027 let ranges = expect_needs_data(decoder.try_decode());
1028 let (ranges1, ranges2) = ranges.split_at(ranges.len() / 2);
1029 assert!(!ranges1.is_empty());
1030 assert!(!ranges2.is_empty());
1031 // push first half to simulate partial read
1032 push_ranges_to_decoder(&mut decoder, ranges1.to_vec());
1033
1034 // still expect more data
1035 let ranges = expect_needs_data(decoder.try_decode());
1036 assert_eq!(ranges, ranges2); // should be the remaining ranges
1037 // push empty ranges should be a no-op
1038 push_ranges_to_decoder(&mut decoder, vec![]);
1039 let ranges = expect_needs_data(decoder.try_decode());
1040 assert_eq!(ranges, ranges2); // should be the remaining ranges
1041 push_ranges_to_decoder(&mut decoder, ranges);
1042
1043 let batch2 = expect_data(decoder.try_decode());
1044 let expected2 = TEST_BATCH.slice(200, 200);
1045 assert_eq!(batch2, expected2);
1046
1047 expect_finished(decoder.try_decode());
1048 }
1049
1050 /// Decode multiple columns "a" and "b", expect that the decoder requests
1051 /// only a single request per row group

Callers

nothing calls this directly

Calls 9

push_ranges_to_decoderFunction · 0.85
expect_needs_dataFunction · 0.70
expect_dataFunction · 0.70
expect_finishedFunction · 0.70
buildMethod · 0.45
try_decodeMethod · 0.45
sliceMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected