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, org.apache.hadoop.mapred.JobConfigurable, org.apache.hadoop.mapred.Mapper, org.apache.hadoop.mapred.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  org.apache.hadoop.io.Text inputTag
           
protected  org.apache.hadoop.mapred.JobConf job
           
protected  org.apache.hadoop.mapred.Reporter reporter
           
 
Fields inherited from class org.apache.hadoop.contrib.utils.join.JobBase
LOG
 
Constructor Summary
DataJoinMapperBase()
           
 
Method Summary
 void close()
           
 void configure(org.apache.hadoop.mapred.JobConf job)
          Initializes a new instance from a JobConf.
protected abstract  org.apache.hadoop.io.Text generateGroupKey(TaggedMapOutput aRecord)
          Generate a map output key.
protected abstract  org.apache.hadoop.io.Text generateInputTag(String inputFile)
          Determine the source tag based on the input file name.
protected abstract  TaggedMapOutput generateTaggedMapOutput(Object value)
          Generate a tagged map output value.
 void map(Object key, Object value, org.apache.hadoop.mapred.OutputCollector output, org.apache.hadoop.mapred.Reporter reporter)
           
 void reduce(Object arg0, Iterator arg1, org.apache.hadoop.mapred.OutputCollector arg2, org.apache.hadoop.mapred.Reporter arg3)
           
 
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 org.apache.hadoop.mapred.JobConf job

inputTag

protected org.apache.hadoop.io.Text inputTag

reporter

protected org.apache.hadoop.mapred.Reporter reporter
Constructor Detail

DataJoinMapperBase

public DataJoinMapperBase()
Method Detail

configure

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

Specified by:
configure in interface org.apache.hadoop.mapred.JobConfigurable
Overrides:
configure in class JobBase
Parameters:
job - the configuration

generateInputTag

protected abstract org.apache.hadoop.io.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(Object 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 org.apache.hadoop.io.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(Object key,
                Object value,
                org.apache.hadoop.mapred.OutputCollector output,
                org.apache.hadoop.mapred.Reporter reporter)
         throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException

reduce

public void reduce(Object arg0,
                   Iterator arg1,
                   org.apache.hadoop.mapred.OutputCollector arg2,
                   org.apache.hadoop.mapred.Reporter arg3)
            throws IOException
Throws:
IOException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.