Package org.apache.hadoop.hbase.mapred
Class GroupingTableMap
java.lang.Object
org.apache.hadoop.mapred.MapReduceBase
org.apache.hadoop.hbase.mapred.GroupingTableMap
- All Implemented Interfaces:
Closeable
,AutoCloseable
,TableMap<ImmutableBytesWritable,
,Result> org.apache.hadoop.io.Closeable
,org.apache.hadoop.mapred.JobConfigurable
,org.apache.hadoop.mapred.Mapper<ImmutableBytesWritable,
Result, ImmutableBytesWritable, Result>
@Public
public class GroupingTableMap
extends org.apache.hadoop.mapred.MapReduceBase
implements TableMap<ImmutableBytesWritable,Result>
Extract grouping columns from input record
-
Field Summary
Modifier and TypeFieldDescriptionprotected byte[][]
static final String
JobConf parameter to specify the columns used to produce the key passed to collect from the map phase -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(org.apache.hadoop.mapred.JobConf job) protected ImmutableBytesWritable
createGroupKey
(byte[][] vals) Create a key by concatenating multiple column values.protected byte[][]
Extract columns values from the current record.static void
initJob
(String table, String columns, String groupColumns, Class<? extends TableMap> mapper, org.apache.hadoop.mapred.JobConf job) Use this before submitting a TableMap job.void
map
(ImmutableBytesWritable key, Result value, org.apache.hadoop.mapred.OutputCollector<ImmutableBytesWritable, Result> output, org.apache.hadoop.mapred.Reporter reporter) Extract the grouping columns from value to construct a new key.Methods inherited from class org.apache.hadoop.mapred.MapReduceBase
close
-
Field Details
-
GROUP_COLUMNS
JobConf parameter to specify the columns used to produce the key passed to collect from the map phase- See Also:
-
columns
-
-
Constructor Details
-
GroupingTableMap
public GroupingTableMap()
-
-
Method Details
-
initJob
public static void initJob(String table, String columns, String groupColumns, Class<? extends TableMap> mapper, org.apache.hadoop.mapred.JobConf job) Use this before submitting a TableMap job. It will appropriately set up the JobConf.- Parameters:
table
- table to be processedcolumns
- space separated list of columns to fetchgroupColumns
- space separated list of columns used to form the key used in collectmapper
- map classjob
- job configuration object
-
configure
- Specified by:
configure
in interfaceorg.apache.hadoop.mapred.JobConfigurable
- Overrides:
configure
in classorg.apache.hadoop.mapred.MapReduceBase
-
map
public void map(ImmutableBytesWritable key, Result value, org.apache.hadoop.mapred.OutputCollector<ImmutableBytesWritable, Result> output, org.apache.hadoop.mapred.Reporter reporter) throws IOExceptionExtract the grouping columns from value to construct a new key. Pass the new key and value to reduce. If any of the grouping columns are not found in the value, the record is skipped.- Specified by:
map
in interfaceorg.apache.hadoop.mapred.Mapper<ImmutableBytesWritable,
Result, ImmutableBytesWritable, Result> - Throws:
IOException
-
extractKeyValues
Extract columns values from the current record. This method returns null if any of the columns are not found. Override this method if you want to deal with nulls differently.- Returns:
- array of byte values
-
createGroupKey
Create a key by concatenating multiple column values. Override this function in order to produce different types of keys.- Returns:
- key generated by concatenating multiple column values
-