Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-10528

OM: Concatenated keys are evil

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • OM

    Description

      Ozone Manager uses concatenated keys as table/cache keys. For instance, a key of the key_table is a result of: "/" + volume + "/" + "bucket" + "/" + key.

      That unnecessarily creates and throws away multiple significant string objects for every request, e.g volume keys, bucket keys, key keys. (Even volume keys are a concatenation of "/" + volume?).

      A simple composite key would eliminate the need for string concatenation, e.g. 

      public class KeyTableKey {
          private final String volume;
          private final String bucket;
          private final String key;
          privale final int hashCode;
          public KeyIdentifier(String volume, String bucket, String key) {
            this.volume = volume;
            this.bucket = bucket
            this.key = key;
            this.hashCode = volume.hashcode() * 31 * 31 + bucket.hashCode() * 31 + key.hashCode();
          }
          public boolean equals(Object other) {
            // return true if the components are equals
          }
          public int hashCode() {
             return hashCode;
          }
      }

      For backward compatibility, we can implement a KeyTableKeyCodec that generates the same binary as the concatenated content.

      Attachments

        Activity

          People

            Unassigned Unassigned
            duongnguyen Duong
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: