hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r908161 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/client/HTable.java
Date Tue, 09 Feb 2010 19:20:01 GMT
Author: stack
Date: Tue Feb  9 19:20:01 2010
New Revision: 908161

URL: http://svn.apache.org/viewvc?rev=908161&view=rev
Log:
HBASE-2185 HTable - put(Put) , put(List<Put) code duplication

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=908161&r1=908160&r2=908161&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Feb  9 19:20:01 2010
@@ -348,6 +348,7 @@
                (Lars Francke via Stack)
    HBASE-2178  Hooks for replication
    HBASE-2180  Bad random read performance from synchronizing hfile.fddatainputstream
+   HBASE-2194  HTable - put(Put) , put(List<Put) code duplication (Kay Kay via Stack)
 
   NEW FEATURES
    HBASE-1961  HBase EC2 scripts

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java?rev=908161&r1=908160&r2=908161&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java Tue Feb  9 19:20:01
2010
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -445,12 +446,7 @@
    * @since 0.20.0
    */
   public synchronized void put(final Put put) throws IOException {
-    validatePut(put);
-    writeBuffer.add(put);
-    currentWriteBufferSize += put.heapSize();
-    if(autoFlush || currentWriteBufferSize > writeBufferSize) {
-      flushCommits();
-    }
+    doPut(Arrays.asList(put));
   }
 
   /**
@@ -462,6 +458,19 @@
    * @since 0.20.0
    */
   public synchronized void put(final List<Put> puts) throws IOException {
+    doPut(puts);
+  }
+
+  /**
+   * Internal helper method. 
+   * Need to synchronize this instance to prevent race conditions on the internal 
+   * data structures.
+   * <p>
+   * If autoFlush is false, the update is buffered.
+   * @param puts
+   * @throws IOException
+   */
+  private  void doPut(final List<Put> puts) throws IOException {
     for (Put put : puts) {
       validatePut(put);
       writeBuffer.add(put);
@@ -471,7 +480,7 @@
       flushCommits();
     }
   }
-
+  
   /**
    * Atomically increments a column value. If the column value already exists
    * and is not a big-endian long, this could throw an exception.<p>



Mime
View raw message