Skip to content

Commit 9c7b1a2

Browse files
committed
Revert "Reuse CompactBuffer in UniqueKeyHashedRelation."
This reverts commit 97626a1.
1 parent 97626a1 commit 9c7b1a2

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

core/src/main/scala/org/apache/spark/util/collection/CompactBuffer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private[spark] class CompactBuffer[T] extends Seq[T] with Serializable {
4949
}
5050
}
5151

52-
def update(position: Int, value: T): Unit = {
52+
private def update(position: Int, value: T): Unit = {
5353
if (position < 0 || position >= curSize) {
5454
throw new IndexOutOfBoundsException
5555
}

sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashedRelation.scala

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ import org.apache.spark.util.collection.CompactBuffer
2828
* object.
2929
*/
3030
private[joins] sealed trait HashedRelation {
31-
/**
32-
* Get the rows matching the key back as a [[CompactBuffer]]. If no rows match this key,
33-
* null is returned.
34-
*
35-
* The concrete implementation may reuse the returned [[CompactBuffer]].
36-
*/
3731
def get(key: Row): CompactBuffer[Row]
3832
}
3933

@@ -55,16 +49,9 @@ private[joins] final class GeneralHashedRelation(hashTable: JavaHashMap[Row, Com
5549
private[joins] final class UniqueKeyHashedRelation(hashTable: JavaHashMap[Row, Row])
5650
extends HashedRelation with Serializable {
5751

58-
private[this] val compactBuf = CompactBuffer[Row](null)
59-
6052
override def get(key: Row) = {
6153
val v = hashTable.get(key)
62-
if (v eq null) {
63-
null
64-
} else {
65-
compactBuf(0) = v
66-
compactBuf
67-
}
54+
if (v eq null) null else CompactBuffer(v)
6855
}
6956

7057
def getValue(key: Row): Row = hashTable.get(key)

0 commit comments

Comments
 (0)