@@ -122,13 +122,12 @@ private[joins] class UnsafeHashedRelation(
122122
123123 override def keyIsUnique : Boolean = binaryMap.numKeys() == binaryMap.numValues()
124124
125- override def asReadOnlyCopy (): UnsafeHashedRelation =
125+ override def asReadOnlyCopy (): UnsafeHashedRelation = {
126126 new UnsafeHashedRelation (numFields, binaryMap)
127-
128- override def estimatedSize : Long = {
129- binaryMap.getTotalMemoryConsumption
130127 }
131128
129+ override def estimatedSize : Long = binaryMap.getTotalMemoryConsumption
130+
132131 // re-used in get()/getValue()
133132 var resultRow = new UnsafeRow (numFields)
134133
@@ -374,8 +373,9 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
374373 // do not support spilling
375374 val got = mm.acquireExecutionMemory(size, MemoryMode .ON_HEAP , this )
376375 if (got < size) {
377- mm.releaseExecutionMemory(got, MemoryMode .ON_HEAP , this )
378- throw new SparkException (s " Can't acquire $size bytes memory to build hash relation " )
376+ freeMemory(got)
377+ throw new SparkException (s " Can't acquire $size bytes memory to build hash relation, " +
378+ s " got $got bytes " )
379379 }
380380 }
381381
@@ -396,9 +396,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
396396
397397 init()
398398
399- def spill (size : Long , trigger : MemoryConsumer ): Long = {
400- 0L
401- }
399+ def spill (size : Long , trigger : MemoryConsumer ): Long = 0L
402400
403401 /**
404402 * Returns whether all the keys are unique.
@@ -408,9 +406,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
408406 /**
409407 * Returns total memory consumption.
410408 */
411- def getTotalMemoryConsumption : Long = {
412- array.length * 8 + page.length
413- }
409+ def getTotalMemoryConsumption : Long = array.length * 8 + page.length
414410
415411 /**
416412 * Returns the first slot of array that store the keys (sparse mode).
@@ -423,9 +419,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
423419 /**
424420 * Returns the next probe in the array.
425421 */
426- private def nextSlot (pos : Int ): Int = {
427- (pos + 2 ) & mask
428- }
422+ private def nextSlot (pos : Int ): Int = (pos + 2 ) & mask
429423
430424 private def getRow (address : Long , resultRow : UnsafeRow ): UnsafeRow = {
431425 val offset = address >>> 32
@@ -674,9 +668,7 @@ private[joins] class LongHashedRelation(
674668
675669 override def asReadOnlyCopy (): LongHashedRelation = new LongHashedRelation (nFields, map)
676670
677- override def estimatedSize : Long = {
678- map.getTotalMemoryConsumption
679- }
671+ override def estimatedSize : Long = map.getTotalMemoryConsumption
680672
681673 override def get (key : InternalRow ): Iterator [InternalRow ] = {
682674 if (key.isNullAt(0 )) {
@@ -694,12 +686,9 @@ private[joins] class LongHashedRelation(
694686 }
695687 }
696688
697- override def get (key : Long ): Iterator [InternalRow ] =
698- map.get(key, resultRow)
689+ override def get (key : Long ): Iterator [InternalRow ] = map.get(key, resultRow)
699690
700- override def getValue (key : Long ): InternalRow = {
701- map.getValue(key, resultRow)
702- }
691+ override def getValue (key : Long ): InternalRow = map.getValue(key, resultRow)
703692
704693 override def keyIsUnique : Boolean = map.keyIsUnique
705694
0 commit comments