-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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-37438] Improve the createLocalEnvironment by reduce duplicate operation on Configuration #26273
Conversation
ping @1996fanrui cc @davidradl |
return createLocalEnvironment(parallelism, new Configuration()); | ||
Configuration configuration = new Configuration(); | ||
configuration.set(CoreOptions.DEFAULT_PARALLELISM, parallelism); | ||
return createLocalEnvironment(configuration); |
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.
nit: Or
return createLocalEnvironment(new Configuration().set(CoreOptions.DEFAULT_PARALLELISM, parallelism));
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.
@davidradl @1996fanrui
Does Flink have any coding style preferences for this style?
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.
@beliefer I found https://flink.apache.org/how-to-contribute/code-style-and-quality-java/ but it does not include this example.
I was only thinking to not define variables if we can avoid it. As the committer @1996fanrui WDYT?
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.
Does Flink have any coding style preferences for this style?
I didn't see the strict style preference for this case. I like @davidradl 's suggestion because we could avoid one temporary variable.
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.
Done.
…create of Configuration
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.
Thanks for the refactor!
LGTM
Hi @davidradl , do you have any comment about this PR? I will merge it next Monday if no more comment. |
@1996fanrui @davidradl Thank you all! |
What is the purpose of the change
This PR proposes to improve the
createLocalEnvironment
by reduce duplicate operation onConfiguration
.Brief change log
Improve the
createLocalEnvironment
by reduce duplicate operation onConfiguration
Currently,
StreamExecutionEnvironment
provides acreateLocalEnvironment
with one parameter parallelism.Above method will create a new instance of
Configuration
and then calling the below override one.The second will create another instance of
Configuration
and name it withcopyOfConfiguration
.You can see add
configuration
intocopyOfConfiguration
withaddAll
.The issue is create
Configuration
duplicately and an extra operationaddAll
.Verifying this change
This change is already covered by existing tests, such as
ExpressionTestBase
.Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation