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

Ted Yu commented on FLINK-9393:
-------------------------------

The tricky part is about the hostnames member which has an accessor:
{code}
  public String[] getHostnames() {
    return this.hostnames;
{code}
In the context of instance of this class used as key to some Map, if some user 
of some instance of this class happens to change the member of the array, 
thereby changing the hash code / equals, the Map entry would not be found on 
the subsequent lookup (by checking the wrong bin).

Another downside is higher collision rate since instances with different host 
names may hash to the same value.

It will be more error prone than abiding by the contract between hashCode and 
equals. We should fix the methods to follow the contract as there really isn't 
any harm in doing it correctly, and avoiding weird surprises. 

> LocatableInputSplit#hashCode should take hostnames into account
> ---------------------------------------------------------------
>
>                 Key: FLINK-9393
>                 URL: https://issues.apache.org/jira/browse/FLINK-9393
>             Project: Flink
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Assignee: vinoyang
>            Priority: Major
>
> Currently:
> {code}
>   public int hashCode() {
>     return this.splitNumber;
> {code}
> This is not symmetrical with {{equals}} method where hostnames are compared.
> LocatableInputSplit#hashCode should take hostnames into account.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to