Skip to content

Commit 20a2811

Browse files
committed
use require
1 parent 6e4f8ca commit 20a2811

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mllib/src/main/scala/org/apache/spark/mllib/util/MLUtils.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,12 @@ object MLUtils {
8383
(index, value)
8484
}.unzip
8585

86-
// check if indices is one-based and in ascending order
86+
// check if indices are one-based and in ascending order
8787
var previous = -1
8888
var i = 0
8989
val indicesLength = indices.size
9090
while (i < indicesLength) {
91-
if (indices(i) <= previous) {
92-
throw new IllegalArgumentException("indices should be one-based and in ascending order")
93-
}
91+
require(indices(i) > previous, "indices should be one-based and in ascending order" )
9492
previous = indices(i)
9593
i += 1
9694
}

0 commit comments

Comments
 (0)