Skip to content

Commit

Permalink
Simplify a check
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 15, 2024
1 parent 37f73be commit 6261654
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions velox/exec/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,12 @@ void updateKRowsOffsetsColumn(
int precedingFactor = isKPreceding ? -1 : 1;
for (auto i = 0; i < numRows; i++) {
auto startValue = (int64_t)(startRow + i) + precedingFactor * offsets[i];
if (startValue > INT32_MAX || startValue < INT32_MIN) {
// Integer overflow. computeValidFrames will replace INT32_MAX set here
if (startValue < INT32_MIN) {
rawFrameBounds[i] = 0;
} else if (startValue > INT32_MAX) {
// computeValidFrames will replace INT32_MAX set here
// with partition's final row index.
rawFrameBounds[i] = startValue < 0 ? 0 : INT32_MAX;
rawFrameBounds[i] = INT32_MAX;
} else {
rawFrameBounds[i] = startValue;
}
Expand Down

0 comments on commit 6261654

Please sign in to comment.