You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean R. Owen (Jira)" <ji...@apache.org> on 2019/12/02 15:07:00 UTC

[jira] [Resolved] (SPARK-30075) ArrayIndexType doesn't implement hashCode correctly

     [ https://issues.apache.org/jira/browse/SPARK-30075?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sean R. Owen resolved SPARK-30075.
----------------------------------
    Fix Version/s: 3.0.0
       Resolution: Fixed

Issue resolved by pull request 26709
[https://github.com/apache/spark/pull/26709]

> ArrayIndexType doesn't implement hashCode correctly
> ---------------------------------------------------
>
>                 Key: SPARK-30075
>                 URL: https://issues.apache.org/jira/browse/SPARK-30075
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 2.4.4, 3.0.0
>            Reporter: Jungtaek Lim
>            Assignee: Jungtaek Lim
>            Priority: Minor
>             Fix For: 3.0.0
>
>
> [https://github.com/apache/spark/blob/master/common/kvstore/src/test/java/org/apache/spark/util/kvstore/ArrayKeyIndexType.java]
> {code:java}
> public class ArrayKeyIndexType {
>   @KVIndex
>   public int[] key;
>   @KVIndex("id")
>   public String[] id;  
>   @Override
>   public boolean equals(Object o) {
>     if (o instanceof ArrayKeyIndexType) {
>       ArrayKeyIndexType other = (ArrayKeyIndexType) o;
>       return Arrays.equals(key, other.key) && Arrays.equals(id, other.id);
>     }
>     return false;
>   }
>   @Override
>   public int hashCode() {
>     return key.hashCode();
>   }
> } {code}
> Here hashCode() simply calls key.hashCode() which won't work as our intention - as the implementation would be Object.hashCode(). We need to call Array.hashCode(key) instead.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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