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

Function verify_arrow_stream

arrow-integration-testing/tests/ipc_reader.rs:183–219  ·  view source on GitHub ↗

Verifies the arrow stream integration test Input file: `arrow-ipc-stream/integration/ / .stream Verification json file `arrow-ipc-stream/integration/ / .json.gz

(testdata: &str, version: &str, path: &str)

Source from the content-addressed store, hash-verified

181/// Verification json file
182/// `arrow-ipc-stream/integration/<version>/<path>.json.gz
183fn verify_arrow_stream(testdata: &str, version: &str, path: &str) {
184 let filename = format!("{testdata}/arrow-ipc-stream/integration/{version}/{path}.stream");
185 println!("Verifying {filename}");
186
187 // read expected JSON output
188 let arrow_json = read_gzip_json(version, path);
189
190 // Compare contents to the expected output format in JSON
191 {
192 println!(" verifying content");
193 let file = File::open(&filename).unwrap();
194 let mut reader = StreamReader::try_new(file, None).unwrap();
195
196 assert!(arrow_json.equals_reader(&mut reader).unwrap());
197 // the next batch must be empty
198 assert!(reader.next().is_none());
199 // the stream must indicate that it's finished
200 assert!(reader.is_finished());
201 }
202
203 // Test stream decoder
204 let expected = arrow_json.get_record_batches().unwrap();
205 for chunk_sizes in [1, 2, 8, 123] {
206 let mut decoder = StreamDecoder::new();
207 let stream = chunked_file(&filename, chunk_sizes);
208 let mut actual = Vec::with_capacity(expected.len());
209 for mut x in stream {
210 while !x.is_empty() {
211 if let Some(x) = decoder.decode(&mut x).unwrap() {
212 actual.push(x);
213 }
214 }
215 }
216 decoder.finish().unwrap();
217 assert_eq!(expected, actual);
218 }
219}
220
221fn chunked_file(filename: &str, chunk_size: u64) -> impl Iterator<Item = Buffer> {
222 let mut file = File::open(filename).unwrap();

Callers 4

read_0_1_4Function · 0.85
read_0_1_7Function · 0.85
read_1_0_0_littleendianFunction · 0.85
read_2_0_0_compressionFunction · 0.85

Calls 9

read_gzip_jsonFunction · 0.85
try_newFunction · 0.85
chunked_fileFunction · 0.85
get_record_batchesMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45
decodeMethod · 0.45
pushMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected