From aa67d02543b1af583c997ffd9b5bd7e3c1c6191d Mon Sep 17 00:00:00 2001 From: PHILO-HE Date: Tue, 10 Dec 2024 15:28:02 +0800 Subject: [PATCH] Opt following logic --- velox/exec/WindowPartition.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/velox/exec/WindowPartition.cpp b/velox/exec/WindowPartition.cpp index 2c75661c75d0..19f33812ed54 100644 --- a/velox/exec/WindowPartition.cpp +++ b/velox/exec/WindowPartition.cpp @@ -437,7 +437,21 @@ void WindowPartition::updateKRangeFrameBounds( } else { // start = lastFoundIndex == -1 ? currentRow // : std::min(lastFoundIndex, numRows - 1); - start = currentRow; + if (i == 0) { + start = currentRow; + } else { + auto compareResult = data_->compare( + partition_[currentRow - 1], + partition_[currentRow], + mappedFrameColumn, + mappedFrameColumn, + flags); + if (compareResult <= 0) { + start = lastFoundIndex == -1 ? currentRow : lastFoundIndex; + } else { + start = currentRow; + } + } end = partition_.size(); } rawFrameBounds[i] = searchFrameValue(