Skip to content

Commit

Permalink
replace if with require
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingCat committed Mar 13, 2014
1 parent ad483fd commit a40e8fb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/src/main/scala/org/apache/spark/rdd/RDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,8 @@ abstract class RDD[T: ClassTag](
* Return a sampled subset of this RDD.
*/
def sample(withReplacement: Boolean, fraction: Double, seed: Int): RDD[T] = {
if (fraction < Double.MinValue || fraction > Double.MaxValue) {
throw new Exception("Invalid fraction value:" + fraction)
}
require(fraction >= 0 && fraction <= Double.MaxValue,
"Invalid fraction value: " + fraction)
if (withReplacement) {
new PartitionwiseSampledRDD[T, T](this, new PoissonSampler[T](fraction), seed)
} else {
Expand Down

0 comments on commit a40e8fb

Please sign in to comment.