Skip to content

Commit 4c0fc1e

Browse files
HeartSaVioRattilapiros
authored andcommitted
[SPARK-30075][CORE][TESTS] Fix the hashCode implementation of ArrayKeyIndexType correctly
### What changes were proposed in this pull request? This patch fixes the bug on ArrayKeyIndexType.hashCode() as it is simply calling Array.hashCode() which in turn calls Object.hashCode(). That should be Arrays.hashCode() to reflect the elements in the array. ### Why are the changes needed? I've encountered the bug in apache#25811 while adding test codes for apache#25811, and I've split the fix into individual PR to speed up reviewing. Without this patch, ArrayKeyIndexType would bring various issues when it's used as type of collections. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? I've skipped adding UT as ArrayKeyIndexType is in test and the patch is pretty simple one-liner. Closes apache#26709 from HeartSaVioR/SPARK-30075. Authored-by: Jungtaek Lim (HeartSaVioR) <[email protected]> Signed-off-by: Sean Owen <[email protected]>
1 parent 831ad77 commit 4c0fc1e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

common/kvstore/src/test/java/org/apache/spark/util/kvstore/ArrayKeyIndexType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public boolean equals(Object o) {
3838

3939
@Override
4040
public int hashCode() {
41-
return key.hashCode();
41+
return Arrays.hashCode(key) ^ Arrays.hashCode(id);
4242
}
4343

4444
}

0 commit comments

Comments
 (0)