Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.0
    • Component/s: None
    • Labels:
      None

      Description

      There are hash functions in Utilities.hash and Util.hash and spread throughout the code, e.g. in ColumnMetaData and ClassDeclaration (search for uses of Object.hashCode).

      Suggested improvements:

      • Some multiply by 37; I'm not sure that all CPUs can multiply by 37 in one instruction; switch to a mersenne prime (2 ^ n - 1).
      • Util.hash uses shift and xor. Change that to multiply by a prime.
      • Lists should continue to multiply by 31 to be consistent with java.util.List.
      • Deprecate Util.hash methods and use Utilities.hash instead.

      Changing hash functions may cause some test output to change; be prepared for that.

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.7.0 (2016-03-22).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.7.0 (2016-03-22).
        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/ecf4d6dc.

        Summary of changes:

        • Deprecate all Util.hashXxx functions;
        • Add a few hash functions to Utilities;
        • Change as many implementations of hashCode as I could to use java.util.Objects.hash (we prefer it over Guava's Objects.hashCode);
        • Change code to use java.util.Objects.equals (we prefer it over Guava's Objects.equal);
        • Make sure that classes that implement Map.Entry have a hashCode that complies with the contract;
        • Change hash functions in Utilities to use 31 as their prime, to be consistent with Objects.hash.
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/ecf4d6dc . Summary of changes: Deprecate all Util.hashXxx functions; Add a few hash functions to Utilities ; Change as many implementations of hashCode as I could to use java.util.Objects.hash (we prefer it over Guava's Objects.hashCode); Change code to use java.util.Objects.equals (we prefer it over Guava's Objects.equal); Make sure that classes that implement Map.Entry have a hashCode that complies with the contract; Change hash functions in Utilities to use 31 as their prime, to be consistent with Objects.hash .

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development