This project has retired. For details please refer to its Attic page.
MRPipeline (Apache Crunch 0.4.0-incubating API)

org.apache.crunch.impl.mr
Class MRPipeline

java.lang.Object
  extended by org.apache.crunch.impl.mr.MRPipeline
All Implemented Interfaces:
Pipeline

public class MRPipeline
extends Object
implements Pipeline

Pipeline implementation that is executed within Hadoop MapReduce.


Constructor Summary
MRPipeline(Class<?> jarClass)
          Instantiate with a default Configuration and name.
MRPipeline(Class<?> jarClass, org.apache.hadoop.conf.Configuration conf)
          Instantiate with a custom configuration and default naming.
MRPipeline(Class<?> jarClass, String name)
          Instantiate with a custom pipeline name.
MRPipeline(Class<?> jarClass, String name, org.apache.hadoop.conf.Configuration conf)
          Instantiate with a custom name and configuration.
 
Method Summary
<T> SourceTarget<T>
createIntermediateOutput(PType<T> ptype)
           
 org.apache.hadoop.fs.Path createTempPath()
           
 PipelineResult done()
          Run any remaining jobs required to generate outputs and then clean up any intermediate data files that were created in this run or previous calls to run.
 void enableDebug()
          Turn on debug logging for jobs that are run from this pipeline.
 org.apache.hadoop.conf.Configuration getConfiguration()
          Returns the Configuration instance associated with this pipeline.
<T> ReadableSourceTarget<T>
getMaterializeSourceTarget(PCollection<T> pcollection)
          Retrieve a ReadableSourceTarget that provides access to the contents of a PCollection.
 String getName()
          Returns the name of this pipeline.
 int getNextAnonymousStageId()
           
<T> Iterable<T>
materialize(PCollection<T> pcollection)
          Create the given PCollection and read the data it contains into the returned Collection instance for client use.
 org.apache.crunch.impl.mr.exec.MRExecutor plan()
           
<S> PCollection<S>
read(Source<S> source)
          Converts the given Source into a PCollection that is available to jobs run using this Pipeline instance.
<K,V> PTable<K,V>
read(TableSource<K,V> source)
          A version of the read method for TableSource instances that map to PTables.
 PCollection<String> readTextFile(String pathName)
          A convenience method for reading a text file.
 PipelineResult run()
          Constructs and executes a series of MapReduce jobs in order to write data to the output targets.
 void setConfiguration(org.apache.hadoop.conf.Configuration conf)
          Set the Configuration to use with this pipeline.
 void write(PCollection<?> pcollection, Target target)
          Write the given collection to the given target on the next pipeline run.
<T> void
writeTextFile(PCollection<T> pcollection, String pathName)
          A convenience method for writing a text file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MRPipeline

public MRPipeline(Class<?> jarClass)
Instantiate with a default Configuration and name.

Parameters:
jarClass - Class containing the main driver method for running the pipeline

MRPipeline

public MRPipeline(Class<?> jarClass,
                  String name)
Instantiate with a custom pipeline name. The name will be displayed in the Hadoop JobTracker.

Parameters:
jarClass - Class containing the main driver method for running the pipeline
name - Display name of the pipeline

MRPipeline

public MRPipeline(Class<?> jarClass,
                  org.apache.hadoop.conf.Configuration conf)
Instantiate with a custom configuration and default naming.

Parameters:
jarClass - Class containing the main driver method for running the pipeline
conf - Configuration to be used within all MapReduce jobs run in the pipeline

MRPipeline

public MRPipeline(Class<?> jarClass,
                  String name,
                  org.apache.hadoop.conf.Configuration conf)
Instantiate with a custom name and configuration. The name will be displayed in the Hadoop JobTracker.

Parameters:
jarClass - Class containing the main driver method for running the pipeline
name - Display name of the pipeline
conf - Configuration to be used within all MapReduce jobs run in the pipeline
Method Detail

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Description copied from interface: Pipeline
Returns the Configuration instance associated with this pipeline.

Specified by:
getConfiguration in interface Pipeline

setConfiguration

public void setConfiguration(org.apache.hadoop.conf.Configuration conf)
Description copied from interface: Pipeline
Set the Configuration to use with this pipeline.

Specified by:
setConfiguration in interface Pipeline

plan

public org.apache.crunch.impl.mr.exec.MRExecutor plan()

run

public PipelineResult run()
Description copied from interface: Pipeline
Constructs and executes a series of MapReduce jobs in order to write data to the output targets.

Specified by:
run in interface Pipeline

done

public PipelineResult done()
Description copied from interface: Pipeline
Run any remaining jobs required to generate outputs and then clean up any intermediate data files that were created in this run or previous calls to run.

Specified by:
done in interface Pipeline

read

public <S> PCollection<S> read(Source<S> source)
Description copied from interface: Pipeline
Converts the given Source into a PCollection that is available to jobs run using this Pipeline instance.

Specified by:
read in interface Pipeline
Parameters:
source - The source of data
Returns:
A PCollection that references the given source

read

public <K,V> PTable<K,V> read(TableSource<K,V> source)
Description copied from interface: Pipeline
A version of the read method for TableSource instances that map to PTables.

Specified by:
read in interface Pipeline
Parameters:
source - The source of the data
Returns:
A PTable that references the given source

readTextFile

public PCollection<String> readTextFile(String pathName)
Description copied from interface: Pipeline
A convenience method for reading a text file.

Specified by:
readTextFile in interface Pipeline

write

public void write(PCollection<?> pcollection,
                  Target target)
Description copied from interface: Pipeline
Write the given collection to the given target on the next pipeline run.

Specified by:
write in interface Pipeline
Parameters:
pcollection - The collection
target - The output target

materialize

public <T> Iterable<T> materialize(PCollection<T> pcollection)
Description copied from interface: Pipeline
Create the given PCollection and read the data it contains into the returned Collection instance for client use.

Specified by:
materialize in interface Pipeline
Parameters:
pcollection - The PCollection to materialize
Returns:
the data from the PCollection as a read-only Collection

getMaterializeSourceTarget

public <T> ReadableSourceTarget<T> getMaterializeSourceTarget(PCollection<T> pcollection)
Retrieve a ReadableSourceTarget that provides access to the contents of a PCollection. This is primarily intended as a helper method to materialize(PCollection). The underlying data of the ReadableSourceTarget may not be actually present until the pipeline is run.

Parameters:
pcollection - The collection for which the ReadableSourceTarget is to be retrieved
Returns:
The ReadableSourceTarget
Throws:
IllegalArgumentException - If no ReadableSourceTarget can be retrieved for the given PCollection

createIntermediateOutput

public <T> SourceTarget<T> createIntermediateOutput(PType<T> ptype)

createTempPath

public org.apache.hadoop.fs.Path createTempPath()

writeTextFile

public <T> void writeTextFile(PCollection<T> pcollection,
                              String pathName)
Description copied from interface: Pipeline
A convenience method for writing a text file.

Specified by:
writeTextFile in interface Pipeline

getNextAnonymousStageId

public int getNextAnonymousStageId()

enableDebug

public void enableDebug()
Description copied from interface: Pipeline
Turn on debug logging for jobs that are run from this pipeline.

Specified by:
enableDebug in interface Pipeline

getName

public String getName()
Description copied from interface: Pipeline
Returns the name of this pipeline.

Specified by:
getName in interface Pipeline
Returns:
Name of the pipeline


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.