diff options
author | Matei Zaharia <matei@eecs.berkeley.edu> | 2013-10-07 15:31:30 -0700 |
---|---|---|
committer | Matei Zaharia <matei@eecs.berkeley.edu> | 2013-10-07 19:16:35 -0700 |
commit | a8725bf8f82ffea215afe7dd6c9ea1df36618e5b (patch) | |
tree | 59cf62621f17a2fcf7b17eae055a43030f758431 /core/src | |
parent | 4a25b116d4e451afdf10fc4f018c383ed2c7789a (diff) | |
download | spark-a8725bf8f82ffea215afe7dd6c9ea1df36618e5b.tar.gz spark-a8725bf8f82ffea215afe7dd6c9ea1df36618e5b.tar.bz2 spark-a8725bf8f82ffea215afe7dd6c9ea1df36618e5b.zip |
Don't allocate Kryo buffers unless needed
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala b/core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala index 24ef204aa1..6c500bad92 100644 --- a/core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala +++ b/core/src/main/scala/org/apache/spark/serializer/KryoSerializer.scala @@ -38,8 +38,6 @@ class KryoSerializer extends org.apache.spark.serializer.Serializer with Logging def newKryoOutput() = new KryoOutput(bufferSize) - def newKryoInput() = new KryoInput(bufferSize) - def newKryo(): Kryo = { val instantiator = new ScalaKryoInstantiator val kryo = instantiator.newKryo() @@ -118,8 +116,10 @@ class KryoDeserializationStream(kryo: Kryo, inStream: InputStream) extends Deser private[spark] class KryoSerializerInstance(ks: KryoSerializer) extends SerializerInstance { val kryo = ks.newKryo() - val output = ks.newKryoOutput() - val input = ks.newKryoInput() + + // Make these lazy vals to avoid creating a buffer unless we use them + lazy val output = ks.newKryoOutput() + lazy val input = new KryoInput() def serialize[T](t: T): ByteBuffer = { output.clear() |