Skip to content

Conversation

@harborl
Copy link

@harborl harborl commented Nov 22, 2017

Only because of the thread-safe and coding convention consideration, please check if it's OK with adding final decoration?

Only because of the thread-safe and coding convention consideration, please check if it's OK with adding `final` decoration?
@greghogan
Copy link
Contributor

This change doesn't work since WordWithCount needs to be a POJO which requires a default or no-args constructor and non-final public attributes or getters/setters. Since the type is not a POJO the TypeExtractor falls back to GenericType, which cannot be used as a key type as noted in the error message:

Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.949 sec <<< FAILURE! - in org.apache.flink.streaming.test.socket.SocketWindowWordCountITCase
testJavaProgram(org.apache.flink.streaming.test.socket.SocketWindowWordCountITCase)  Time elapsed: 0.045 sec  <<< ERROR!
org.apache.flink.api.common.InvalidProgramException: This type (GenericType<org.apache.flink.streaming.examples.socket.SocketWindowWordCount.WordWithCount>) cannot be used as key.
	at org.apache.flink.api.common.operators.Keys$ExpressionKeys.<init>(Keys.java:330)
	at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:295)
	at org.apache.flink.streaming.examples.socket.SocketWindowWordCount.main(SocketWindowWordCount.java:79)
	at org.apache.flink.streaming.test.socket.SocketWindowWordCountITCase.testJavaProgram(SocketWindowWordCountITCase.java:65)

Reconsider this code, it seems my bad as my lack of understanding underlying stuff. However, I still suggest to support the immutable Value Object(if not) for programming because it might be a more natural manner.
@greghogan
Copy link
Contributor

Do we still want to make this change since the PR is now only adding a single comment?

@fhueske
Copy link
Contributor

fhueske commented Nov 28, 2017

IMO, the added comment might rather confuse readers than help them.

@harborl harborl closed this Dec 7, 2017
@harborl harborl deleted the patch-1 branch December 7, 2017 16:54
@harborl
Copy link
Author

harborl commented Dec 7, 2017

Yes, after a few learning, it turns out, to me, that this project uses POJO as a sort of reasonable style of parameters(it has nothing with the thread-safe consideration here, although value object corresponds with it). Excuse me for the interruption and my poor English. I think I am excited about learning further and it is a great project truly, as far as I can tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants