Pass not serializable objects to Flink transformation functions

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

Pass not serializable objects to Flink transformation functions

Flavio Pompermaier
Hi to all,

in my Flink job I initialize some java object that doesn't implement serializable to use it within some Flink function (i.e. map or flatMap). At the moment the only way to achieve that is to keep those operators as private classes in the main one and reference to static fields or implement them as inner classes and reference to final parameters of the containing function.

Is there any way to move those classes to a normal class at the moment (e.g. forcing kryo serialization)?

Best,
Flavio
Reply | Threaded
Open this post in threaded view
|

Re: Pass not serializable objects to Flink transformation functions

Till Rohrmann

Hi Flavio,

for the user code logic Flink uses exclusively Java serialization. What you can do, though, is to override the readObject and writeObject methods which are used by Java serialization. Within the methods you can serialize the other object you’re referencing.

Cheers,
Till


On Mon, Jul 27, 2015 at 10:05 AM, Flavio Pompermaier <[hidden email]> wrote:
Hi to all,

in my Flink job I initialize some java object that doesn't implement serializable to use it within some Flink function (i.e. map or flatMap). At the moment the only way to achieve that is to keep those operators as private classes in the main one and reference to static fields or implement them as inner classes and reference to final parameters of the containing function.

Is there any way to move those classes to a normal class at the moment (e.g. forcing kryo serialization)?

Best,
Flavio