Skip to content

[SPARK-27464][CORE] Added Constant instead of referring string literal used from many places - #24368

Closed
shivusondur wants to merge 3 commits into
apache:masterfrom
shivusondur:Constant
Closed

[SPARK-27464][CORE] Added Constant instead of referring string literal used from many places#24368
shivusondur wants to merge 3 commits into
apache:masterfrom
shivusondur:Constant

Conversation

@shivusondur

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Added Constant instead of referring the same String literal "spark.buffer.pageSize" from many places

How was this patch tested?

Run the corresponding Unit Test Cases manually.

@HyukjinKwon

Copy link
Copy Markdown
Member

ok to test

.createOptional

private[spark] val BUFFER_PAGESIZE = ConfigBuilder("spark.buffer.pageSize")
.bytesConf(ByteUnit.BYTE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add a doc?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@HyukjinKwon
Thanks for your time.
Now I added the doc and corrected the scalastyle issue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was going to say this needs a default, but it looks like the default in non-test code is not a single value, and different tests want different defaults.

@SparkQA

Copy link
Copy Markdown

Test build #104570 has finished for PR 24368 at commit bc815de.

  • This patch fails Java style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

> corrected the scalasyle issue
.createOptional

private[spark] val BUFFER_PAGESIZE = ConfigBuilder("spark.buffer.pageSize")
.bytesConf(ByteUnit.BYTE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was going to say this needs a default, but it looks like the default in non-test code is not a single value, and different tests want different defaults.

val size = ByteArrayMethods.nextPowerOf2(maxTungstenMemory / cores / safetyFactor)
val default = math.min(maxPageSize, math.max(minPageSize, size))
conf.getSizeAsBytes("spark.buffer.pageSize", default)
conf.getSizeAsBytes(BUFFER_PAGESIZE.key, default)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is a byteConf, can this just use conf.get()?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@srowen
Updated the code to use conf.get.
initially, I thought the same, But there is no method to provide the default value sparkConf class.
Now I am checking the values, if not present initializing with a default value.

@SparkQA

Copy link
Copy Markdown

Test build #104571 has finished for PR 24368 at commit eba8417.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #104577 has finished for PR 24368 at commit 8cf7d81.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@shivusondurshivusondur changed the title [MINOR][CORE] Added Constant instead of referring string literal used from many places[SPARK-27464][CORE] Added Constant instead of referring string literal used from many placesApr 15, 2019

@attilapirosattilapiros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small question otherwise LGTM.

@srowen

ghost commented Apr 16, 2019

Copy link
Copy Markdown
Member

Merged to master

@shivusondur

ghost commented Apr 16, 2019

Copy link
Copy Markdown
ContributorAuthor

@srowen
Thanks for merging

Sign up for freeto 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.

5 participants

@shivusondur@HyukjinKwon@SparkQA@srowen@attilapiros