-
Notifications
You must be signed in to change notification settings - Fork 29k
Spark 1246 add min max to stat counter #144
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
Changes from 1 commit
4916016
eaf89d9
29981f2
37a7dea
1e7056d
ed67136
a5c13b0
1a97558
21dd366
5d96799
82cde0e
fd3fd4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,11 +477,23 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable { | |
| new java.util.ArrayList(arr) | ||
| } | ||
|
|
||
| /** | ||
| * Returns the maximum element from this RDD as defined by the specified | ||
| * Comparator[T]. | ||
| * @params comp the comparator that defines ordering | ||
| * @return the maximum of the RDD | ||
| * */ | ||
| def max(comp: Comparator[T]): T = { | ||
| import scala.collection.JavaConversions._ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need to import this if you're going to call Ordering.comparatorToOrdering directly -- was it necessary? It was in some other methods because they used other conversions |
||
| rdd.max()(Ordering.comparatorToOrdering(comp)) | ||
| } | ||
|
|
||
| /** | ||
| * Returns the minimum element from this RDD as defined by the specified | ||
| * Comparator[T]. | ||
| * @params comp the comparator that defines ordering | ||
| * @return the minimum of the RDD | ||
| * */ | ||
| def min(comp: Comparator[T]): T = { | ||
| import scala.collection.JavaConversions._ | ||
| rdd.min()(Ordering.comparatorToOrdering(comp)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,8 +29,8 @@ class StatCounter(values: TraversableOnce[Double]) extends Serializable { | |
| private var n: Long = 0 // Running count of our values | ||
| private var mu: Double = 0 // Running mean of our values | ||
| private var m2: Double = 0 // Running variance numerator (sum of (x - mean)^2) | ||
| private var max_v: Double = 0 // Running max of our values | ||
| private var min_v: Double = 0 // Running min of our values | ||
| private var max_v: Double = Double(-Infinity) // Running max of our values | ||
| private var min_v: Double = Double(Infinity) // Running min of our values | ||
|
|
||
| merge(values) | ||
|
|
||
|
|
@@ -135,7 +135,7 @@ class StatCounter(values: TraversableOnce[Double]) extends Serializable { | |
| def sampleStdev: Double = math.sqrt(sampleVariance) | ||
|
|
||
| override def toString: String = { | ||
| "(count: %d, mean: %f, stdev: %f)".format(count, mean, stdev) | ||
| "(count: %d, mean: %f, stdev: %f, max: %f, min: $f)".format(count, mean, stdev, max, min) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc comments to these and the Scala versions