org.apache.hadoop.mapreduce
Class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>

java.lang.Object
  extended by org.apache.hadoop.mapreduce.JobContext
      extended by org.apache.hadoop.mapreduce.TaskAttemptContext
          extended by org.apache.hadoop.mapreduce.TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
              extended by org.apache.hadoop.mapreduce.ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
Type Parameters:
KEYIN - the class of the input keys
VALUEIN - the class of the input values
KEYOUT - the class of the output keys
VALUEOUT - the class of the output values
All Implemented Interfaces:
Progressable
Direct Known Subclasses:
Reducer.Context

public class ReduceContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
extends TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>

The context passed to the Reducer.


Nested Class Summary
protected  class ReduceContext.ValueIterable
           
protected  class ReduceContext.ValueIterator
           
 
Field Summary
protected  Progressable reporter
           
 
Fields inherited from class org.apache.hadoop.mapreduce.JobContext
CACHE_ARCHIVES_VISIBILITIES, CACHE_FILE_VISIBILITIES, COMBINE_CLASS_ATTR, conf, credentials, INPUT_FORMAT_CLASS_ATTR, JOB_ACL_MODIFY_JOB, JOB_ACL_VIEW_JOB, JOB_CANCEL_DELEGATION_TOKEN, JOB_NAMENODES, MAP_CLASS_ATTR, OUTPUT_FORMAT_CLASS_ATTR, PARTITIONER_CLASS_ATTR, REDUCE_CLASS_ATTR, ugi, USER_LOG_RETAIN_HOURS
 
Constructor Summary
ReduceContext(Configuration conf, TaskAttemptID taskid, RawKeyValueIterator input, Counter inputKeyCounter, Counter inputValueCounter, RecordWriter<KEYOUT,VALUEOUT> output, OutputCommitter committer, StatusReporter reporter, RawComparator<KEYIN> comparator, Class<KEYIN> keyClass, Class<VALUEIN> valueClass)
           
 
Method Summary
 KEYIN getCurrentKey()
          Get the current key.
 VALUEIN getCurrentValue()
          Get the current value.
 Iterable<VALUEIN> getValues()
          Iterate through the values for the current key, reusing the same value object, which is stored in the context.
 boolean nextKey()
          Start processing next unique key.
 boolean nextKeyValue()
          Advance to the next key/value pair.
 
Methods inherited from class org.apache.hadoop.mapreduce.TaskInputOutputContext
getCounter, getCounter, getOutputCommitter, getProgress, progress, setStatus, write
 
Methods inherited from class org.apache.hadoop.mapreduce.TaskAttemptContext
getStatus, getTaskAttemptID
 
Methods inherited from class org.apache.hadoop.mapreduce.JobContext
getCombinerClass, getConfiguration, getCredentials, getGroupingComparator, getInputFormatClass, getJar, getJobID, getJobName, getMapOutputKeyClass, getMapOutputValueClass, getMapperClass, getNumReduceTasks, getOutputFormatClass, getOutputKeyClass, getOutputValueClass, getPartitionerClass, getReducerClass, getSortComparator, getWorkingDirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reporter

protected Progressable reporter
Constructor Detail

ReduceContext

public ReduceContext(Configuration conf,
                     TaskAttemptID taskid,
                     RawKeyValueIterator input,
                     Counter inputKeyCounter,
                     Counter inputValueCounter,
                     RecordWriter<KEYOUT,VALUEOUT> output,
                     OutputCommitter committer,
                     StatusReporter reporter,
                     RawComparator<KEYIN> comparator,
                     Class<KEYIN> keyClass,
                     Class<VALUEIN> valueClass)
              throws InterruptedException,
                     IOException
Throws:
InterruptedException
IOException
Method Detail

nextKey

public boolean nextKey()
                throws IOException,
                       InterruptedException
Start processing next unique key.

Throws:
IOException
InterruptedException

nextKeyValue

public boolean nextKeyValue()
                     throws IOException,
                            InterruptedException
Advance to the next key/value pair.

Specified by:
nextKeyValue in class TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
Returns:
the key object that was read into, or null if no more
Throws:
IOException
InterruptedException

getCurrentKey

public KEYIN getCurrentKey()
Description copied from class: TaskInputOutputContext
Get the current key.

Specified by:
getCurrentKey in class TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
Returns:
the current key object or null if there isn't one

getCurrentValue

public VALUEIN getCurrentValue()
Description copied from class: TaskInputOutputContext
Get the current value.

Specified by:
getCurrentValue in class TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
Returns:
the value object that was read into

getValues

public Iterable<VALUEIN> getValues()
                            throws IOException,
                                   InterruptedException
Iterate through the values for the current key, reusing the same value object, which is stored in the context.

Returns:
the series of values associated with the current key. All of the objects returned directly and indirectly from this method are reused.
Throws:
IOException
InterruptedException


Copyright © 2009 The Apache Software Foundation