HBASE-940 Make the TableOutputFormat batching-aware

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@707784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2008-10-24 23:24:09 +00:00
parent ae1653c001
commit ce3e6ccdff
5 changed files with 23 additions and 4 deletions

View File

@ -65,6 +65,7 @@ Release 0.19.0 - Unreleased
SubString operator (Clint Morgan via Stack)
HBASE-937 Thrift getRow does not support specifying columns
(Doğacan Güney via Stack)
HBASE-940 Make the TableOutputFormat batching-aware
NEW FEATURES
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]

View File

@ -89,6 +89,17 @@ public class BatchUpdate implements WritableComparable<BatchUpdate>,
public BatchUpdate(final String row, long timestamp){
this(Bytes.toBytes(row), timestamp);
}
/**
* Recopy constructor
* @param buToCopy BatchUpdate to copy
*/
public BatchUpdate(BatchUpdate buToCopy) {
this(buToCopy.getRow(), buToCopy.getTimestamp());
for(BatchOperation bo : buToCopy) {
this.put(bo.getColumn(), bo.getValue());
}
}
/**
* Initialize a BatchUpdate operation on a row with a specific timestamp.

View File

@ -24,7 +24,8 @@ import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.io.BatchUpdate;import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.io.BatchUpdate;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

View File

@ -64,12 +64,17 @@ FileOutputFormat<ImmutableBytesWritable, BatchUpdate> {
}
public void close(@SuppressWarnings("unused") Reporter reporter) {
// Nothing to do.
try {
m_table.flushCommits();
}
catch(IOException ioe) {
LOG.error(ioe);
}
}
public void write(@SuppressWarnings("unused") ImmutableBytesWritable key,
BatchUpdate value) throws IOException {
m_table.commit(value);
m_table.commit(new BatchUpdate(value));
}
}
@ -91,6 +96,7 @@ FileOutputFormat<ImmutableBytesWritable, BatchUpdate> {
LOG.error(e);
throw e;
}
table.setAutoFlush(false);
return new TableRecordWriter(table);
}

View File

@ -135,7 +135,7 @@ public class TestTableMapReduce extends MultiRegionTable {
TableMapReduceUtil.initTableReduceJob(Bytes.toString(table.getTableName()),
IdentityTableReduce.class, jobConf);
LOG.info("Started " + table.getTableName());
LOG.info("Started " + Bytes.toString(table.getTableName()));
JobClient.runJob(jobConf);
LOG.info("After map/reduce completion");