Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
beliefer committed Oct 27, 2020
1 parent 72e7805 commit 9c35ddd
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ abstract class OffsetWindowFunctionFrameBase(
newMutableProjection(boundExpressions, Nil).target(target)
}

override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = {
input = rows
inputIterator = input.generateIterator()
// drain the first few rows if offset is larger than zero
inputIndex = 0
while (inputIndex < offset) {
if (inputIterator.hasNext) inputIterator.next()
inputIndex += 1
}
inputIndex = offset
}

override def currentLowerBound(): Int = throw new UnsupportedOperationException()

override def currentUpperBound(): Int = throw new UnsupportedOperationException()
Expand All @@ -163,6 +151,18 @@ class FrameLessOffsetWindowFunctionFrame(
extends OffsetWindowFunctionFrameBase(
target, ordinal, expressions, inputSchema, newMutableProjection, offset) {

override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = {
input = rows
inputIterator = input.generateIterator()
// drain the first few rows if offset is larger than zero
inputIndex = 0
while (inputIndex < offset) {
if (inputIterator.hasNext) inputIterator.next()
inputIndex += 1
}
inputIndex = offset
}

override def write(index: Int, current: InternalRow): Unit = {
if (inputIndex >= 0 && inputIndex < input.length) {
val r = WindowFunctionFrame.getNextOrNull(inputIterator)
Expand Down

0 comments on commit 9c35ddd

Please sign in to comment.