You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Martin Neumann <mn...@sics.se> on 2016/04/29 12:25:04 UTC

Fwd: TypeVariable problems

Hej,

I have a construct of different generic classes stacked on each other to
create a library (so the type variables get handed on). And I have some
trouble getting it to work.
The current offender is a Class with 3 type variables <K, V, RV> internally
it calls:

.fold(new Tuple3<>(keyInit ,new Tuple2<Double,Double>(0d,0d),
valueFold.getInit()), new
CountSumFold<V,K,RV>(keySelector,valueSelector,valueFold))

I initiated the class with <String, Tuple2<String,Double>,NullValue> but
when I try to run it it I get the exception:
org.apache.flink.api.common.functions.InvalidTypesException: Type of
TypeVariable 'K' in 'class se.sics.anomaly.bs.models.CountSumFold' could
not be determined.

Anyone has an idea on how to fix this problem?

cheers Martin

Re: TypeVariable problems

Posted by Martin Neumann <mn...@sics.se>.
Hi Aljosha

Thanks for your answer!
I tried using returns but it does not work since the only place where I
could call it is within the function that has all the generic types so
there is no useful type hint to give. I could make the user hand over the
class definition for the type as well but that would complicate the
interface and I like to avoid that. Is there documentation or example
somewhere so I can see how to use
InputTypeConfigurable/OutputTypeConfigurable.

if you have time you can also reach me on hangout (might be faster than
email). :-)

cheers Martin


On Mon, May 2, 2016 at 11:23 AM, Aljoscha Krettek <al...@apache.org>
wrote:

> Hi,
> for user functions that have generics, such as you have, you have to
> manually specify the types somehow. This can either be done using
> InputTypeConfigurable/OutputTypeConfigurable or maybe using
> stream.returns(<type>).
>
> Cheers,
> Aljoscha
>
> On Fri, 29 Apr 2016 at 12:25 Martin Neumann <mn...@sics.se> wrote:
>
>> Hej,
>>
>> I have a construct of different generic classes stacked on each other to
>> create a library (so the type variables get handed on). And I have some
>> trouble getting it to work.
>> The current offender is a Class with 3 type variables <K, V, RV>
>> internally it calls:
>>
>> .fold(new Tuple3<>(keyInit ,new Tuple2<Double,Double>(0d,0d), valueFold.getInit()), new CountSumFold<V,K,RV>(keySelector,valueSelector,valueFold))
>>
>> I initiated the class with <String, Tuple2<String,Double>,NullValue> but
>> when I try to run it it I get the exception:
>> org.apache.flink.api.common.functions.InvalidTypesException: Type of
>> TypeVariable 'K' in 'class se.sics.anomaly.bs.models.CountSumFold' could
>> not be determined.
>>
>> Anyone has an idea on how to fix this problem?
>>
>> cheers Martin
>>
>>

Re: TypeVariable problems

Posted by Aljoscha Krettek <al...@apache.org>.
Hi,
for user functions that have generics, such as you have, you have to
manually specify the types somehow. This can either be done using
InputTypeConfigurable/OutputTypeConfigurable or maybe using
stream.returns(<type>).

Cheers,
Aljoscha

On Fri, 29 Apr 2016 at 12:25 Martin Neumann <mn...@sics.se> wrote:

> Hej,
>
> I have a construct of different generic classes stacked on each other to
> create a library (so the type variables get handed on). And I have some
> trouble getting it to work.
> The current offender is a Class with 3 type variables <K, V, RV>
> internally it calls:
>
> .fold(new Tuple3<>(keyInit ,new Tuple2<Double,Double>(0d,0d), valueFold.getInit()), new CountSumFold<V,K,RV>(keySelector,valueSelector,valueFold))
>
> I initiated the class with <String, Tuple2<String,Double>,NullValue> but
> when I try to run it it I get the exception:
> org.apache.flink.api.common.functions.InvalidTypesException: Type of
> TypeVariable 'K' in 'class se.sics.anomaly.bs.models.CountSumFold' could
> not be determined.
>
> Anyone has an idea on how to fix this problem?
>
> cheers Martin
>
>