提交 96f6476f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Optimize EXCLUDE TIES part 1

上级 c2f95233
...@@ -538,13 +538,23 @@ public final class WindowFrame { ...@@ -538,13 +538,23 @@ public final class WindowFrame {
} else { } else {
int exStart = toGroupStart(orderedRows, sortOrder, currentRow, startIndex); int exStart = toGroupStart(orderedRows, sortOrder, currentRow, startIndex);
int exEnd = toGroupEnd(orderedRows, sortOrder, currentRow, endIndex); int exEnd = toGroupEnd(orderedRows, sortOrder, currentRow, endIndex);
if (exEnd < startIndex || exStart > endIndex) { boolean includeCurrentRow = exclusion == WindowFrameExclusion.EXCLUDE_TIES;
if (includeCurrentRow) {
if (currentRow == exStart) {
exStart++;
includeCurrentRow = false;
} else if (currentRow == exEnd) {
exEnd--;
includeCurrentRow = false;
}
}
if (exStart > exEnd || exEnd < startIndex || exStart > endIndex) {
// Nothing to do // Nothing to do
} else { } else {
BitSet set = new BitSet(endIndex + 1); BitSet set = new BitSet(endIndex + 1);
set.set(startIndex, endIndex + 1); set.set(startIndex, endIndex + 1);
set.clear(exStart, exEnd + 1); set.clear(exStart, exEnd + 1);
if (exclusion == WindowFrameExclusion.EXCLUDE_TIES) { if (includeCurrentRow) {
set.set(currentRow); set.set(currentRow);
} }
if (set.isEmpty()) { if (set.isEmpty()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论