Uploaded image for project: 'Parquet'
  1. Parquet
  2. PARQUET-1191

Type.hashCode() takes originalType into account but Type.equals() does not

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.10.0
    • None
    • None

    Description

      Taking originalType into account in Type.hashCode() but ignoring it in Type.equals() is inconsistent and violates hashCode-equals contract.

      If two Type instances that are equal according to equals() but have different logical types were ever put in a hash map, then both of the following cases are possible:

      • The two instances may accidentally have the same hash, which is consistent with the equals() method but is pure coincidence and has a very low probablility.
      • The two instances may have different hashes and end up in different buckets of a hash map, leading to a situation where we can't find a value in the hash map despite that it's equals() would return true.

      We should decide whether originalType is needed for an equality check or not. If it is, then it should be added to equals(). Otherwise it should be removed from hashCode().

      Attachments

        Issue Links

          Activity

            People

              nkollar Nándor Kollár
              gszadovszky Gabor Szadovszky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: