@InterfaceAudience.Public @InterfaceStability.Stable public class GroupingTableMapper extends TableMapper<ImmutableBytesWritable,Result>
| Modifier and Type | Field and Description |
|---|---|
protected byte[][] |
columns
The grouping columns.
|
static java.lang.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.
|
Configuration |
getConf()
Returns the current configuration.
|
static void |
initJob(java.lang.String table,
Scan scan,
java.lang.String groupColumns,
java.lang.Class<? extends TableMapper> mapper,
Job job)
Use this before submitting a TableMap job.
|
void |
map(ImmutableBytesWritable key,
Result value,
Context context)
Extract the grouping columns from value to construct a new key.
|
void |
setConf(Configuration configuration)
Sets the configuration.
|
public static final java.lang.String GROUP_COLUMNS
protected byte[][] columns
public static void initJob(java.lang.String table,
Scan scan,
java.lang.String groupColumns,
java.lang.Class<? extends TableMapper> mapper,
Job job)
throws java.io.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.java.io.IOException - When setting up the job fails.public void map(ImmutableBytesWritable key, Result value, Context context) throws java.io.IOException, java.lang.InterruptedException
key - The current key.value - The current value.context - The current context.java.io.IOException - When writing the record fails.java.lang.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 Configuration getConf()
org.apache.hadoop.conf.Configurable#getConf()public void setConf(Configuration configuration)
configuration - The configuration to set.org.apache.hadoop.conf.Configurable#setConf(
org.apache.hadoop.conf.Configuration)