You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/08/09 08:04:54 UTC
svn commit: r1155220 - in /hbase/trunk: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
Author: stack
Date: Tue Aug 9 06:04:54 2011
New Revision: 1155220
URL: http://svn.apache.org/viewvc?rev=1155220&view=rev
Log:
HBASE-4039 Users should be able to choose custom TableInputFormats without modifying TableMapReduceUtil.initTableMapperJob()
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1155220&r1=1155219&r2=1155220&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Aug 9 06:04:54 2011
@@ -380,6 +380,8 @@ Release 0.91.0 - Unreleased
HBASE-4017 BlockCache interface should be truly modular (Li Pi)
HBASE-4152 Rename o.a.h.h.regionserver.wal.WALObserver to
o.a.h.h.regionserver.wal.WALActionsListener
+ HBASE-4039 Users should be able to choose custom TableInputFormats without
+ modifying TableMapReduceUtil.initTableMapperJob() (Brock Noland)
NEW FEATURES
HBASE-2001 Coprocessors: Colocate user code with regions (Mingjie Lai via
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java?rev=1155220&r1=1155219&r2=1155220&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java Tue Aug 9 06:04:54 2011
@@ -45,6 +45,7 @@ import org.apache.hadoop.hbase.util.Byte
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.mapreduce.InputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.util.StringUtils;
@@ -119,9 +120,9 @@ public class TableMapReduceUtil {
Class<? extends TableMapper> mapper,
Class<? extends WritableComparable> outputKeyClass,
Class<? extends Writable> outputValueClass, Job job,
- boolean addDependencyJars)
+ boolean addDependencyJars, Class<? extends InputFormat> inputFormatClass)
throws IOException {
- job.setInputFormatClass(TableInputFormat.class);
+ job.setInputFormatClass(inputFormatClass);
if (outputValueClass != null) job.setMapOutputValueClass(outputValueClass);
if (outputKeyClass != null) job.setMapOutputKeyClass(outputKeyClass);
job.setMapperClass(mapper);
@@ -133,7 +134,33 @@ public class TableMapReduceUtil {
addDependencyJars(job);
}
}
-
+
+ /**
+ * Use this before submitting a TableMap job. It will appropriately set up
+ * the job.
+ *
+ * @param table Binary representation of the table name to read from.
+ * @param scan The scan instance with the columns, time range etc.
+ * @param mapper The mapper class to use.
+ * @param outputKeyClass The class of the output key.
+ * @param outputValueClass The class of the output value.
+ * @param job The current job to adjust. Make sure the passed job is
+ * carrying all necessary HBase configuration.
+ * @param addDependencyJars upload HBase jars and jars for any of the configured
+ * job classes via the distributed cache (tmpjars).
+ * @param inputFormatClass The class of the input format
+ * @throws IOException When setting up the details fails.
+ */
+ public static void initTableMapperJob(byte[] table, Scan scan,
+ Class<? extends TableMapper> mapper,
+ Class<? extends WritableComparable> outputKeyClass,
+ Class<? extends Writable> outputValueClass, Job job,
+ boolean addDependencyJars, Class<? extends InputFormat> inputFormatClass)
+ throws IOException {
+ initTableMapperJob(Bytes.toString(table), scan, mapper, outputKeyClass,
+ outputValueClass, job, addDependencyJars, inputFormatClass);
+ }
+
/**
* Use this before submitting a TableMap job. It will appropriately set up
* the job.
@@ -156,7 +183,32 @@ public class TableMapReduceUtil {
boolean addDependencyJars)
throws IOException {
initTableMapperJob(Bytes.toString(table), scan, mapper, outputKeyClass,
- outputValueClass, job, addDependencyJars);
+ outputValueClass, job, addDependencyJars, TableInputFormat.class);
+ }
+
+ /**
+ * Use this before submitting a TableMap job. It will appropriately set up
+ * the job.
+ *
+ * @param table The table name to read from.
+ * @param scan The scan instance with the columns, time range etc.
+ * @param mapper The mapper class to use.
+ * @param outputKeyClass The class of the output key.
+ * @param outputValueClass The class of the output value.
+ * @param job The current job to adjust. Make sure the passed job is
+ * carrying all necessary HBase configuration.
+ * @param addDependencyJars upload HBase jars and jars for any of the configured
+ * job classes via the distributed cache (tmpjars).
+ * @throws IOException When setting up the details fails.
+ */
+ public static void initTableMapperJob(String table, Scan scan,
+ Class<? extends TableMapper> mapper,
+ Class<? extends WritableComparable> outputKeyClass,
+ Class<? extends Writable> outputValueClass, Job job,
+ boolean addDependencyJars)
+ throws IOException {
+ initTableMapperJob(table, scan, mapper, outputKeyClass,
+ outputValueClass, job, addDependencyJars, TableInputFormat.class);
}
/**