org.apache.hadoop.contrib.utils.join
Class DataJoinMapperBase

java.lang.Object
  extended by org.apache.hadoop.contrib.utils.join.JobBase
      extended by org.apache.hadoop.contrib.utils.join.DataJoinMapperBase
All Implemented Interfaces:
Closeable, JobConfigurable, Mapper, Reducer

public abstract class DataJoinMapperBase
extends JobBase

This abstract class serves as the base class for the mapper class of a data join job. This class expects its subclasses to implement methods for the following functionalities: 1. Compute the source tag of input values 2. Compute the map output value object 3. Compute the map output key object The source tag will be used by the reducer to determine from which source (which table in SQL terminology) a value comes. Computing the map output value object amounts to performing projecting/filtering work in a SQL statement (through the select/where clauses). Computing the map output key amounts to choosing the join key. This class provides the appropriate plugin points for the user defined subclasses to implement the appropriate logic.


Field Summary
protected  String inputFile
           
protected  Text inputTag
           
protected  JobConf job
           
protected  Reporter reporter
           
 
Fields inherited from class org.apache.hadoop.contrib.utils.join.JobBase
LOG
 
Constructor Summary
DataJoinMapperBase()
           
 
Method Summary
 void close()
          Called after the last call to any other method on this object to free and/or flush resources.
 void configure(JobConf job)
          Initializes a new instance from a JobConf.
protected abstract  Text generateGroupKey(TaggedMapOutput aRecord)
          Generate a map output key.
protected abstract  Text generateInputTag(String inputFile)
          Determine the source tag based on the input file name.
protected abstract  TaggedMapOutput generateTaggedMapOutput(Writable value)
          Generate a tagged map output value.
 void map(WritableComparable key, Writable value, OutputCollector output, Reporter reporter)
          Maps a single input key/value pair into intermediate key/value pairs.
 void reduce(WritableComparable arg0, Iterator arg1, OutputCollector arg2, Reporter arg3)
          Combines values for a given key.
 
Methods inherited from class org.apache.hadoop.contrib.utils.join.JobBase
addDoubleValue, addLongValue, getDoubleValue, getLongValue, getReport, report, setDoubleValue, setLongValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputFile

protected String inputFile

job

protected JobConf job

inputTag

protected Text inputTag

reporter

protected Reporter reporter
Constructor Detail

DataJoinMapperBase

public DataJoinMapperBase()
Method Detail

configure

public void configure(JobConf job)
Description copied from class: JobBase
Initializes a new instance from a JobConf.

Specified by:
configure in interface JobConfigurable
Overrides:
configure in class JobBase
Parameters:
job - the configuration

generateInputTag

protected abstract Text generateInputTag(String inputFile)
Determine the source tag based on the input file name.

Parameters:
inputFile -
Returns:
the source tag computed from the given file name.

generateTaggedMapOutput

protected abstract TaggedMapOutput generateTaggedMapOutput(Writable value)
Generate a tagged map output value. The user code can also perform projection/filtering. If it decides to discard the input record when certain conditions are met,it can simply return a null.

Parameters:
value -
Returns:
an object of TaggedMapOutput computed from the given value.

generateGroupKey

protected abstract Text generateGroupKey(TaggedMapOutput aRecord)
Generate a map output key. The user code can compute the key programmatically, not just selecting the values of some fields. In this sense, it is more general than the joining capabilities of SQL.

Parameters:
aRecord -
Returns:
the group key for the given record

map

public void map(WritableComparable key,
                Writable value,
                OutputCollector output,
                Reporter reporter)
         throws IOException
Description copied from interface: Mapper
Maps a single input key/value pair into intermediate key/value pairs. Output pairs need not be of the same types as input pairs. A given input pair may map to zero or many output pairs. Output pairs are collected with calls to OutputCollector.collect(WritableComparable,Writable).

Parameters:
key - the key
value - the values
output - collects mapped keys and values
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: Closeable
Called after the last call to any other method on this object to free and/or flush resources. Typical implementations do nothing.

Throws:
IOException

reduce

public void reduce(WritableComparable arg0,
                   Iterator arg1,
                   OutputCollector arg2,
                   Reporter arg3)
            throws IOException
Description copied from interface: Reducer
Combines values for a given key. Output values must be of the same type as input values. Input keys must not be altered. Typically all values are combined into zero or one value. Output pairs are collected with calls to OutputCollector.collect(WritableComparable,Writable).

Parameters:
arg0 - the key
arg1 - the values to combine
arg2 - to collect combined values
Throws:
IOException


Copyright © 2006 The Apache Software Foundation