spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkbradley <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-7140][MLLIB] only scan the first 16 non...
Date Sat, 25 Apr 2015 23:39:27 GMT
Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5697#discussion_r29105224
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala ---
    @@ -63,20 +63,27 @@ sealed trait Vector extends Serializable {
                 Vectors.equals(0 until d1.size, d1.values, s1.indices, s1.values)
               case (_, _) => util.Arrays.equals(this.toArray, v2.toArray)
             }
    -      }
           case _ => false
         }
       }
     
    +  /**
    +   * Returns a hash code value for the vector. The hash code is based on its size and
its nonzeros
    +   * in the first 16 entries, using a hash algorithm similar to [[java.util.Arrays.hashCode]].
    +   */
       override def hashCode(): Int = {
    -    var result: Int = size + 31
    -    this.foreachActive { case (index, value) =>
    -      // ignore explict 0 for comparison between sparse and dense
    -      if (value != 0) {
    -        result = 31 * result + index
    -        // refer to {@link java.util.Arrays.equals} for hash algorithm
    -        val bits = java.lang.Double.doubleToLongBits(value)
    -        result = 31 * result + (bits ^ (bits >>> 32)).toInt
    +    // This is a reference implementation. It calls return in foreachActive, which is
slow.
    +    var result: Int = 31 + size
    +    this.foreachActive { (index, value) =>
    +      if (index < 16) {
    +        // ignore explict 0 for comparison between sparse and dense
    --- End diff --
    
    typo: "explicit"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message