How to register TypeInfoFactory for 'external' class

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to register TypeInfoFactory for 'external' class

Alexey Trenikhun
Hello,
I've class, which I can't change (generated code or class from third party library), so I can't use @TypeInfo annotation, how can I register TypeInfoFactory for such class? It looks like TypeExtractor has map of registered factories - registeredTypeInfoFactories and even registration method - registerFactory, but it is private, so how can I register TypeInfoFactory for class w/o using annotation.

Thanks,
Alexey
Reply | Threaded
Open this post in threaded view
|

Re: How to register TypeInfoFactory for 'external' class

Tzu-Li (Gordon) Tai
Hi Alexey,

I don't think using the @TypeInfo annotation is doable at the moment.

Is this class being used only for input / output types of functions /
operators?
Or are you using it as a state type?

For the former, I think you can explicitly set the TypeInformation by
calling setTypeInfo on transformations.
For the latter, you can provide your own TypeInformation / TypeSerializer
for the state when declaring the StateDescriptor for the state.

Cheers,
Gordon



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: How to register TypeInfoFactory for 'external' class

Alexey Trenikhun
Hi Gordon,
This class is used for states, in/out parameters and as key. As you wrote, there is no problem with usage in states - I just specify TypeInformation in descriptor. With return value of process function, I tried
.process(new MyProcessFunction())
.returns(MyTypeInformation), it works, but still gives warning, because method ‘.process()’ is trying to extract type information of MyProcessFunction before ‘.returns()’ is called. However, implementing of ResultTypeQueryable interface by MyProcessFunction helps, and this way I don’t need to call .returns(MyTypeInformation).
When used as key - I didn’t find way to override key type information for closure, seems the only way is to use explicit KeySelector implementing ResultTypeQueryable.
In short, ability to register MyTypeInformation for class at environment level would be more convenient, less bloat and less error prone.

Thanks,
Alexey

 

From: Tzu-Li (Gordon) Tai <[hidden email]>
Sent: Tuesday, February 12, 2019 9:14 PM
To: [hidden email]
Subject: Re: How to register TypeInfoFactory for 'external' class
 
Hi Alexey,

I don't think using the @TypeInfo annotation is doable at the moment.

Is this class being used only for input / output types of functions /
operators?
Or are you using it as a state type?

For the former, I think you can explicitly set the TypeInformation by
calling setTypeInfo on transformations.
For the latter, you can provide your own TypeInformation / TypeSerializer
for the state when declaring the StateDescriptor for the state.

Cheers,
Gordon



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/