TypeInformation composition ?

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

TypeInformation composition ?

Laurent Exsteens
Hello,

I have a generic ProcessFunction using list state, for which I receive the type information as constructor parameter (since it is not possible to create the type information in the class due to type Erasure).

I now need to keep not only the data, but also the timestamp at which they appear. But I don't find a way to create a list state of Tuple2<long, T> (where T is the generic type, for which I receive the type information as parameter.

I would like to create that state descriptor getting only those informations (in order to keep the interface of the class simple.

Right now I manage by creating 2 state: one for T and one for Long.

But I wonder if I could create that composite state,. For exemple n'y composing the type informations, but I didn't find a way to do that.

Any other idea is also welcome.

Thanks in advance.

Regards,

Laurent.

 Be green, keep it on the screen
Reply | Threaded
Open this post in threaded view
|

Re: TypeInformation composition ?

Seth Wiesman
If the type information for T is stored in a member variable called myTypeInfo you can do something like this.

import org.apache.flink.api.common.typeinfo.Types;

Types.TUPLE(Types.LONG, myTypeInfo);

Seth 

On Apr 11, 2020, at 11:06 AM, Laurent Exsteens <[hidden email]> wrote:


Hello,

I have a generic ProcessFunction using list state, for which I receive the type information as constructor parameter (since it is not possible to create the type information in the class due to type Erasure).

I now need to keep not only the data, but also the timestamp at which they appear. But I don't find a way to create a list state of Tuple2<long, T> (where T is the generic type, for which I receive the type information as parameter.

I would like to create that state descriptor getting only those informations (in order to keep the interface of the class simple.

Right now I manage by creating 2 state: one for T and one for Long.

But I wonder if I could create that composite state,. For exemple n'y composing the type informations, but I didn't find a way to do that.

Any other idea is also welcome.

Thanks in advance.

Regards,

Laurent.

 Be green, keep it on the screen
Reply | Threaded
Open this post in threaded view
|

Re: TypeInformation composition ?

Laurent Exsteens
Thanks a lot! 

On Sat, 11 Apr 2020 at 20:45, Seth Wiesman <[hidden email]> wrote:
If the type information for T is stored in a member variable called myTypeInfo you can do something like this.

import org.apache.flink.api.common.typeinfo.Types;

Types.TUPLE(Types.LONG, myTypeInfo);

Seth 

On Apr 11, 2020, at 11:06 AM, Laurent Exsteens <[hidden email]> wrote:


Hello,

I have a generic ProcessFunction using list state, for which I receive the type information as constructor parameter (since it is not possible to create the type information in the class due to type Erasure).

I now need to keep not only the data, but also the timestamp at which they appear. But I don't find a way to create a list state of Tuple2<long, T> (where T is the generic type, for which I receive the type information as parameter.

I would like to create that state descriptor getting only those informations (in order to keep the interface of the class simple.

Right now I manage by creating 2 state: one for T and one for Long.

But I wonder if I could create that composite state,. For exemple n'y composing the type informations, but I didn't find a way to do that.

Any other idea is also welcome.

Thanks in advance.

Regards,

Laurent.

 Be green, keep it on the screen


--
Laurent Exsteens
Data Engineer
(M) +32 (0) 486 20 48 36

EURA NOVA

Rue Emile Francqui, 4

1435 Mont-Saint-Guibert

(T) <a href="tel:%2B32%2010%2075%2002%2000" value="+3210750200" style="color:rgb(17,85,204)" target="_blank">+32 10 75 02 00

euranova.eu

research.euranova.eu


 Be green, keep it on the screen