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)
| 181 | /// Verification json file |
| 182 | /// `arrow-ipc-stream/integration/<version>/<path>.json.gz |
| 183 | fn 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 | |
| 221 | fn chunked_file(filename: &str, chunk_size: u64) -> impl Iterator<Item = Buffer> { |
| 222 | let mut file = File::open(filename).unwrap(); |
no test coverage detected