Skip to content

Commit

Permalink
replace multiplier with ByteUnit methods
Browse files Browse the repository at this point in the history
  • Loading branch information
liyezhang556520 committed May 6, 2015
1 parent 9bf93e9 commit 8693288
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.roaringbitmap.{ArrayContainer, BitmapContainer, RoaringArray, Roaring
import org.apache.spark._
import org.apache.spark.api.python.PythonBroadcast
import org.apache.spark.broadcast.HttpBroadcast
import org.apache.spark.network.util.ByteUnit
import org.apache.spark.network.nio.{GetBlock, GotBlock, PutBlock}
import org.apache.spark.scheduler.{CompressedMapStatus, HighlyCompressedMapStatus}
import org.apache.spark.storage._
Expand All @@ -51,18 +52,18 @@ class KryoSerializer(conf: SparkConf)

private val bufferSizeKb = conf.getSizeAsKb("spark.kryoserializer.buffer", "64k")

if (bufferSizeKb >= 2048 * 1024) {
if (bufferSizeKb >= ByteUnit.GiB.toKiB(2)) {
throw new IllegalArgumentException("spark.kryoserializer.buffer must be less than " +
s"2048 mb, got: + ${bufferSizeKb/1024} mb.")
s"2048 mb, got: + ${ByteUnit.KiB.toMiB(bufferSizeKb)} mb.")
}
private val bufferSize = (bufferSizeKb * 1024).toInt
private val bufferSize = ByteUnit.KiB.toBytes(bufferSizeKb).toInt

val maxBufferSizeMb = conf.getSizeAsMb("spark.kryoserializer.buffer.max", "64m").toInt
if (maxBufferSizeMb >= 2048) {
if (maxBufferSizeMb >= ByteUnit.GiB.toMiB(2)) {
throw new IllegalArgumentException("spark.kryoserializer.buffer.max must be less than " +
s"2048 mb, got: + $maxBufferSizeMb mb.")
}
private val maxBufferSize = maxBufferSizeMb * 1024 * 1024
private val maxBufferSize = ByteUnit.MiB.toBytes(maxBufferSizeMb).toInt

private val referenceTracking = conf.getBoolean("spark.kryo.referenceTracking", true)
private val registrationRequired = conf.getBoolean("spark.kryo.registrationRequired", false)
Expand Down

0 comments on commit 8693288

Please sign in to comment.