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

[SPARK-3285] [examples] Using values.sum is easier to understand than using values.foldLeft(0)(_ + _) #2182

Closed
wants to merge 3 commits into from

Conversation

watermen
Copy link
Contributor

def sum[B >: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus)
Using values.sum is easier to understand than using values.foldLeft(0)(_ + ), so we'd better use values.sum instead of values.foldLeft(0)( + _)

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@srowen
Copy link
Member

srowen commented Aug 28, 2014

+1 -- you should open a JIRA though. Although there's reluctance to do cross-cutting code polish PRs, this looks targeted, restricted to example/test code, and is also something that I've wanted to zap for a while.

@watermen watermen changed the title Using values.sum is easier to understand than using values.foldLeft(0)(_ + _) [SPARK-3285] [examples] Using values.sum is easier to understand than using values.foldLeft(0)(_ + _) Aug 28, 2014
@mattf
Copy link
Contributor

mattf commented Aug 28, 2014

+1 nice catch, the simpler the examples the easier they'll be to consume by their intended audience: folks who aren't experts yet

@rxin
Copy link
Contributor

rxin commented Aug 28, 2014

Jenkins, test this please.

@rxin
Copy link
Contributor

rxin commented Aug 28, 2014

LGTM pending Jenkins. sum is also much faster than fold.

@SparkQA
Copy link

SparkQA commented Aug 28, 2014

QA tests have started for PR 2182 at commit 17be9fb.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Aug 28, 2014

QA tests have finished for PR 2182 at commit 17be9fb.

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

@rxin
Copy link
Contributor

rxin commented Aug 28, 2014

Thanks. Merging this in master.

@asfgit asfgit closed this in 3901245 Aug 28, 2014
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
… using values.foldLeft(0)(_ + _)

def sum[B >: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus)
Using values.sum is easier to understand than using values.foldLeft(0)(_ + _), so we'd better use values.sum instead of values.foldLeft(0)(_ + _)

Author: Yadong Qi <qiyadong2010@gmail.com>

Closes apache#2182 from watermen/bug-fix3 and squashes the following commits:

17be9fb [Yadong Qi] Update CheckpointSuite.scala
714bda5 [Yadong Qi] Update BasicOperationsSuite.scala
57e704c [Yadong Qi] Update StatefulNetworkWordCount.scala
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