简体   繁体   English

Flink:scala 案例 class 通过 Kryo 被序列化为 GenericType

[英]Flink: scala case class being serialized as GenericType via Kryo

I have following case classes defined in my flink application (Flink 1.10.1)我在我的 flink 应用程序(Flink 1.10.1)中定义了以下案例类

case class FilterDefinition(filterDefId: String, filter: TileFilter)

case class TileFilter(tiles: Seq[Long], zoomLevel: Int)

During runtime, I noticed the log saying在运行时,我注意到日志说

FilterDefinition cannot be used as a POJO type because not all fields are valid POJO fields, and must be processed as GenericType. Please read the Flink documentation on "Data Types & Serialization" for details of the effect on performance.

If I interpreted Flink documentation correctly, the flink should be able to serialize the scala case classes and not need Kryo for it.如果我正确解释了 Flink 文档,flink 应该能够序列化 scala 案例类,并且不需要 Kryo。 However, it looks like for me, the above case class fallbacks on Kryo serializer.但是,对我来说,上面的案例 class 是 Kryo 序列化器的后备。

Did I miss interpret how case classes are handled by flink?我是否错过了 flink 处理案例类的解释?

Excerpting here from the documentation :此处摘自文档

Java and Scala classes are treated by Flink as a special POJO data type if they fulfill the following requirements: Flink 将 Java 和 Scala 类视为特殊的 POJO 数据类型,如果它们满足以下要求:

  • The class must be public. class 必须是公共的。

  • It must have a public constructor without arguments (default constructor).它必须有一个没有 arguments 的公共构造函数(默认构造函数)。

  • All fields are either public or must be accessible through getter and setter functions.所有字段要么是公共的,要么必须可以通过 getter 和 setter 函数访问。 For a field called foo the getter and setter methods must be named getFoo() and setFoo().对于名为 foo 的字段,getter 和 setter 方法必须命名为 getFoo() 和 setFoo()。

  • The type of a field must be supported by a registered serializer.字段的类型必须由已注册的序列化程序支持。

In this case Flink it appears that Flink doesn't know how to serialize TileFilter (or more specifically, Seq[Long]).在这种情况下,Flink 似乎 Flink 不知道如何序列化TileFilter (或者更具体地说,Seq[Long])。

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

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