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

Improve multiop performances in HTable#flushCommits

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.95.2
    • 0.95.0
    • Client
    • None

    Description

      This code:

        @Override
        public void flushCommits() throws IOException {
          try {
            Object[] results = new Object[writeBuffer.size()];
            try {
              this.connection.processBatch(writeBuffer, tableName, pool, results);
            } catch (InterruptedException e) {
              throw new IOException(e);
            } finally {
              // mutate list so that it is empty for complete success, or contains
              // only failed records results are returned in the same order as the
              // requests in list walk the list backwards, so we can remove from list
              // without impacting the indexes of earlier members
              for (int i = results.length - 1; i>=0; i--) {
                if (results[i] instanceof Result) {
                  // successful Puts are removed from the list here.
                  writeBuffer.remove(i);
                }
              }
            }
          } finally {
            if (clearBufferOnFail) {
              writeBuffer.clear();
              currentWriteBufferSize = 0;
            } else {
              // the write buffer was adjusted by processBatchOfPuts
              currentWriteBufferSize = 0;
              for (Put aPut : writeBuffer) {
                currentWriteBufferSize += aPut.heapSize();
              }
            }
          }
        }
      

      Can be improved by:

      • not iterating on the list if clearBufferOnFail is set
      • not iterating the the list of there are no error
      • iterating on the list only once instead of two when we really have to.

      Attachments

        Issue Links

          Activity

            People

              nkeywal Nicolas Liochon
              nkeywal Nicolas Liochon
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: