Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-18555

Remove redundant familyMap.put() from addxxx() of sub-classes of Mutation and Query

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0, 2.0.0-alpha-2, 2.0.0
    • Component/s: Client
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      In addxxx() functions of Mutation(Append, Delete, Increment and Put) and Query(Get and Scan), there are redundant Map#put() calls which could be removed to improve the performance.

      For example, in Put#addColumn() and addImmutable(), after getting the cell list of the given family and add the cell into the list, the code puts (key=family, value=list) into familyMap.

      In addColumn(), it is like

          List<Cell> list = getCellList(family);
          KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
          list.add(kv);
          familyMap.put(CellUtil.cloneFamily(kv), list); // <-- here
          return this;
      

      In addImmutable(), it is like

          List<Cell> list = getCellList(family);
          KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag);
          list.add(kv);
          familyMap.put(family, list); // <-- here
          return this;
      

      I think those put() for Map only take effect when getCellList(family) returns a new allocated ArrayList. When the list for a family already exist, put() for Map will update the value to the reference of the list, but actually, the reference of the list is not changed.

      Those put() do not do any harm in terms of the correctness when they are here. But it could be removed to improve the performance. familyMap searches for key and set the new value and return the old value. Those operation take some time but actually are not needed.

      The put() could be moved into Mutation#getCellList(family)

        Attachments

        1. HBASE-18555.master.000.patch
          3 kB
          Xiang Li
        2. HBASE-18555.master.001.patch
          9 kB
          Xiang Li
        3. HBASE-18555.master.002.patch
          10 kB
          Xiang Li

          Issue Links

            Activity

              People

              • Assignee:
                xiangli Xiang Li
                Reporter:
                xiangli Xiang Li
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: