New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-9976][streaming] Remove unnecessary generic parameters #6437
Conversation
Isn't this meant for the case where you want to change the |
but the bucket ID type is already defined in the constructor. you can't just change that. |
I think the Builders are done wrong. Instead of reusing the builder, the builder should be immutable and each call should return a new builder that has fields from the old builder and the new value that the user wants to set. This way we don't need to reinterpret. WDYT? |
I think that would be a nicer approach. The fact that this compiles and runs without error is rather disgusting:
|
@aljoscha I've reworked the builders. This introduced a small gotcha for tests; if you set the |
👍 that's better now |
Shall we also change the PR's title? |
I agree that the code looks nicer now, but essentially the only thing changed is that in the:
now we throw the |
@@ -205,33 +205,40 @@ private StreamingFileSink( | |||
this.rollingPolicy = DefaultRollingPolicy.create().build(); | |||
} | |||
|
|||
RowFormatBuilder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor can be private
. Actually also the other constructor could be, as it is called by the enclosing class, but if it were to move the builder to a different file, then it would have a problem. So I would recommend to make the new constructor private
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also call this constructor from the other one, just to have a single point of assignment of variables.
@@ -275,22 +282,30 @@ private StreamingFileSink( | |||
this.bucketer = Preconditions.checkNotNull(bucketer); | |||
} | |||
|
|||
BulkFormatBuilder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this constructor can be private
and call this constructor from the previous one.
yes, the functionality is the same, and in my example the test would now fail. |
What is the purpose of the change
This PR removes unnecessary generic parameter from format builder methods of the
StreamingFileSink
.These are inconsistent with other existing methods that use the already defined bucket ID type of the builder, and as of right now would always lead to
ClassCastExceptions
if one tried to use a different type.