[ 
https://issues.apache.org/jira/browse/SPARK-30075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16984760#comment-16984760
 ] 

Jungtaek Lim commented on SPARK-30075:
--------------------------------------

Working on the fix. Actually the fix is also available in 
[https://github.com/apache/spark/pull/25811|https://github.com/apache/spark/pull/25811/files]
 , but the review progress doesn't go fast enough, so I'm splitting out this 
fix from the PR.

> 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
>            Priority: Minor
>
> [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-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to