如何在 Apache Flink 中注册 java.util.List 类型



是否可以将Environment#registerType用于java.util.List或其他集合类型?如果我这样做:

StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableGenericTypes();
env.registerType(List.class);

我仍然得到Generic types have been disabled in the ExecutionConfig and type java.util.List is treated as a generic type.

我本来想做的,但由于类型擦除而在 Java 中不可能做到的是:

StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableGenericTypes();
env.registerType(List<MyClass>.class);

不幸的是,我在文档中或使用搜索引擎找不到解决方案。

这样的实现List<T>怎么样

class MyClassList implements List<MyClass> {
...
}

然后,您可以使用特定MyClass注册类型MyClassList

相关内容

最新更新