|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.mapred.lib.FieldSelectionMapReduce<K,V>
@InterfaceAudience.Public @InterfaceStability.Stable public class FieldSelectionMapReduce<K,V>
This class implements a mapper/reducer class that can be used to perform field selections in a manner similar to unix cut. The input data is treated as fields separated by a user specified separator (the default value is "\t"). The user can specify a list of fields that form the map output keys, and a list of fields that form the map output values. If the inputformat is TextInputFormat, the mapper will ignore the key to the map function. and the fields are from the value only. Otherwise, the fields are the union of those from the key and those from the value. The field separator is under attribute "mapreduce.fieldsel.data.field.separator" The map output field list spec is under attribute "mapreduce.fieldsel.map.output.key.value.fields.spec". The value is expected to be like "keyFieldsSpec:valueFieldsSpec" key/valueFieldsSpec are comma (,) separated field spec: fieldSpec,fieldSpec,fieldSpec ... Each field spec can be a simple number (e.g. 5) specifying a specific field, or a range (like 2-5) to specify a range of fields, or an open range (like 3-) specifying all the fields starting from field 3. The open range field spec applies value fields only. They have no effect on the key fields. Here is an example: "4,3,0,1:6,5,1-3,7-". It specifies to use fields 4,3,0 and 1 for keys, and use fields 6,5,1,2,3,7 and above for values. The reduce output field list spec is under attribute "mapreduce.fieldsel.reduce.output.key.value.fields.spec". The reducer extracts output key/value pairs in a similar manner, except that the key is never ignored.
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
LOG
|
Constructor Summary | |
---|---|
FieldSelectionMapReduce()
|
Method Summary | |
---|---|
void |
close()
|
void |
configure(JobConf job)
Initializes a new instance from a JobConf . |
void |
map(K key,
V val,
OutputCollector<Text,Text> output,
Reporter reporter)
The identify function. |
void |
reduce(Text key,
Iterator<Text> values,
OutputCollector<Text,Text> output,
Reporter reporter)
Reduces values for a given key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
public FieldSelectionMapReduce()
Method Detail |
---|
public void map(K key, V val, OutputCollector<Text,Text> output, Reporter reporter) throws IOException
map
in interface Mapper<K,V,Text,Text>
key
- the input key.val
- the input value.output
- collects mapped keys and values.reporter
- facility to report progress.
IOException
public void configure(JobConf job)
JobConfigurable
JobConf
.
configure
in interface JobConfigurable
job
- the configurationpublic void close() throws IOException
close
in interface Closeable
IOException
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text,Text> output, Reporter reporter) throws IOException
Reducer
The framework calls this method for each
<key, (list of values)>
pair in the grouped inputs.
Output values must be of the same type as input values. Input keys must
not be altered. The framework will reuse the key and value objects
that are passed into the reduce, therefore the application should clone
the objects they want to keep a copy of. In many cases, all values are
combined into zero or one value.
Output pairs are collected with calls to
OutputCollector.collect(Object,Object)
.
Applications can use the Reporter
provided to report progress
or just indicate that they are alive. In scenarios where the application
takes a significant amount of time to process individual key/value
pairs, this is crucial since the framework might assume that the task has
timed-out and kill that task. The other way of avoiding this is to set
mapreduce.task.timeout to a high-enough value (or even zero for no
time-outs).
reduce
in interface Reducer<Text,Text,Text,Text>
key
- the key.values
- the list of values to reduce.output
- to collect keys and combined values.reporter
- facility to report progress.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |