Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7189#discussion_r33826234
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/InternalRow.scala ---
    @@ -91,31 +91,42 @@ abstract class InternalRow extends Row {
     
       // Custom hashCode function that matches the efficient code generated 
version.
       override def hashCode: Int = {
    -    var result: Int = 37
    -    var i = 0
    -    while (i < length) {
    -      val update: Int =
    -        if (isNullAt(i)) {
    -          0
    -        } else {
    -          apply(i) match {
    -            case b: Boolean => if (b) 0 else 1
    -            case b: Byte => b.toInt
    -            case s: Short => s.toInt
    -            case i: Int => i
    -            case l: Long => (l ^ (l >>> 32)).toInt
    -            case f: Float => java.lang.Float.floatToIntBits(f)
    -            case d: Double =>
    -              val b = java.lang.Double.doubleToLongBits(d)
    -              (b ^ (b >>> 32)).toInt
    -            case a: Array[Byte] => java.util.Arrays.hashCode(a)
    -            case other => other.hashCode()
    -          }
    +    def hashCode(v: Any): Int = v match {
    +      case null => 0
    +      case b: Boolean => if (b) 0 else 1
    +      case b: Byte => b.toInt
    +      case s: Short => s.toInt
    +      case i: Int => i
    +      case l: Long => (l ^ (l >>> 32)).toInt
    +      case f: Float => java.lang.Float.floatToIntBits(f)
    +      case d: Double =>
    +        val b = java.lang.Double.doubleToLongBits(d)
    +        (b ^ (b >>> 32)).toInt
    --- End diff --
    
    This should match with the codegen version. It's good to avoid boxing in 
codegen.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to