Skip to content
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-7000] Add custom configuration local environment in Scala StreamExecutionEnvironment #4178

Closed
wants to merge 1 commit into from
Closed

[FLINK-7000] Add custom configuration local environment in Scala StreamExecutionEnvironment #4178

wants to merge 1 commit into from

Conversation

ch33hau
Copy link
Contributor

@ch33hau ch33hau commented Jun 24, 2017

See description in FLINK-7000

@zentol
Copy link
Contributor

zentol commented Jun 25, 2017

you're modifying an existing method, didn't you mean to add a new one?

@ch33hau
Copy link
Contributor Author

ch33hau commented Jun 25, 2017

Hi @zentol , thanks for taking time for reviewing :)

It was my original thought.
However turns out due to Scala supports default value in parameters, in order to achieve same behaviour as Java, adding a new method is not working here.

This is what currently Java has:

1. createLocalEnvironment()
2. createLocalEnvironment(Int)
3. createLocalEnvironment(Int, Configuration)

Before this PR, in Scala we have:

createLocalEnvironment(Int = defaultValue)

So a Scala user can access this method by createLocalEnvironment() or createLocalEnvironment(someValue).

If I add another method createLocalEnvironment(Int = defaultValue, conf = defaultValue), compiler will complain because at this moment createLocalEnvironment(someValue) is ambiguous.

My opinion is by just adding a parameter with default value to existing method, it doesn't change the existing way to access the method. In addition, Scala user can choose to use default values or override any one of them.

There is also a test in org.apache.flink.streaming.api.scala.DataStreamTest#testParallelism() to make sure that the existing method is working fine.

How do you think?

@zentol
Copy link
Contributor

zentol commented Jun 25, 2017

This method is part of the public API and thus must not be changed.

Does the compiler still complain if there is no default value for the configuration?

@ch33hau
Copy link
Contributor Author

ch33hau commented Jun 25, 2017

Do you mean a new method with createLocalEnvironment(Int, conf)?

By this way compiler won't complain, just both the value have to be entered.
However, I do agree that the way that you have suggested could allows user to pass in custom configuration without modifying public API

I could update the PR in a moment.

@ch33hau
Copy link
Contributor Author

ch33hau commented Jun 25, 2017

Hi @zentol ,

I have updated PR by adding a new method without default values.

Thanks =)

* @param parallelism The parallelism for the local environment.
* @param configuration Pass a custom configuration into the cluster.
*/
def createLocalEnvironment(parallelism: Int, configuration: Configuration):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the parallelism have a default value?

Copy link
Contributor Author

@ch33hau ch33hau Jun 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it can't. I have think about it before, again compiler complains.

It could be related to this scala issue spec

If you have two overloads with defaults on the same parameter position, 
we would need a different naming scheme. 
But we want to keep the generated byte-code stable over multiple compiler runs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that's unfortunate.

Copy link
Contributor

@zentol zentol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge this.

* @param parallelism The parallelism for the local environment.
* @param configuration Pass a custom configuration into the cluster.
*/
def createLocalEnvironment(parallelism: Int, configuration: Configuration):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that's unfortunate.

zentol pushed a commit to zentol/flink that referenced this pull request Jun 26, 2017
@ch33hau
Copy link
Contributor Author

ch33hau commented Jun 26, 2017

Thank you @zentol !

zentol pushed a commit to zentol/flink that referenced this pull request Jun 27, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 27, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 28, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 28, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 28, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 29, 2017
zentol pushed a commit to zentol/flink that referenced this pull request Jun 30, 2017
@asfgit asfgit closed this in acc2e34 Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants