Skip to content

Commit fbf8d00

Browse files
Davies Liudavies
authored andcommitted
[SPARK-14419] [MINOR] coding style cleanup
## What changes were proposed in this pull request? Making them more consistent. ## How was this patch tested? Existing tests. Author: Davies Liu <[email protected]> Closes #12289 from davies/cleanup_style.
1 parent a7ce473 commit fbf8d00

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/TungstenAggregate.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ case class TungstenAggregate(
454454
val thisPlan = ctx.addReferenceObj("plan", this)
455455
hashMapTerm = ctx.freshName("hashMap")
456456
val hashMapClassName = classOf[UnsafeFixedWidthAggregationMap].getName
457-
ctx.addMutableState(hashMapClassName, hashMapTerm, s"")
457+
ctx.addMutableState(hashMapClassName, hashMapTerm, "")
458458
sorterTerm = ctx.freshName("sorter")
459459
ctx.addMutableState(classOf[UnsafeKVExternalSorter].getName, sorterTerm, "")
460460

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)