Saleh
08/13/2023, 2:33 PMjava.util class like HashSet , ArrayList or SortedSet in my POJO without having to use Kyro?
The warnings I get when I try this:
class java.util.ArrayList does not contain a setter for field size
Class class java.util.ArrayList 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 and schema evolution.
and
No fields were detected for class java.util.HashSet so it cannot be used as a POJO type and must be processed as GenericType. Please read the Flink documentation on "Data Types & Serialization" for details of the effect on performance and schema evolution.
I read through the documentation and stackoverflow and the conclusion is that I need to make a TypeInfoFactory and use it inside a TypeInfo annotation over my POJO.
While this seems incredibly tedious since I have a bunch of POJOs in my project, I would be fine with this solution if I could figure out how to do this for the Set types I'm using.
Any help would be appreciated.Keyur Makwana
08/14/2023, 6:30 AMSaleh
08/14/2023, 7:08 AMKeyur Makwana
08/14/2023, 7:11 AMpublic class ResourceTypeFactory extends TypeInfoFactory<Log> {
@Override
public TypeInformation<Log> createTypeInfo(Type type, Map<String, TypeInformation<?>> map) {
return Types.POJO(Log.class,ImmutableMap.<String, TypeInformation<?>>builder()
.put("resources", Types.LIST(Types.POJO(Resource.class)))
.put("version",Types.STRING)
.put("user", Types.POJO(User.class))
.build()
);
}
}Saleh
08/14/2023, 8:18 AMSET in the Types package.Keyur Makwana
08/14/2023, 2:57 PMKeyur Makwana
08/14/2023, 2:57 PM