tdcmeehan commented on code in PR #58417:
URL: https://github.com/apache/spark/pull/58417#discussion_r3906087693
##########
mllib/src/main/scala/org/apache/spark/ml/feature/MinHashLSH.scala:
##########
@@ -222,16 +222,20 @@ object MinHashLSHModel extends
MLReadable[MinHashLSHModel] {
private def hashFunction(
elems: Vector,
randCoefficients: Array[(Int, Int)]): Array[Vector] = {
- require(elems.nonZeroIterator.nonEmpty, "Must have at least 1 non zero
entry.")
- val hashValues = randCoefficients.map { case (a, b) =>
- elems.nonZeroIterator.map { case (i, _) =>
- ((1L + i) * a + b) % MinHashLSH.HASH_PRIME
- }.min.toDouble
+ if (elems.nonZeroIterator.isEmpty) {
+ Array.empty[Vector]
+ } else {
+ val hashValues = randCoefficients.map { case (a, b) =>
+ elems.nonZeroIterator.map { case (i, _) =>
+ ((1L + i) * a + b) % MinHashLSH.HASH_PRIME
+ }.min.toDouble
+ }
+ // TODO: Output vectors of dimension numHashFunctions in SPARK-18450
+ hashValues.map(Vectors.dense(_))
}
- // TODO: Output vectors of dimension numHashFunctions in SPARK-18450
- hashValues.map(Vectors.dense(_))
}
+
Review Comment:
Please remove the unnecessary whitespace only change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]