HBASE-2185 HTable - put(Put) , put(List<Put) code duplication

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@908161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-02-09 19:20:01 +00:00
parent 74cc78ac2d
commit d32839d1a0
2 changed files with 17 additions and 7 deletions

View File

@ -348,6 +348,7 @@ Release 0.21.0 - Unreleased
(Lars Francke via Stack) (Lars Francke via Stack)
HBASE-2178 Hooks for replication HBASE-2178 Hooks for replication
HBASE-2180 Bad random read performance from synchronizing hfile.fddatainputstream 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 NEW FEATURES
HBASE-1961 HBase EC2 scripts HBASE-1961 HBase EC2 scripts

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.client;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -445,12 +446,7 @@ public class HTable implements HTableInterface {
* @since 0.20.0 * @since 0.20.0
*/ */
public synchronized void put(final Put put) throws IOException { public synchronized void put(final Put put) throws IOException {
validatePut(put); doPut(Arrays.asList(put));
writeBuffer.add(put);
currentWriteBufferSize += put.heapSize();
if(autoFlush || currentWriteBufferSize > writeBufferSize) {
flushCommits();
}
} }
/** /**
@ -462,6 +458,19 @@ public class HTable implements HTableInterface {
* @since 0.20.0 * @since 0.20.0
*/ */
public synchronized void put(final List<Put> puts) throws IOException { 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) { for (Put put : puts) {
validatePut(put); validatePut(put);
writeBuffer.add(put); writeBuffer.add(put);
@ -471,7 +480,7 @@ public class HTable implements HTableInterface {
flushCommits(); flushCommits();
} }
} }
/** /**
* Atomically increments a column value. If the column value already exists * Atomically increments a column value. If the column value already exists
* and is not a big-endian long, this could throw an exception.<p> * and is not a big-endian long, this could throw an exception.<p>