[Exception]Key expressions are only supported on POJO types and Tuples

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

[Exception]Key expressions are only supported on POJO types and Tuples

Vinh June
Hello,
I ran into this exception while trying to call groupBy function.
I thought all val(s) are already set to public by default.
My class can be found here http://pastebin.com/EZuiP9XA

Any one has any idea how to fix it?
Thank you.

======================================
log4j:WARN No appenders could be found for logger (org.apache.flink.api.java.typeutils.TypeExtractor).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.IllegalArgumentException: Key expressions are only supported on POJO types and Tuples. A type is considered a POJO if all its fields are public, or have both getters and setters defined
        at org.apache.flink.api.java.operators.Keys$ExpressionKeys.<init>(Keys.java:276)
        at org.apache.flink.api.scala.DataSet.groupBy(DataSet.scala:707)
        at vj.polimi.thesis.gmql.model.GmqlSampleSet.<init>(GmqlSampleSet.scala:35)
        at vj.polimi.thesis.test.GmqlFromNarrowPeak$.main(GmqlFromNarrowPeak.scala:63)
        at vj.polimi.thesis.test.GmqlFromNarrowPeak.main(GmqlFromNarrowPeak.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
======================================

Reply | Threaded
Open this post in threaded view
|

Re: [Exception]Key expressions are only supported on POJO types and Tuples

Vinh June
sorry, here is also the Metadata class that I use http://pastebin.com/WUQE613E
Reply | Threaded
Open this post in threaded view
|

Re: [Exception]Key expressions are only supported on POJO types and Tuples

Fabian Hueske-2
Hi,

you are right, there is a problem. I reproduced the problem and it seems that regular Scala classes are not properly analyzed and not identified as Pojos.
As long as you only need these classes to be data holders without custom logic, you could go with case classes.

I will open a JIRA to extend Pojo support for regular Scala classes.

Thanks for reporting,
Fabian

2015-02-11 2:42 GMT+01:00 Vinh June <[hidden email]>:
sorry, here is also the Metadata class that I use
http://pastebin.com/WUQE613E



--
View this message in context: http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Exception-Key-expressions-are-only-supported-on-POJO-types-and-Tuples-tp720p721.html
Sent from the Apache Flink (Incubator) User Mailing List archive. mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: [Exception]Key expressions are only supported on POJO types and Tuples

Fabian Hueske-2
In case you want to contribute or follow the discussion, here's the JIRA: https://issues.apache.org/jira/browse/FLINK-1511

Again, thanks for reporting!

2015-02-11 9:59 GMT+01:00 Fabian Hueske <[hidden email]>:
Hi,

you are right, there is a problem. I reproduced the problem and it seems that regular Scala classes are not properly analyzed and not identified as Pojos.
As long as you only need these classes to be data holders without custom logic, you could go with case classes.

I will open a JIRA to extend Pojo support for regular Scala classes.

Thanks for reporting,
Fabian

2015-02-11 2:42 GMT+01:00 Vinh June <[hidden email]>:
sorry, here is also the Metadata class that I use
http://pastebin.com/WUQE613E



--
View this message in context: http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Exception-Key-expressions-are-only-supported-on-POJO-types-and-Tuples-tp720p721.html
Sent from the Apache Flink (Incubator) User Mailing List archive. mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: [Exception]Key expressions are only supported on POJO types and Tuples

Aljoscha Krettek
From the Flink documentation:

Conditions for a class to be treated as a POJO by Flink:

 - The class must be public
 - It must have a public constructor without arguments
 - All fields either have to be public or there must be getters and
setters for all non-public fields.

In your example, the zero argument constructor is missing. You could
consider adding the constructor or changing to case classes.

On Wed, Feb 11, 2015 at 10:08 AM, Fabian Hueske <[hidden email]> wrote:

> In case you want to contribute or follow the discussion, here's the JIRA:
> https://issues.apache.org/jira/browse/FLINK-1511
>
> Again, thanks for reporting!
>
> 2015-02-11 9:59 GMT+01:00 Fabian Hueske <[hidden email]>:
>>
>> Hi,
>>
>> you are right, there is a problem. I reproduced the problem and it seems
>> that regular Scala classes are not properly analyzed and not identified as
>> Pojos.
>> As long as you only need these classes to be data holders without custom
>> logic, you could go with case classes.
>>
>> I will open a JIRA to extend Pojo support for regular Scala classes.
>>
>> Thanks for reporting,
>> Fabian
>>
>> 2015-02-11 2:42 GMT+01:00 Vinh June <[hidden email]>:
>>>
>>> sorry, here is also the Metadata class that I use
>>> http://pastebin.com/WUQE613E
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Exception-Key-expressions-are-only-supported-on-POJO-types-and-Tuples-tp720p721.html
>>> Sent from the Apache Flink (Incubator) User Mailing List archive. mailing
>>> list archive at Nabble.com.
>>
>>
>