Skip to content
Snippets Groups Projects
Commit fbf8d008 authored by Davies Liu's avatar Davies Liu Committed by Davies Liu
Browse files

[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 <davies@databricks.com>

Closes #12289 from davies/cleanup_style.
parent a7ce473b
No related branches found
No related tags found
No related merge requests found
...@@ -454,7 +454,7 @@ case class TungstenAggregate( ...@@ -454,7 +454,7 @@ case class TungstenAggregate(
val thisPlan = ctx.addReferenceObj("plan", this) val thisPlan = ctx.addReferenceObj("plan", this)
hashMapTerm = ctx.freshName("hashMap") hashMapTerm = ctx.freshName("hashMap")
val hashMapClassName = classOf[UnsafeFixedWidthAggregationMap].getName val hashMapClassName = classOf[UnsafeFixedWidthAggregationMap].getName
ctx.addMutableState(hashMapClassName, hashMapTerm, s"") ctx.addMutableState(hashMapClassName, hashMapTerm, "")
sorterTerm = ctx.freshName("sorter") sorterTerm = ctx.freshName("sorter")
ctx.addMutableState(classOf[UnsafeKVExternalSorter].getName, sorterTerm, "") ctx.addMutableState(classOf[UnsafeKVExternalSorter].getName, sorterTerm, "")
......
...@@ -122,13 +122,12 @@ private[joins] class UnsafeHashedRelation( ...@@ -122,13 +122,12 @@ private[joins] class UnsafeHashedRelation(
override def keyIsUnique: Boolean = binaryMap.numKeys() == binaryMap.numValues() override def keyIsUnique: Boolean = binaryMap.numKeys() == binaryMap.numValues()
override def asReadOnlyCopy(): UnsafeHashedRelation = override def asReadOnlyCopy(): UnsafeHashedRelation = {
new UnsafeHashedRelation(numFields, binaryMap) new UnsafeHashedRelation(numFields, binaryMap)
override def estimatedSize: Long = {
binaryMap.getTotalMemoryConsumption
} }
override def estimatedSize: Long = binaryMap.getTotalMemoryConsumption
// re-used in get()/getValue() // re-used in get()/getValue()
var resultRow = new UnsafeRow(numFields) var resultRow = new UnsafeRow(numFields)
...@@ -374,8 +373,9 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap ...@@ -374,8 +373,9 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
// do not support spilling // do not support spilling
val got = mm.acquireExecutionMemory(size, MemoryMode.ON_HEAP, this) val got = mm.acquireExecutionMemory(size, MemoryMode.ON_HEAP, this)
if (got < size) { if (got < size) {
mm.releaseExecutionMemory(got, MemoryMode.ON_HEAP, this) freeMemory(got)
throw new SparkException(s"Can't acquire $size bytes memory to build hash relation") throw new SparkException(s"Can't acquire $size bytes memory to build hash relation, " +
s"got $got bytes")
} }
} }
...@@ -396,9 +396,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap ...@@ -396,9 +396,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
init() init()
def spill(size: Long, trigger: MemoryConsumer): Long = { def spill(size: Long, trigger: MemoryConsumer): Long = 0L
0L
}
/** /**
* Returns whether all the keys are unique. * Returns whether all the keys are unique.
...@@ -408,9 +406,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap ...@@ -408,9 +406,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
/** /**
* Returns total memory consumption. * Returns total memory consumption.
*/ */
def getTotalMemoryConsumption: Long = { def getTotalMemoryConsumption: Long = array.length * 8 + page.length
array.length * 8 + page.length
}
/** /**
* Returns the first slot of array that store the keys (sparse mode). * 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 ...@@ -423,9 +419,7 @@ private[execution] final class LongToUnsafeRowMap(var mm: TaskMemoryManager, cap
/** /**
* Returns the next probe in the array. * Returns the next probe in the array.
*/ */
private def nextSlot(pos: Int): Int = { private def nextSlot(pos: Int): Int = (pos + 2) & mask
(pos + 2) & mask
}
private def getRow(address: Long, resultRow: UnsafeRow): UnsafeRow = { private def getRow(address: Long, resultRow: UnsafeRow): UnsafeRow = {
val offset = address >>> 32 val offset = address >>> 32
...@@ -674,9 +668,7 @@ private[joins] class LongHashedRelation( ...@@ -674,9 +668,7 @@ private[joins] class LongHashedRelation(
override def asReadOnlyCopy(): LongHashedRelation = new LongHashedRelation(nFields, map) override def asReadOnlyCopy(): LongHashedRelation = new LongHashedRelation(nFields, map)
override def estimatedSize: Long = { override def estimatedSize: Long = map.getTotalMemoryConsumption
map.getTotalMemoryConsumption
}
override def get(key: InternalRow): Iterator[InternalRow] = { override def get(key: InternalRow): Iterator[InternalRow] = {
if (key.isNullAt(0)) { if (key.isNullAt(0)) {
...@@ -694,12 +686,9 @@ private[joins] class LongHashedRelation( ...@@ -694,12 +686,9 @@ private[joins] class LongHashedRelation(
} }
} }
override def get(key: Long): Iterator[InternalRow] = override def get(key: Long): Iterator[InternalRow] = map.get(key, resultRow)
map.get(key, resultRow)
override def getValue(key: Long): InternalRow = { override def getValue(key: Long): InternalRow = map.getValue(key, resultRow)
map.getValue(key, resultRow)
}
override def keyIsUnique: Boolean = map.keyIsUnique override def keyIsUnique: Boolean = map.keyIsUnique
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment