@@ -193,6 +193,35 @@ class KryoSerializerSuite extends FunSuite with SharedSparkContext {
193193 }
194194}
195195
196+ class KryoSerializerResizableOutputSuite extends FunSuite {
197+ import org .apache .spark .SparkConf
198+ import org .apache .spark .SparkContext
199+ import org .apache .spark .LocalSparkContext
200+ import org .apache .spark .SparkException
201+
202+ // trial and error showed this will not serialize with 1mb buffer
203+ val x = (1 to 400000 ).toArray
204+
205+ test(" kryo without resizable output buffer should fail on large array" ) {
206+ val conf = new SparkConf (false )
207+ conf.set(" spark.serializer" , " org.apache.spark.serializer.KryoSerializer" )
208+ conf.set(" spark.kryoserializer.buffer.mb" , " 1" )
209+ val sc = new SparkContext (" local" , " test" , conf)
210+ intercept[SparkException ](sc.parallelize(x).collect)
211+ LocalSparkContext .stop(sc)
212+ }
213+
214+ test(" kryo with resizable output buffer should succeed on large array" ) {
215+ val conf = new SparkConf (false )
216+ conf.set(" spark.serializer" , " org.apache.spark.serializer.KryoSerializer" )
217+ conf.set(" spark.kryoserializer.buffer.mb" , " 1" )
218+ conf.set(" spark.kryoserializer.buffer.max.mb" , " 2" )
219+ val sc = new SparkContext (" local" , " test" , conf)
220+ assert(sc.parallelize(x).collect === x)
221+ LocalSparkContext .stop(sc)
222+ }
223+ }
224+
196225object KryoTest {
197226 case class CaseClass (i : Int , s : String ) {}
198227
0 commit comments