jessiedanwang commented on issue #5414:
URL: https://github.com/apache/iceberg/issues/5414#issuecomment-1205552368
thanks a lot, will keep an eye for 0.14.1. In the meantime, i am trying to
create custom serializer as follows, but got compilation error for newHashMap,
looks like it does not work with relocated immutableMap?
overloaded method value newHashMap with alternatives:
[K, V](x$1: java.util.Map[_ <: K, _ <: V])java.util.HashMap[K,V] <and>
[K, V]()java.util.HashMap[K,V]
cannot be applied to
(org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap[Any,Any])
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.Serializer
import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import com.google.common.collect.Maps
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap
class ImmutableMapSerializer(acceptNull: Boolean = true, immutable: Boolean
= true) extends Serializer[ImmutableMap[Any,Any]](acceptNull, immutable) {
override def write (kryo: Kryo, output: Output, map:
ImmutableMap[Any,Any]): Unit = {
kryo.writeObject(output, Maps.newHashMap(map) )
}
override def read (kryo: Kryo, input: Input, dataype:
Class[ImmutableMap[Any,Any]]): ImmutableMap[Any,Any] = {
val map: java.util.Map[Any,Any] = kryo.readObject (input,
classOf[java.util.HashMap[Any,Any]] )
return ImmutableMap.copyOf(map)
}
}
and also,
class CustomKryoRegistrator extends KryoRegistrator {
override def registerClasses(kryo: Kryo): Unit = {
val serializer = new ImmutableMapSerializer()
kryo.register(classOf[java.util.HashMap[Any,Any]])
kryo.register(classOf[ImmutableMap[Any,Any]], serializer)
kryo.register(Class.forName("org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap"),
serializer)
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]