Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Feb 27, 2024
1 parent e18cd45 commit 73a273e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions velox/exec/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,13 @@ void updateKRowsOffsetsColumn(
// moves ahead.
int precedingFactor = isKPreceding ? -1 : 1;
for (auto i = 0; i < numRows; i++) {
rawFrameBounds[i] =
(startRow + i) + vector_size_t(precedingFactor * offsets[i]);
auto startValue = (int64_t)(startRow + i) + precedingFactor * offsets[i];
// Considers integer overflow case.
if (startValue != (int32_t)startValue) {
rawFrameBounds[i] = startValue < 0 ? 0 : numRows - 1;
} else {
rawFrameBounds[i] = startValue;
}
}
}

Expand All @@ -300,8 +305,16 @@ void Window::updateKRowsFrameBounds(
if (frameArg.index == kConstantChannel) {
auto constantOffset = frameArg.constant.value();
auto startValue =
startRow + (isKPreceding ? -constantOffset : constantOffset);
std::iota(rawFrameBounds, rawFrameBounds + numRows, startValue);
(isKPreceding ? -constantOffset : constantOffset) + startRow;
for (int i = 0; i < numRows; i++) {
// Considers integer overflow case.
if (startValue != (int32_t)startValue) {
rawFrameBounds[i] = startValue < 0 ? 0 : numRows - 1;
} else {
rawFrameBounds[i] = startValue;
}
startValue = startValue + 1;
}
} else {
currentPartition_->extractColumn(
frameArg.index, partitionOffset_, numRows, 0, frameArg.value);
Expand Down

0 comments on commit 73a273e

Please sign in to comment.