Mixing POJO and Tuples

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

Mixing POJO and Tuples

Flavio Pompermaier
Hi all,

in my code I create my model objects extending some TupleX in order to perform joins etc but now I have to add additional info to those classes. Since those attributes are not involved in any Flink operator (just in the end in my UDF) I was thinking to add them as fields instead of increasing the arity of the extended Tuple to avoid to change all the input and output of my UDFs.

In this way I'm mixing POJO and Tuples. Do you see any problem in that approach?

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

Re: Mixing POJO and Tuples

Fabian Hueske-2
Hi Flavio,

this will not work out of the box. If you extend a Flink tuple and add additional fields, the type will be recognized as tuple and the TupleSerializer will be used to serialize and deserialize the record. Since the TupleSerializer is not aware of your additional fields it will not serialize this information.

Best,
Fabian

2015-11-10 10:43 GMT+01:00 Flavio Pompermaier <[hidden email]>:
Hi all,

in my code I create my model objects extending some TupleX in order to perform joins etc but now I have to add additional info to those classes. Since those attributes are not involved in any Flink operator (just in the end in my UDF) I was thinking to add them as fields instead of increasing the arity of the extended Tuple to avoid to change all the input and output of my UDFs.

In this way I'm mixing POJO and Tuples. Do you see any problem in that approach?

Best,
Flavio

Reply | Threaded
Open this post in threaded view
|

Re: Mixing POJO and Tuples

Flavio Pompermaier
Ok great! Thanks for the explanation Fabian..I was sure that there were something wrong with this approach :)

On Tue, Nov 10, 2015 at 3:34 PM, Fabian Hueske <[hidden email]> wrote:
Hi Flavio,

this will not work out of the box. If you extend a Flink tuple and add additional fields, the type will be recognized as tuple and the TupleSerializer will be used to serialize and deserialize the record. Since the TupleSerializer is not aware of your additional fields it will not serialize this information.

Best,
Fabian

2015-11-10 10:43 GMT+01:00 Flavio Pompermaier <[hidden email]>:
Hi all,

in my code I create my model objects extending some TupleX in order to perform joins etc but now I have to add additional info to those classes. Since those attributes are not involved in any Flink operator (just in the end in my UDF) I was thinking to add them as fields instead of increasing the arity of the extended Tuple to avoid to change all the input and output of my UDFs.

In this way I'm mixing POJO and Tuples. Do you see any problem in that approach?

Best,
Flavio