Skip to content

Commit

Permalink
Fixes #3654: Out of bounds bug writing float segarray (#3659)
Browse files Browse the repository at this point in the history
This PR (fixes #3654) bug with writing float segarray containing empty segments and nans with parquet

Co-authored-by: Tess Hayes <stress-tess@users.noreply.github.com>
  • Loading branch information
stress-tess and stress-tess committed Aug 14, 2024
1 parent b0dffaf commit 015b139
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/ParquetMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,9 @@ module ParquetMsg {
var valIdxRange = startValIdx..endValIdx;
ref olda = values.a;
int_vals[ui..#valIdxRange.size] = olda[valIdxRange];
ptrList[i] = c_ptrTo(int_vals[ui]): c_ptr(void);
if !int_vals.domain.isEmpty() {
ptrList[i] = c_ptrTo(int_vals[ui]): c_ptr(void);
}
}
when DType.UInt64 {
segarray_sizes[i] = seg_sizes_int[i];
Expand All @@ -1696,7 +1698,9 @@ module ParquetMsg {
var valIdxRange = startValIdx..endValIdx;
ref olda = values.a;
int_vals[ui..#valIdxRange.size] = olda[valIdxRange]: int;
ptrList[i] = c_ptrTo(int_vals[ui]): c_ptr(void);
if !int_vals.domain.isEmpty() {
ptrList[i] = c_ptrTo(int_vals[ui]): c_ptr(void);
}
}
when DType.Float64 {
segarray_sizes[i] = seg_sizes_real[i];
Expand All @@ -1709,7 +1713,9 @@ module ParquetMsg {
var valIdxRange = startValIdx..endValIdx;
ref olda = values.a;
real_vals[ri..#valIdxRange.size] = olda[valIdxRange];
ptrList[i] = c_ptrTo(real_vals[ri]): c_ptr(void);
if !real_vals.domain.isEmpty() {
ptrList[i] = c_ptrTo(real_vals[ri]): c_ptr(void);
}
}
when DType.Bool {
segarray_sizes[i] = seg_sizes_bool[i];
Expand All @@ -1722,7 +1728,9 @@ module ParquetMsg {
var valIdxRange = startValIdx..endValIdx;
ref olda = values.a;
bool_vals[bi..#valIdxRange.size] = olda[valIdxRange];
ptrList[i] = c_ptrTo(bool_vals[bi]): c_ptr(void);
if !bool_vals.domain.isEmpty() {
ptrList[i] = c_ptrTo(bool_vals[bi]): c_ptr(void);
}
}
when DType.Strings {
segarray_sizes[i] = val_sizes_str[i];
Expand All @@ -1749,7 +1757,9 @@ module ParquetMsg {
var endValIdx = if (lastOffsetIdx == offIdxRange.high) then lastValIdx else oldOff[offIdxRange.high + 1] - 1;
var valIdxRange = startValIdx..endValIdx;
str_vals[si..#valIdxRange.size] = oldVal[valIdxRange];
ptrList[i] = c_ptrTo(str_vals[si]): c_ptr(void);
if !str_vals.domain.isEmpty() {
ptrList[i] = c_ptrTo(str_vals[si]): c_ptr(void);
}
}
}
otherwise {
Expand Down

0 comments on commit 015b139

Please sign in to comment.