[
https://issues.apache.org/jira/browse/HDFS-9522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15075825#comment-15075825
]
John Zhuge commented on HDFS-9522:
----------------------------------
Thanks [~szetszwo] for the comments.
>> * if a class overrides equals, it must override hashCode
> Does the current code have this bug?
No. DiffReportEntry overrides both methods, so it is ok.
>> * when they are both overridden, equals and hashCode must use the same set
>> of fields
>> DiffReportEntry.equals() uses field "type", but DiffReportEntry.hashCode()
>> doesn't.
> equals() and hashCode() are still using the same set of fields. hashCode()
> just hashes any type to 1 and multiply it to the return value. No?
I wouldn't call that "use the field" if the hash of the field is always the
same. One small issue might arise: entries of different types (same values
in other fields) will be placed into the same hash table bucket, which will
degrade hash table performance.
> Cleanup o.a.h.hdfs.protocol.SnapshotDiffReport
> ----------------------------------------------
>
> Key: HDFS-9522
> URL: https://issues.apache.org/jira/browse/HDFS-9522
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: John Zhuge
> Assignee: John Zhuge
> Priority: Minor
> Attachments: HDFS-9522-001.patch
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> The current DiffReportEntry is a C-style tagged union-like data structure.
> Recommend subclass hierarchy as in Java idiom.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)