hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkey...@apache.org
Subject svn commit: r1457939 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Date Mon, 18 Mar 2013 19:44:54 GMT
Author: nkeywal
Date: Mon Mar 18 19:44:53 2013
New Revision: 1457939

URL: http://svn.apache.org/r1457939
Log:
HBASE-8128 HTable#put improvements

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HTable.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1457939&r1=1457938&r2=1457939&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HTable.java Mon Mar 18
19:44:53 2013
@@ -114,7 +114,6 @@ public class HTable implements HTableInt
   private ExecutorService pool;  // For Multi
   private boolean closed;
   private int operationTimeout;
-  private static final int DOPUT_WB_CHECK = 10;    // i.e., doPut checks the writebuffer
every X Puts.
   private final boolean cleanupPoolOnClose; // shutdown the pool in close()
   private final boolean cleanupConnectionOnClose; // close the connection in close()
 
@@ -746,7 +745,10 @@ public class HTable implements HTableInt
    */
   @Override
   public void put(final Put put) throws IOException {
-    doPut(Arrays.asList(put));
+    doPut(put);
+    if (autoFlush) {
+      flushCommits();
+    }
   }
 
   /**
@@ -754,23 +756,19 @@ public class HTable implements HTableInt
    */
   @Override
   public void put(final List<Put> puts) throws IOException {
-    doPut(puts);
-  }
-
-  private void doPut(final List<Put> puts) throws IOException {
-    int n = 0;
     for (Put put : puts) {
-      validatePut(put);
-      writeBuffer.add(put);
-      currentWriteBufferSize += put.heapSize();
-     
-      // we need to periodically see if the writebuffer is full instead of waiting until
the end of the List
-      n++;
-      if (n % DOPUT_WB_CHECK == 0 && currentWriteBufferSize > writeBufferSize)
{
-        flushCommits();
-      }
+      doPut(put);
+    }
+    if (autoFlush) {
+      flushCommits();
     }
-    if (autoFlush || currentWriteBufferSize > writeBufferSize) {
+  }
+
+  private void doPut(Put put) throws IOException{
+    validatePut(put);
+    writeBuffer.add(put);
+    currentWriteBufferSize += put.heapSize();
+    if (currentWriteBufferSize > writeBufferSize) {
       flushCommits();
     }
   }



Mime
View raw message