我有一个
Foo
类,由 Flink 在 DataStream
: 中处理
public class Foo {
private int id;
public List<Data> data;
// Getter, setters, and constructor
public static class Data {
private String bar;
// Getter, setters, and constructor
}
}
当我运行应用程序时,我看到以下警告:
Field Foo#data will be processed as GenericType.
这意味着这个列表是由
Kryo
序列化程序处理的,速度非常慢。我想避免在此列表中使用 Kryo 序列化程序。我尝试根据 Flink 的序列化指南使用 Protobuf 来解决这个问题。
这是我添加到代码中的内容:
env.getConfig().registerTypeWithKryoSerializer(Foo.Data.class, ProtobufSerializer.class);
我还包含了 Protobuf 相应的 Maven 依赖项。但是,我仍然看到相同的警告:
Field Foo#data will be processed as GenericType.
预期结果: 我希望 Flink 正确序列化 Foo#data 字段,而不将其处理为 GenericType,并避免出现警告。
您尝试过下面给出的方法吗?
env.getConfig().registerKryoType(Foo.Data.class);
如果没有,请尝试。