From 3caa20421f8a6950dec6e2ad1c54125ef3a896ab Mon Sep 17 00:00:00 2001 From: illumination-k <43526984+illumination-k@users.noreply.github.com> Date: Thu, 11 Nov 2021 04:55:33 +0900 Subject: [PATCH] Fixed error in computing projection in `io::ipc::read::reader::FileReader` (#596) --- src/io/ipc/read/reader.rs | 6 ++---- tests/it/io/ipc/read/file.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/io/ipc/read/reader.rs b/src/io/ipc/read/reader.rs index 0f025e4451c..e9a8328cfde 100644 --- a/src/io/ipc/read/reader.rs +++ b/src/io/ipc/read/reader.rs @@ -236,13 +236,11 @@ impl FileReader { /// Panics iff the projection is not in increasing order (e.g. `[1, 0]` nor `[0, 1, 1]` are valid) pub fn new(reader: R, metadata: FileMetadata, projection: Option>) -> Self { if let Some(projection) = projection.as_ref() { - let _ = projection.iter().fold(0, |mut acc, v| { + projection.windows(2).for_each(|x| { assert!( - *v > acc, + x[0] < x[1], "The projection on IPC must be ordered and non-overlapping" ); - acc = *v; - acc }); } let projection = projection.map(|projection| { diff --git a/tests/it/io/ipc/read/file.rs b/tests/it/io/ipc/read/file.rs index 602c4151a9a..c9f067ccc14 100644 --- a/tests/it/io/ipc/read/file.rs +++ b/tests/it/io/ipc/read/file.rs @@ -178,5 +178,5 @@ fn test_projection(version: &str, file_name: &str, column: usize) -> Result<()> fn read_projected() -> Result<()> { test_projection("1.0.0-littleendian", "generated_primitive", 1)?; test_projection("1.0.0-littleendian", "generated_dictionary", 2)?; - test_projection("1.0.0-littleendian", "generated_nested", 1) + test_projection("1.0.0-littleendian", "generated_nested", 0) }