Skip to content

Commit

Permalink
[Enhancement] Optimize IdChain hash code implement (#47599)
Browse files Browse the repository at this point in the history
The current implement of hashCode is easy to cause conflict. The data in the attachment takes 15 minutes to construct a HashMap<IdChain, IdChain> using the current hashCode implementation, but only takes a few seconds after changing to Arrays.hashCode().


[chain.json.tar.gz](https://github.com/user-attachments/files/16014242/chain.json.tar.gz)


Signed-off-by: gengjun-git <gengjun@starrocks.com>
  • Loading branch information
gengjun-git authored Jun 28, 2024
1 parent 445c8c2 commit d6bccdb
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

public class RestoreFileMapping implements Writable {
Expand Down Expand Up @@ -109,11 +110,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
int code = chain[0].hashCode();
for (int i = 1; i < 5; i++) {
code ^= chain[i].hashCode();
}
return code;
return Arrays.hashCode(chain);
}

@Override
Expand Down

0 comments on commit d6bccdb

Please sign in to comment.