@InterfaceAudience.Public public class GroupingTableMapper extends TableMapper<ImmutableBytesWritable,Result> implements org.apache.hadoop.conf.Configurable
Modifier and Type | Field and Description |
---|---|
protected byte[][] |
columns
The grouping columns.
|
private org.apache.hadoop.conf.Configuration |
conf
The current configuration.
|
static String |
GROUP_COLUMNS
JobConf parameter to specify the columns used to produce the key passed to
collect from the map phase.
|
Constructor and Description |
---|
GroupingTableMapper() |
Modifier and Type | Method and Description |
---|---|
protected ImmutableBytesWritable |
createGroupKey(byte[][] vals)
Create a key by concatenating multiple column values.
|
protected byte[][] |
extractKeyValues(Result r)
Extract columns values from the current record.
|
org.apache.hadoop.conf.Configuration |
getConf()
Returns the current configuration.
|
static void |
initJob(String table,
Scan scan,
String groupColumns,
Class<? extends TableMapper> mapper,
org.apache.hadoop.mapreduce.Job job)
Use this before submitting a TableMap job.
|
void |
map(ImmutableBytesWritable key,
Result value,
org.apache.hadoop.mapreduce.Mapper.Context context)
Extract the grouping columns from value to construct a new key.
|
void |
setConf(org.apache.hadoop.conf.Configuration configuration)
Sets the configuration.
|
public static final String GROUP_COLUMNS
protected byte[][] columns
private org.apache.hadoop.conf.Configuration conf
public GroupingTableMapper()
public static void initJob(String table, Scan scan, String groupColumns, Class<? extends TableMapper> mapper, org.apache.hadoop.mapreduce.Job job) throws IOException
table
- The table to be processed.scan
- The scan with the columns etc.groupColumns
- A space separated list of columns used to form the
key used in collect.mapper
- The mapper class.job
- The current job.IOException
- When setting up the job fails.public void map(ImmutableBytesWritable key, Result value, org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException
map
in class org.apache.hadoop.mapreduce.Mapper<ImmutableBytesWritable,Result,ImmutableBytesWritable,Result>
key
- The current key.value
- The current value.context
- The current context.IOException
- When writing the record fails.InterruptedException
- When the job is aborted.protected byte[][] extractKeyValues(Result r)
Override this method if you want to deal with nulls differently.
r
- The current values.protected ImmutableBytesWritable createGroupKey(byte[][] vals)
Override this function in order to produce different types of keys.
vals
- The current key/values.public org.apache.hadoop.conf.Configuration getConf()
getConf
in interface org.apache.hadoop.conf.Configurable
Configurable.getConf()
public void setConf(org.apache.hadoop.conf.Configuration configuration)
setConf
in interface org.apache.hadoop.conf.Configurable
configuration
- The configuration to set.Configurable.setConf(
org.apache.hadoop.conf.Configuration)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.