Skip to content

Commit cf2e567

Browse files
author
Alain
committed
[MLLIB][tree] Use a rdd api to verify size of input rdd > 0 when building meta data
Use rdd api isEmpty
1 parent b448f47 commit cf2e567

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mllib/src/main/scala/org/apache/spark/mllib/tree/impl/DecisionTreeMetadata.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ private[tree] object DecisionTreeMetadata extends Logging {
107107
numTrees: Int,
108108
featureSubsetStrategy: String): DecisionTreeMetadata = {
109109

110-
val numExamples = input.count()
111-
require(numExamples > 0, s"DecisionTree requires size of input RDD > 0, " +
112-
s"but was given by an empty one.")
110+
require(!input.isEmpty, s"DecisionTree requires size of input RDD > 0, " +
111+
s"but was given by an empty one.")
113112

113+
val numExamples = input.count()
114114
val numFeatures = input.take(1)(0).features.size
115115
val numClasses = strategy.algo match {
116116
case Classification => strategy.numClasses

0 commit comments

Comments
 (0)