title: Spark Kryo: Register a custom serializer
body: <p>I have a class that implements a custom Kryo serializer by implementing the <code>read()</code> and <code>write()</code> methods from <code>com.esotericsoftware.kryo.Serializer</code> (see example below). <strong>How can I register this custom serializer with Spark?</strong></p>
  
  <p>Here is a pseudo-code example of what I have: </p>
  
  <pre><code>class A() 
  
  CustomASerializer extends com.esotericsoftware.kryo.Serializer[A]{
      override def write(kryo: Kryo, output: Output, a: A): Unit = ???
      override def read(kryo: Kryo, input: Input, t: Class[A]): A = ???
  }
  
  val kryo: Kryo = ... 
  kryo.register(classOf[A], new CustomASerializer()); // I can register my serializer
  </code></pre>
  
  <p>Now in Spark: </p>
  
  <pre><code>val sparkConf = new SparkConf()
  sparkConf.registerKryoClasses(Array(classOf[A]))
  </code></pre>
  
  <p>Unfortunately, Spark doesn't give me the option to register my custom serializer. Any idea if there is a way to do this? </p>