How to write type information for a Java Set and List inside a Tuple?

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

How to write type information for a Java Set and List inside a Tuple?

Komal Mariam
Hi all,

I'm trying to create a MapState<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> for KeyedBroadcastProcessFunction but I'm not sure how to initialize its MapStateDescriptor.

I have written it in two ways as given below and my IDE isn't showing an error either way (haven't tested on runtime yet). 

I'd really appreciate if anyone can tell me which way is correct and if not what's the best way to give Type Hints for  Tuple3<Set<String>, Set<String>, List<myClass>>

myClass is POJO type. 

Code Snippet 1:

        private final MapStateDescriptor<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> outStateDesc =
                new MapStateDescriptor<>(
                        "neighbours",
                        BasicTypeInfo.INT_TYPE_INFO,
                        new TupleTypeInfo<>(TypeInformation.of(new TypeHint<Set>() {}),
                                TypeInformation.of(new TypeHint<Set>() {}),
                                new ListTypeInfo<>(myClass.class)));




Code Snippet 2:
        private final MapStateDescriptor<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> outStateDesc =
                new MapStateDescriptor<>(
                        "neighbours",
                        BasicTypeInfo.INT_TYPE_INFO,
                        TypeInformation.of(new TypeHint<Tuple3<Set<String>, Set<String>, List<myClass>>>(){}));



Best Regards,
Komal
Reply | Threaded
Open this post in threaded view
|

Re: How to write type information for a Java Set and List inside a Tuple?

Jingsong Lee
Hi Komal:
I think snippet 1 is better, because it carry more information like ListTypeInfo.
Consider snippet 2, now our type inference in TypeInformation.of can not infer the nested information. (It not get the information: List<myClass>)

On Fri, Nov 1, 2019 at 11:49 AM Jingsong Li <[hidden email]> wrote:
Hi Komal:
I think snippet 1 is better, because it carry more information like ListTypeInfo.
Consider snippet 2, now our type inference in TypeInformation.of can not infer the nested information. (It not get the information: List<myClass>)

On Fri, Nov 1, 2019 at 11:34 AM Komal Mariam <[hidden email]> wrote:
Hi all,

I'm trying to create a MapState<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> for KeyedBroadcastProcessFunction but I'm not sure how to initialize its MapStateDescriptor.

I have written it in two ways as given below and my IDE isn't showing an error either way (haven't tested on runtime yet). 

I'd really appreciate if anyone can tell me which way is correct and if not what's the best way to give Type Hints for  Tuple3<Set<String>, Set<String>, List<myClass>>

myClass is POJO type. 

Code Snippet 1:

        private final MapStateDescriptor<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> outStateDesc =
                new MapStateDescriptor<>(
                        "neighbours",
                        BasicTypeInfo.INT_TYPE_INFO,
                        new TupleTypeInfo<>(TypeInformation.of(new TypeHint<Set>() {}),
                                TypeInformation.of(new TypeHint<Set>() {}),
                                new ListTypeInfo<>(myClass.class)));




Code Snippet 2:
        private final MapStateDescriptor<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> outStateDesc =
                new MapStateDescriptor<>(
                        "neighbours",
                        BasicTypeInfo.INT_TYPE_INFO,
                        TypeInformation.of(new TypeHint<Tuple3<Set<String>, Set<String>, List<myClass>>>(){}));



Best Regards,
Komal


--
Best, Jingsong Lee


--
Best, Jingsong Lee
Reply | Threaded
Open this post in threaded view
|

Re: How to write type information for a Java Set and List inside a Tuple?

Komal Mariam
Thank you. I went with the first one. Have not encountered any problems during run time.

On Fri, 1 Nov 2019 at 12:50, Jingsong Lee <[hidden email]> wrote:
Hi Komal:
I think snippet 1 is better, because it carry more information like ListTypeInfo.
Consider snippet 2, now our type inference in TypeInformation.of can not infer the nested information. (It not get the information: List<myClass>)

On Fri, Nov 1, 2019 at 11:49 AM Jingsong Li <[hidden email]> wrote:
Hi Komal:
I think snippet 1 is better, because it carry more information like ListTypeInfo.
Consider snippet 2, now our type inference in TypeInformation.of can not infer the nested information. (It not get the information: List<myClass>)

On Fri, Nov 1, 2019 at 11:34 AM Komal Mariam <[hidden email]> wrote:
Hi all,

I'm trying to create a MapState<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> for KeyedBroadcastProcessFunction but I'm not sure how to initialize its MapStateDescriptor.

I have written it in two ways as given below and my IDE isn't showing an error either way (haven't tested on runtime yet). 

I'd really appreciate if anyone can tell me which way is correct and if not what's the best way to give Type Hints for  Tuple3<Set<String>, Set<String>, List<myClass>>

myClass is POJO type. 

Code Snippet 1:

        private final MapStateDescriptor<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> outStateDesc =
                new MapStateDescriptor<>(
                        "neighbours",
                        BasicTypeInfo.INT_TYPE_INFO,
                        new TupleTypeInfo<>(TypeInformation.of(new TypeHint<Set>() {}),
                                TypeInformation.of(new TypeHint<Set>() {}),
                                new ListTypeInfo<>(myClass.class)));




Code Snippet 2:
        private final MapStateDescriptor<Integer, Tuple3<Set<String>, Set<String>, List<myClass>>> outStateDesc =
                new MapStateDescriptor<>(
                        "neighbours",
                        BasicTypeInfo.INT_TYPE_INFO,
                        TypeInformation.of(new TypeHint<Tuple3<Set<String>, Set<String>, List<myClass>>>(){}));



Best Regards,
Komal


--
Best, Jingsong Lee


--
Best, Jingsong Lee