我有一个代码片段如下:
env.getConfig.registerTypeWithKryoSerializer(classOf[EventMeta], classOf[ProtobufSerializer[EventMeta]])
其中CCD_ 1是scalaPB根据proto消息生成的case类。我们使用flink 1.10.1和scala 2.11。
我试图从文档中翻译Java代码:env.getConfig.registerTypeWithKryoSerializer(EventMeta.class, ProtobufSerializer.class)
,但编译器一直告诉我:
overloaded method value registerTypeWithKryoSerializer with alternatives:
[error] (x$1: Class[_],x$2: Class[_ <: com.esotericsoftware.kryo.Serializer[_]])Unit <and>
[error] [T <: com.esotericsoftware.kryo.Serializer[_] with java.io.Serializable](x$1: Class[_], x$2: T)Unit
[error] cannot be applied to (Class[com.here.lanes.laneroadreference.derivation.statefun.state.EventMeta.EventMeta], Class[org.apache.flink.statefun.flink.common.protobuf.ProtobufSerializer[com.here.lanes.laneroadreference.derivation.statefun.state.EventMeta.EventMeta]])
[error] env.getConfig.registerTypeWithKryoSerializer(classOf[EventMeta], classOf[ProtobufSerializer[EventMeta]])
显然,在我们的flink版本中,ProtobufSerializer
并没有扩展Serializer
。文档或ProtobufSerializer
中是否存在错误?我该如何解决这个问题?
你正在导入这个吗:
import com.twitter.chill.protobuf.ProtobufSerializer;