简体   繁体   English

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

[英]How to register a java.util.List type in Apache Flink

Is it possible to use Environment#registerType for java.util.List or other collection types? 是否可以将Environment#registerType用于java.util.List或其他集合类型? If I do: 如果我做:

StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

env.getConfig().disableGenericTypes();
env.registerType(List.class);

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

What I acutally would like to do, but what is not possible in Java, because of type erasure is: 我很想做的是,但是由于类型擦除,在Java中是不可能的:

StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

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

Unfortunately, I found no solution in the documentation or using a search engine. 不幸的是,我在文档中或使用搜索引擎都找不到解决方案。

How about implements List<T> like 怎么样实现List<T>

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

then you can registerType Type MyClassList with specifict MyClass 那么您可以使用特定的MyClass注册Type类型MyClassList

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

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