org.apache.hadoop.mapred
Class OutputFormatBase

java.lang.Object
  extended by org.apache.hadoop.mapred.OutputFormatBase
All Implemented Interfaces:
OutputFormat
Direct Known Subclasses:
MapFileOutputFormat, SequenceFileOutputFormat, TextOutputFormat

public abstract class OutputFormatBase
extends Object
implements OutputFormat

A base class for OutputFormat.


Constructor Summary
OutputFormatBase()
           
 
Method Summary
 void checkOutputSpecs(FileSystem ignored, JobConf job)
          Check whether the output specification for a job is appropriate.
static boolean getCompressOutput(JobConf conf)
          Is the reduce output compressed?
static Class getOutputCompressorClass(JobConf conf, Class defaultValue)
          Get the codec for compressing the reduce outputs
abstract  RecordWriter getRecordWriter(FileSystem ignored, JobConf job, String name, Progressable progress)
          Construct a RecordWriter with Progressable.
static void setCompressOutput(JobConf conf, boolean val)
          Set whether the output of the reduce is compressed
static void setOutputCompressorClass(JobConf conf, Class codecClass)
          Set the given class as the output compression codec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputFormatBase

public OutputFormatBase()
Method Detail

setCompressOutput

public static void setCompressOutput(JobConf conf,
                                     boolean val)
Set whether the output of the reduce is compressed

Parameters:
val - the new setting

getCompressOutput

public static boolean getCompressOutput(JobConf conf)
Is the reduce output compressed?

Returns:
true, if the output should be compressed

setOutputCompressorClass

public static void setOutputCompressorClass(JobConf conf,
                                            Class codecClass)
Set the given class as the output compression codec.

Parameters:
conf - the JobConf to modify
codecClass - the CompressionCodec class that will compress the reduce outputs

getOutputCompressorClass

public static Class getOutputCompressorClass(JobConf conf,
                                             Class defaultValue)
Get the codec for compressing the reduce outputs

Parameters:
conf - the Configuration to look in
defaultValue - the value to return if it is not set
Returns:
the CompressionCodec class that should be used to compress the reduce outputs
Throws:
IllegalArgumentException - if the class was specified, but not found

getRecordWriter

public abstract RecordWriter getRecordWriter(FileSystem ignored,
                                             JobConf job,
                                             String name,
                                             Progressable progress)
                                      throws IOException
Description copied from interface: OutputFormat
Construct a RecordWriter with Progressable.

Specified by:
getRecordWriter in interface OutputFormat
job - the job whose output is being written
name - the unique name for this part of the output
progress - mechanism for reporting progress while writing to file
Returns:
a RecordWriter
Throws:
IOException

checkOutputSpecs

public void checkOutputSpecs(FileSystem ignored,
                             JobConf job)
                      throws FileAlreadyExistsException,
                             InvalidJobConfException,
                             IOException
Description copied from interface: OutputFormat
Check whether the output specification for a job is appropriate. Called when a job is submitted. Typically checks that it does not already exist, throwing an exception when it already exists, so that output is not overwritten.

Specified by:
checkOutputSpecs in interface OutputFormat
job - the job whose output will be written
Throws:
IOException - when output should not be attempted
FileAlreadyExistsException
InvalidJobConfException


Copyright © 2006 The Apache Software Foundation