siknezevic commented on a change in pull request #27246:
[SPARK-30536][CORE][SQL] Sort-merge join operator spilling performance
improvements
URL: https://github.com/apache/spark/pull/27246#discussion_r369937789
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/ExternalAppendOnlyUnsafeRowArray.scala
##########
@@ -204,22 +195,44 @@ private[sql] class ExternalAppendOnlyUnsafeRowArray(
}
}
- private[this] class SpillableArrayIterator(
+ private[this] class MergerIterator(
iterator: UnsafeSorterIterator,
- numFieldPerRow: Int)
+ numFieldPerRow: Int,
+ startIndex: Int)
extends ExternalAppendOnlyUnsafeRowArrayIterator {
- private val currentRow = new UnsafeRow(numFieldPerRow)
+ private var currentIndex = startIndex
- override def hasNext(): Boolean = !isModified() && iterator.hasNext
+ private val currentRow = {
+ if (startIndex < numRows) {
+ inMemoryBuffer(currentIndex)
+ } else {
+ new UnsafeRow(numFieldPerRow)
+ }
+ }
+
+ override def hasNext(): Boolean = {
+ if (currentIndex < numRows) {
+ !isModified()
+ } else {
+ !isModified() && iterator.hasNext
+ }
+ }
override def next(): UnsafeRow = {
throwExceptionIfModified()
- iterator.loadNext()
- currentRow.pointTo(iterator.getBaseObject, iterator.getBaseOffset,
iterator.getRecordLength)
- currentRow
+ if (currentIndex < numRows) {
+ val result = inMemoryBuffer(currentIndex)
+ currentIndex += 1
+ result
+ } else {
+ iterator.loadNext()
+ currentRow.pointTo(iterator.getBaseObject, iterator.getBaseOffset,
iterator.getRecordLength)
Review comment:
The same here. I will push all changes together. Thank you
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]