Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-4061

Use Default Value of 1 For UTF8 Hash

    XMLWordPrintableJSON

Details

    Description

          int h = hash;
          if (h == 0) {
            byte[] bytes = this.bytes;
            int length = this.length;
            for (int i = 0; i < length; i++) {
              h = h * 31 + bytes[i];
            }
            this.hash = h;
          }
      

      If this is an empty string, the value of "h" will always be zero, and therefore will not be cached correctly. An empty string will try to re-calculate the hash every time. Instead, make "h" default to 1 to avoid this condition. This change also makes the hash function equivalent to the JDK hash function.

      Attachments

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h
                1h