Skip to content

Commit

Permalink
fix bug with ChunkedArray#compute
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcasale committed May 7, 2024
1 parent 7fb3adb commit 25f5440
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion deps/fastlanez
5 changes: 3 additions & 2 deletions vortex-array/src/array/chunked/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ impl ArrayStatisticsCompute for ChunkedArray<'_> {
s.compute(stat);
s.to_set()
})
.fold(StatsSet::new(), |mut acc, x| {
.reduce(|mut acc, x| {
acc.merge(&x);
acc
}))
})
.unwrap_or_else(StatsSet::new))
}
}
11 changes: 5 additions & 6 deletions vortex-ipc/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,6 @@ mod tests {
let data = PrimitiveArray::from((0i32..3_000_000).collect_vec()).into_array();
let data = round_trip(&data);

// NB: data is an ArrayData constructed from the result of calling read_array on an array
// reader. read_array calls to_static on the underlying chunks, which translates them
// from Array<ArrayView> to Array<ArrayData>, and in that translation, it calls to_set
// in the ArrayView's statistics. Thus, to check that we get correct behavior from
// ArrayView statistics get() and to_set() methods, we call get (but not compute!)
// on the result for each of the desired statistics
verify_stats(&data);

let run_count: u64 = data.statistics().get_as::<u64>(Stat::RunCount).unwrap();
Expand All @@ -501,6 +495,11 @@ mod tests {

let data = round_trip(&chunked_array);

// NB: data is an ArrayData constructed from the result of calling read_array on an array
// reader. compute on a ChunkedArray calls get_or_compute on the underlying chunks and
// merges the results, while get does not. Thus we need to compute a stat and force this
// merge computation before we can test get()
data.statistics().compute(Stat::Min).unwrap();
verify_stats(&data);

// TODO(@jcasale): run_count calculation is wrong for chunked arrays, this should be 3mm
Expand Down

0 comments on commit 25f5440

Please sign in to comment.