[
https://issues.apache.org/jira/browse/FLINK-2633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14734631#comment-14734631
]
ASF GitHub Bot commented on FLINK-2633:
---------------------------------------
Github user tillrohrmann commented on the pull request:
https://github.com/apache/flink/pull/1104#issuecomment-138519198
+1 for `hashCode()`, `equals()` and `toString()` abstract. But also for
introducing `canEqual` as proposed by Martin Odersky
(https://www.artima.com/lejava/articles/equality.html). The reason is that we
currently have the odd behaviour that the `equals` method of `TypleTypeInfo`
and `TupleTypeInfoBase` is not an equality relation (reflexive, symmetric,
transitive, consistent). The following code demonstrates this:
```
TupleTypeInfo<Tuple1<Integer>> tupleTypeInfo = new
TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO);
TupleTypeInfoBase<Tuple1> anonymousTupleTypeInfo = new
TupleTypeInfoBase<Tuple1>((Class<Tuple1>)Tuple1.class,
(TypeInformation<?>)BasicTypeInfo.INT_TYPE_INFO) {
@Override
public TypeSerializer<Tuple1> createSerializer(ExecutionConfig config) {
return null;
}
@Override
protected void initializeNewComparator(int localKeyCount) {}
@Override
protected void addCompareField(int fieldId, TypeComparator<?>
comparator) {}
@Override
protected TypeComparator<Tuple1> getNewComparator(ExecutionConfig
config) {
return null;
}
@Override
public String[] getFieldNames() {
return new String[0];
}
@Override
public int getFieldIndex(String fieldName) {
return 0;
}
};
System.out.println(tupleTypeInfo.equals(anonymousTupleTypeInfo)); // false
System.out.println(anonymousTupleTypeInfo.equals(tupleTypeInfo)); // true
```
Thus, the symmetric condition is violated.
This should actually be the norm for all future equality implementation,
IMHO.
> OptionTypeInfo does not have proper equals and hashCode method
> --------------------------------------------------------------
>
> Key: FLINK-2633
> URL: https://issues.apache.org/jira/browse/FLINK-2633
> Project: Flink
> Issue Type: Bug
> Reporter: Till Rohrmann
> Assignee: Till Rohrmann
>
> The {{OptionTypeInfo}} does not have a proper {{equals}} and {{hashCode}}
> definition. As a consequence, types which contain an option type won't be
> detected to be equal even though the element type of the option is identical.
> This can cause problems when you try to union two data sets of type
> {{DataSet[Option[Int]]}}, for example.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)