Skip to content

[SPARK-22357][CORE][FOLLOWUP] SparkContext.binaryFiles ignore minPartitions parameter - #22356

Closed
srowen wants to merge 2 commits into
apache:masterfrom
srowen:SPARK-22357.2
Closed

[SPARK-22357][CORE][FOLLOWUP] SparkContext.binaryFiles ignore minPartitions parameter#22356
srowen wants to merge 2 commits into
apache:masterfrom
srowen:SPARK-22357.2

Conversation

@srowen

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This adds a test following #21638

How was this patch tested?

Existing tests and new test.

@srowen

Copy link
Copy Markdown
MemberAuthor

CC @bomeng@gatorsmile

@imatiach-msftimatiach-msft 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.

nice test!

@imatiach-msftimatiach-msft 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.

comments

StandardCharsets.UTF_8)
}

assert(sc.binaryFiles(tempDirPath, minPartitions = 1).getNumPartitions === 1)

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.

nitpick: maybe put these three asserts in a loop

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

OK, sure


test("SPARK-22357 test binaryFiles minPartitions") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local")
.set("spark.files.openCostInBytes", "0")

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.

why is this setting needed: spark.files.openCostInBytes

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This removes its effect in the section of code we're really trying to test:

def setMinPartitions(sc: SparkContext, context: JobContext, minPartitions: Int) {
val defaultMaxSplitBytes = sc.getConf.get(config.FILES_MAX_PARTITION_BYTES)
val openCostInBytes = sc.getConf.get(config.FILES_OPEN_COST_IN_BYTES)
val defaultParallelism = Math.max(sc.defaultParallelism, minPartitions)
val files = listStatus(context).asScala
val totalBytes = files.filterNot(_.isDirectory).map(_.getLen + openCostInBytes).sum
val bytesPerCore = totalBytes / defaultParallelism
val maxSplitSize = Math.min(defaultMaxSplitBytes, Math.max(openCostInBytes, bytesPerCore))
super.setMaxSplitSize(maxSplitSize)
}

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.

ah, I see, thanks for pointing that out!

@SparkQA

Copy link
Copy Markdown

Test build #95769 has finished for PR 22356 at commit 84dd4a7.

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

@SparkQA

Copy link
Copy Markdown

Test build #95771 has finished for PR 22356 at commit 6e1d8fd.

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

@bomeng

Copy link
Copy Markdown
Contributor

Thanks for taking my codes. Looks good.

@srowen

Copy link
Copy Markdown
MemberAuthor

Merged to master/2.4

asfgit pushed a commit that referenced this pull request Sep 7, 2018
…itions parameter
## What changes were proposed in this pull request?
This adds a test following #21638
## How was this patch tested?
Existing tests and new test.
Closes#22356 from srowen/SPARK-22357.2.
Authored-by: Sean Owen <sean.owen@databricks.com>
Signed-off-by: Sean Owen <sean.owen@databricks.com>
(cherry picked from commit 4e3365b)
Signed-off-by: Sean Owen <sean.owen@databricks.com>
@asfgitasfgit closed this in 4e3365bSep 7, 2018
@srowen
srowen deleted the SPARK-22357.2 branch September 20, 2018 10:52
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

@srowen@SparkQA@bomeng@HyukjinKwon@imatiach-msft