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

Function verify_encoded_split

arrow-flight/src/encode.rs:2070–2111  ·  view source on GitHub ↗

Coverage for Encodes the specified batch using several values of `max_flight_data_size` between 1K to 5K and ensures that the resulting size of the flight data stays within the limit + `allowed_overage` `allowed_overage` is how far off the actual data encoding is from the target limit that was set. It is an improvement when the allowed_overage dec

(batch: RecordBatch, allowed_overage: usize)

Source from the content-addressed store, hash-verified

2068 ///
2069 ///
2070 async fn verify_encoded_split(batch: RecordBatch, allowed_overage: usize) {
2071 let num_rows = batch.num_rows();
2072
2073 // Track the overall required maximum overage
2074 let mut max_overage_seen = 0;
2075
2076 for max_flight_data_size in [1024, 2021, 5000] {
2077 println!("Encoding {num_rows} with a maximum size of {max_flight_data_size}");
2078
2079 let mut stream = FlightDataEncoderBuilder::new()
2080 .with_max_flight_data_size(max_flight_data_size)
2081 // use 8-byte alignment - default alignment is 64 which produces bigger ipc data
2082 .with_options(IpcWriteOptions::try_new(8, false, MetadataVersion::V5).unwrap())
2083 .build(futures::stream::iter([Ok(batch.clone())]));
2084
2085 let mut i = 0;
2086 while let Some(data) = stream.next().await.transpose().unwrap() {
2087 let actual_data_size = flight_data_size(&data);
2088
2089 let actual_overage = actual_data_size.saturating_sub(max_flight_data_size);
2090
2091 assert!(
2092 actual_overage <= allowed_overage,
2093 "encoded data[{i}]: actual size {actual_data_size}, \
2094 actual_overage: {actual_overage} \
2095 allowed_overage: {allowed_overage}"
2096 );
2097
2098 i += 1;
2099
2100 max_overage_seen = max_overage_seen.max(actual_overage)
2101 }
2102 }
2103
2104 // ensure that the specified overage is exactly the maxmium so
2105 // that when the splitting logic improves, the tests must be
2106 // updated to reflect the better logic
2107 assert_eq!(
2108 allowed_overage, max_overage_seen,
2109 "Specified overage was too high"
2110 );
2111 }
2112}

Calls 9

try_newFunction · 0.85
flight_data_sizeFunction · 0.85
with_optionsMethod · 0.80
maxMethod · 0.80
num_rowsMethod · 0.45
buildMethod · 0.45
cloneMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected