Spark Kryo: Register a custom serializer

前端 未结 1 1089
清酒与你
清酒与你 2020-12-06 02:09

I have a class that implements a custom Kryo serializer by implementing the read() and write() methods from com.esotericsoftware.kryo.Seriali

相关标签:
1条回答
  • 2020-12-06 02:45

    Create your own KryoRegistrator with this custom serializer registered:

    package com.acme
    
    class MyRegistrator extends KryoRegistrator {
      override def registerClasses(kryo: Kryo) {
        kryo.register(classOf[A], new CustomASerializer())
      } 
    }
    

    Then, set spark.kryo.registrator to your registrator's fully-qualified name, e.g. com.acme.MyRegistrator:

    val conf = new SparkConf()
    conf.set("spark.kryo.registrator", "com.acme.KryoRegistrator")
    
    0 讨论(0)
提交回复
热议问题