Skip to content

Conversation

@chetkhatri
Copy link
Contributor

What changes were proposed in this pull request?

  • Under Spark Scala Examples: Some of the syntax were written like Java way, It has been re-written as per scala style guide.
  • Most of all changes are followed to println() statement.

How was this patch tested?

Since, All changes proposed are re-writing println statements in scala way, manual run used to test println.

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Not sure if it's worth. String interpolation might be closer to Scala syntax vs I wonder if it makes users to understand it more easily, in particular, who are not used to Scala.

I think I don't have a strong preference between them and I'd just leave them out.

@chetkhatri
Copy link
Contributor Author

@HyukjinKwon I agree with you ! But since Spark is scala project - A lot's of developers refer examples available here and if those are Java Developers they might don't understand that this is right way to do in Scala ! I had a same discussion in Scala Days with developers and I think it does make sense here too.

@chetkhatri
Copy link
Contributor Author

chetkhatri commented Dec 19, 2017

parseArgs(args)

println("Performing local word count")
println(s"Performing local word count")
Copy link
Member

Choose a reason for hiding this comment

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

There is no interpolation here; revert changes like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@srowen Thanks for review, I did addressed changes. Please review

println(s"Success! Local Word Count ($localWordCount) " +
s"and DFS Word Count ($dfsWordCount) agree.")
println(s"Success! Local Word Count ($localWordCount)
and DFS Word Count ($dfsWordCount) agree.")
Copy link
Member

Choose a reason for hiding this comment

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

This should be reverted; you've added a bunch of space to the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@srowen Thanks for review, I did addressed changes. Please review.

// Initialize w to a random value
val w = DenseVector.fill(D) {2 * rand.nextDouble - 1}
println("Initial w: " + w)
println(s"Initial w: ${w}")
Copy link
Member

Choose a reason for hiding this comment

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

You can just write $w in cases like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@srowen Thanks for review, I did addressed changes. Please review


for (i <- 0 until 3) {
println("Iteration " + i)
println(s"Iteration ${i}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Beyond the unnecessary { } that @srowen has already mentioned, this isn't really a style improvement. "a string " + anotherString is arguably at least as good stylistically as using string interpolation for such simple concatenations of a string reference to the end of a string literal. It's only when there are multiple concatenations and/or multiple string references that interpolation is clearly the better way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markhamstra Thank you for valueable suggestion, I am addressed and did new commit.

"\n" +
"localFile - (string) local file to use in test\n" +
"dfsDir - (string) DFS directory for read/write tests\n"
val usage = s"""DFS Read-Write Test
Copy link
Contributor

Choose a reason for hiding this comment

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

here you should use

"""
 |...
 """.stripMargin

otherwise you introduce a lot of spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mgaido91 Thank you for feedback, changed addressed.

def showWarning() {
System.err.println(
"""WARN: This is a naive implementation of ALS and is given as an example!
s"""WARN: This is a naive implementation of ALS and is given as an example!
Copy link
Contributor

Choose a reason for hiding this comment

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

please here revert the change and do the same in all similar places, since there is no variable to interpolate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mgaido91 Thank you for feedback, changed addressed.

for (x <- mapped) { x + 2 }
val end = System.currentTimeMillis()
println("Iteration " + iter + " took " + (end-start) + " ms")
println(s"Iteration ${iter} took ${(end-start)} ms")
Copy link
Member

Choose a reason for hiding this comment

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

Let's just write as $iter and $end-start

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HyukjinKwon $end-start won't work, both are different variables see. I made changes.

def showWarning() {
System.err.println(
"""WARN: This is a naive implementation of ALS and is given as an example!
s"""WARN: This is a naive implementation of ALS and is given as an example!
Copy link
Member

Choose a reason for hiding this comment

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

Seems we don't need s.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HyukjinKwon Addressed ! Kindly do review

slices = slices_.getOrElse("2").toInt
case _ =>
System.err.println("Usage: SparkALS [M] [U] [F] [iters] [partitions]")
System.err.println(s"Usage: SparkALS [M] [U] [F] [iters] [partitions]")
Copy link
Member

Choose a reason for hiding this comment

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

ditto for s.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HyukjinKwon Addressed ! Kindly do review

@chetkhatri
Copy link
Contributor Author

@HyukjinKwon @mgaido91 @srowen All the changes are addressed and committed, please do review and needful.

@SparkQA
Copy link

SparkQA commented Dec 20, 2017

Test build #4018 has finished for PR 20016 at commit a14eb3e.

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

@chetkhatri
Copy link
Contributor Author

@srowen why only recent commit is going to merge, can't we get "squash merge" ?
Please re-run test build. and let me know if still seems wrong.

@srowen
Copy link
Member

srowen commented Dec 20, 2017

@chetkhatri not sure what you mean. The whole change here is considered, and doesn't pass style checks. Look at the test results and fix the errors.

@chetkhatri
Copy link
Contributor Author

@srowen Thanks for response, correct - i went through error of jenkins and found error Online[https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/4018/console] which fixed accordingly to me and committed so please take a look, if not correct please suggest the same.
Thank you

@SparkQA
Copy link

SparkQA commented Dec 20, 2017

Test build #4019 has finished for PR 20016 at commit 319e282.

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

@chetkhatri
Copy link
Contributor Author

@srowen Thank you for re-run, now it passes all.

@chetkhatri
Copy link
Contributor Author

@srowen I think, we can merge this now.

@srowen
Copy link
Member

srowen commented Dec 20, 2017

Merged to master

@asfgit asfgit closed this in 792915c Dec 20, 2017
Sign up for free to 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.

6 participants