You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Komal Mariam <ko...@gmail.com> on 2019/11/01 03:33:41 UTC

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

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

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

Posted by Komal Mariam <ko...@gmail.com>.
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 <lz...@apache.org> 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 <ji...@gmail.com>
> 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 <ko...@gmail.com>
>> 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
>

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

Posted by Jingsong Lee <lz...@apache.org>.
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 <ji...@gmail.com> 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 <ko...@gmail.com>
> 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