Skip to content

Commit 9c35ddd

Browse files
committed
Optimize code
1 parent 72e7805 commit 9c35ddd

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowFunctionFrame.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,6 @@ abstract class OffsetWindowFunctionFrameBase(
129129
newMutableProjection(boundExpressions, Nil).target(target)
130130
}
131131

132-
override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = {
133-
input = rows
134-
inputIterator = input.generateIterator()
135-
// drain the first few rows if offset is larger than zero
136-
inputIndex = 0
137-
while (inputIndex < offset) {
138-
if (inputIterator.hasNext) inputIterator.next()
139-
inputIndex += 1
140-
}
141-
inputIndex = offset
142-
}
143-
144132
override def currentLowerBound(): Int = throw new UnsupportedOperationException()
145133

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

154+
override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = {
155+
input = rows
156+
inputIterator = input.generateIterator()
157+
// drain the first few rows if offset is larger than zero
158+
inputIndex = 0
159+
while (inputIndex < offset) {
160+
if (inputIterator.hasNext) inputIterator.next()
161+
inputIndex += 1
162+
}
163+
inputIndex = offset
164+
}
165+
166166
override def write(index: Int, current: InternalRow): Unit = {
167167
if (inputIndex >= 0 && inputIndex < input.length) {
168168
val r = WindowFunctionFrame.getNextOrNull(inputIterator)

0 commit comments

Comments
 (0)