[
https://issues.apache.org/jira/browse/HIVE-10621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexander Pivovarov updated HIVE-10621:
---
Description:
correct equals method implementation should start with
{code}
if (this == other) {
return true;
}
if (other == null || getClass() != other.getClass()) {
return false;
}
{code}
DecimalTypeInfo, PrimitiveTypeInfo, VarcharTypeInfo, CharTypeInfo,
HiveDecimalWritable equals method implementation starts with
{code}
if (other == null || !(other instanceof class_name)) {
return false
}
{code}
- first of all check for null is redundant
- the second issue is that other instanceof class_name check is not
symmetric.
contract of equals() implies that, a.equals(b) is true if and only if
b.equals(a) is true
Current implementation violates this contract.
e.g.
DecimalTypeInfo instanceof PrimitiveTypeInfo is true
but
PrimitiveTypeInfo instanceof DecimalTypeInfo is false
See more details here
http://stackoverflow.com/questions/6518534/equals-method-overrides-equals-in-superclass-and-may-not-be-symmetric
serde typeinfo equals methods are not symmetric
---
Key: HIVE-10621
URL: https://issues.apache.org/jira/browse/HIVE-10621
Project: Hive
Issue Type: Bug
Components: Serializers/Deserializers
Reporter: Alexander Pivovarov
Assignee: Alexander Pivovarov
Priority: Minor
correct equals method implementation should start with
{code}
if (this == other) {
return true;
}
if (other == null || getClass() != other.getClass()) {
return false;
}
{code}
DecimalTypeInfo, PrimitiveTypeInfo, VarcharTypeInfo, CharTypeInfo,
HiveDecimalWritable equals method implementation starts with
{code}
if (other == null || !(other instanceof class_name)) {
return false
}
{code}
- first of all check for null is redundant
- the second issue is that other instanceof class_name check is not
symmetric.
contract of equals() implies that, a.equals(b) is true if and only if
b.equals(a) is true
Current implementation violates this contract.
e.g.
DecimalTypeInfo instanceof PrimitiveTypeInfo is true
but
PrimitiveTypeInfo instanceof DecimalTypeInfo is false
See more details here
http://stackoverflow.com/questions/6518534/equals-method-overrides-equals-in-superclass-and-may-not-be-symmetric
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)