简体   繁体   English

在flink(scala)中使用kryo在某种类型上注册protobuf序列化程序时出现问题

[英]Problem registering protobuf serializer on a certain type with kryo in flink (scala)

I have a code snippet as follows:我有一个代码片段如下:

env.getConfig.registerTypeWithKryoSerializer(classOf[EventMeta], classOf[ProtobufSerializer[EventMeta]])

where EventMeta is a case class generated from proto message by scalaPB.其中EventMeta是一个案例 class 由 scalaPB 从 proto 消息生成。 We use flink 1.10.1 and scala 2.11.我们使用 flink 1.10.1 和 scala 2.11。

I tried to translate the Java code from the doc: env.getConfig.registerTypeWithKryoSerializer(EventMeta.class, ProtobufSerializer.class) , but the compiler keeps telling me:我试图翻译文档中的 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]])

Apparently, ProtobufSerializer doesn't extend Serializer in our version of flink.显然, ProtobufSerializer并没有在我们的 flink 版本中扩展Serializer Is there an error in doc or ProtobufSerializer ? doc 或ProtobufSerializer是否有错误? How do I fix this?我该如何解决?

Are you importing this:你要导入这个:

import com.twitter.chill.protobuf.ProtobufSerializer;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM