Xushaohong commented on a change in pull request #3121:
URL: https://github.com/apache/ozone/pull/3121#discussion_r812542472
##########
File path:
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/EpochEntry.java
##########
@@ -64,7 +64,8 @@ public int hashCode() {
@Override
public int compareTo(Object o) {
if (this.epoch == ((EpochEntry<?>)o).epoch) {
- return 0;
+ return Integer.compare(
+ this.cachekey.hashCode(), ((EpochEntry<?>) o).cachekey.hashCode());
Review comment:
> This one looks much better. Note `hashCode` may be equal for different
`cachekey`s, so we may still run into the original problem, only with lower
probability.
I think the possibility is negligible, but to eliminate it, we could have a
twice hash check?
How about hash the cachekey and then EpochEntry ?
public int compareTo(Object o) {
if(this.epoch == ((EpochEntry<?>)o).epoch) {
int temp = Integer.compare(
this.cachekey.hashCode(), ((EpochEntry<?>) o).cachekey.hashCode());
return temp == 0 ? Integer.compare(this.hashCode(), o.hashCode()) :
temp;
} else if (this.epoch < ((EpochEntry<?>)o).epoch) {
return -1;
} else {
return 1;
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]