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

MultiAction.add creates unnecessary temporary objects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 2.0.0
    • None
    • Client
    • None

    Description

      MultiAction class:

        /**
         * Add an Action to this container based on it's regionName. If the regionName
         * is wrong, the initial execution will fail, but will be automatically
         * retried after looking up the correct region.
         *
         * @param regionName
         * @param a
         */
        public void add(byte[] regionName, Action<R> a) {
          add(regionName, Arrays.asList(a));
        }
      
        /**
         * Add an Action to this container based on it's regionName. If the regionName
         * is wrong, the initial execution will fail, but will be automatically
         * retried after looking up the correct region.
         *
         * @param regionName
         * @param actionList list of actions to add for the region
         */
        public void add(byte[] regionName, List<Action<R>> actionList){
          List<Action<R>> rsActions = actions.get(regionName);
          if (rsActions == null) {
            rsActions = new ArrayList<Action<R>>(actionList.size());
            actions.put(regionName, rsActions);
          }
          rsActions.addAll(actionList);
        }
      

      Avoid Arrays.asList(a) and Collection.addAll - they create temporary garbage

      Attachments

        1. HBASE-15501-v1.patch
          1 kB
          Vladimir Rodionov

        Issue Links

          Activity

            People

              vrodionov Vladimir Rodionov
              vrodionov Vladimir Rodionov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: