<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>X-Combinator &#187; java</title>
	<atom:link href="http://www.xcombinator.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xcombinator.com</link>
	<description>making the human scalable</description>
	<lastBuildDate>Mon, 06 Sep 2010 20:18:14 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to use a raw MapReduce job in Cascading</title>
		<link>http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/</link>
		<comments>http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 22:31:18 +0000</pubDate>
		<dc:creator>Nate Murray</dc:creator>
				<category><![CDATA[cascading]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://xcombinator.local/?p=135</guid>
		<description><![CDATA[Cascading is a great abstraction over MapReduce.
However, sometimes you may have code for an existing MapReduce job or want to drop directly to Hadoop for efficiency. Even if you&#8217;re using raw MapReduce jobs, Cascading can still be useful in planning the overall data pipeline. 
The code below is an example of how to use a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cascading.org/">Cascading</a> is a great abstraction over MapReduce.</p>
<p>However, sometimes you may have code for an existing MapReduce job or want to drop directly to Hadoop for efficiency. Even if you&#8217;re using raw MapReduce jobs, Cascading can still be useful in planning the overall data pipeline. </p>
<p>The code below is an example of how to use a raw MapReduce job in a Cascade. The main thing to take away is that we are creating intermediate sinks and sources and relying on Cascading to schedule the flows in the correct order.</p>
<blockquote class="normal">
<p>NOTE: this code below depends on commit <a href="http://github.com/jashmenn/cascading/commit/f0dd84cd89da70c326e7285034e982c33d2d7388">f0dd84cd</a> which is a patch to MapReduceFlow.java that allows you to specifically set the Taps for a MapReduceFlow. I&#8217;ve contacted Chris about integrating this into the trunk. </p>
<p>Also note this patch applies to the branch <code>wip-1.1</code> and later.</p>
</blockquote>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.xcombinator.hadoopjobs.mapreducetest</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.cascade.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.Flow</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.FlowConnector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.flow.MapReduceFlow</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.aggregator.Count</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.regex.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.pipe.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.scheme.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tap.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.tuple.Fields</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Identity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Properties</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.conf.Configuration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.conf.Configured</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.io.LongWritable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.io.Text</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.FileInputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.FileOutputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.JobConf</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.TextInputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.TextOutputFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.lib.IdentityMapper</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.lib.IdentityReducer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.util.Tool</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.util.ToolRunner</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">cascading.operation.Debug</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.hadoop.mapred.KeyValueTextInputFormat</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * An example file to use a raw MapReduce job in cascading
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #000000; font-weight: bold;">extends</span> Configured <span style="color: #000000; font-weight: bold;">implements</span> Tool
  <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger LOG <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span> Main.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> run<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    JobConf conf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JobConf<span style="color: #009900;">&#40;</span>getConf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Properties</span> properties <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FlowConnector.<span style="color: #006633;">setApplicationJarClass</span><span style="color: #009900;">&#40;</span>properties, <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    CascadeConnector cascadeConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CascadeConnector<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    FlowConnector flowConnector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FlowConnector<span style="color: #009900;">&#40;</span>properties<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">String</span> inputPath  <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> outputPath <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> intermediatePath1 <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-mr-input&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> intermediatePath2 <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-mr-output&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    Scheme textLineScheme <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextLine<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Tap sourceTap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, inputPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap intermediateTap1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> TextLine<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>, intermediatePath1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap intermediateTap2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, intermediatePath2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Tap sinkTap   <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hfs<span style="color: #009900;">&#40;</span>textLineScheme, outputPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our first flow, sink to the intermediateTap</span>
    Pipe wsPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wordsplit&quot;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> RegexSplitGenerator<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>s+&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Flow parsedLogFlow <span style="color: #339933;">=</span> flowConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>sourceTap, intermediateTap1, wsPipe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create a pipe and set our mr job for it </span>
    Pipe importPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pipe<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mr pipe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    JobConf mrconf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JobConf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mrconf.<span style="color: #006633;">setJobName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;custom mr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    mrconf.<span style="color: #006633;">setOutputKeyClass</span><span style="color: #009900;">&#40;</span>LongWritable.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mrconf.<span style="color: #006633;">setOutputValueClass</span><span style="color: #009900;">&#40;</span>Text.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// the IdentityMapper, in this case, will actually output the key, which is</span>
    <span style="color: #666666; font-style: italic;">// a long of offset in bytes. Not what we'd usually want, but we'll leave</span>
    <span style="color: #666666; font-style: italic;">// it in for now.</span>
    mrconf.<span style="color: #006633;">setMapperClass</span><span style="color: #009900;">&#40;</span>IdentityMapper.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    mrconf.<span style="color: #006633;">setReducerClass</span><span style="color: #009900;">&#40;</span>IdentityReducer.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// note that your input is straight text-lines. This means in a real mr job</span>
    <span style="color: #666666; font-style: italic;">// you'd most likely need to split the line by some convention</span>
    TextInputFormat format <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TextInputFormat<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    format.<span style="color: #006633;">configure</span><span style="color: #009900;">&#40;</span>mrconf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// NOTE: this is both here and in the MapReduceFlow below</span>
    FileInputFormat.<span style="color: #006633;">setInputPaths</span><span style="color: #009900;">&#40;</span>mrconf, intermediateTap1.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
    FileOutputFormat.<span style="color: #006633;">setOutputPath</span><span style="color: #009900;">&#40;</span>mrconf, intermediateTap2.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// likewise</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our second flow, this one is for the mrjob. Notice source and sink taps</span>
    Flow mrFlow <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MapReduceFlow<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mrflow&quot;</span>, 
      mrconf, intermediateTap1, intermediateTap2, <span style="color: #000066; font-weight: bold;">false</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create our third &quot;regular&quot; cascading pipe</span>
    Pipe countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pipe<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;count&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// b/c our IdentityMapper is emitting long of offset in the line, just</span>
    <span style="color: #666666; font-style: italic;">// strip that out. You wouldn't have to do this if you had a smarter Mapper</span>
    <span style="color: #666666; font-style: italic;">// class.</span>
    countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Each<span style="color: #009900;">&#40;</span>countPipe, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> RegexParser<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;.*?<span style="color: #000099; font-weight: bold;">\\</span>t(.*)&quot;</span><span style="color: #009900;">&#41;</span>, 
        <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroupBy<span style="color: #009900;">&#40;</span>countPipe, <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    countPipe <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Every<span style="color: #009900;">&#40;</span>countPipe, <span style="color: #000000; font-weight: bold;">new</span> Count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Fields<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;count&quot;</span>, <span style="color: #0000ff;">&quot;word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create the flow for the last count pipe</span>
    Flow countFlow <span style="color: #339933;">=</span> flowConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>intermediateTap2, sinkTap, countPipe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    Cascade cascade <span style="color: #339933;">=</span> cascadeConnector.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>parsedLogFlow, mrFlow, countFlow<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cascade.<span style="color: #006633;">complete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// if you want to get rid of the intermediate files you </span>
    <span style="color: #666666; font-style: italic;">// could do something like the following here:</span>
    <span style="color: #666666; font-style: italic;">// Path tmp = tap.getPath();</span>
    <span style="color: #666666; font-style: italic;">// FileSystem fs = tmp.getFileSystem(conf);</span>
    <span style="color: #666666; font-style: italic;">// fs.delete(tmp, true);</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> 
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">int</span> res <span style="color: #339933;">=</span> ToolRunner.<span style="color: #006633;">run</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Configuration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Share:</p>
<p>	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;title=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading&amp;notes=Cascading%20is%20a%20great%20abstraction%20over%20MapReduce.%0D%0A%0D%0AHowever%2C%20sometimes%20you%20may%20have%20code%20for%20an%20existing%20MapReduce%20job%20or%20want%20to%20drop%20directly%20to%20Hadoop%20for%20efficiency.%20Even%20if%20you%27re%20using%20raw%20MapReduce%20jobs%2C%20Cascading%20can%20still%20be%20useful%20in%20planni" title="del.icio.us"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;title=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading" title="Reddit"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F" title="Technorati"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://twitter.com/home?status=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading%20-%20http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F" title="Twitter"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;t=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading" title="Facebook"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;title=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading&amp;annotation=Cascading%20is%20a%20great%20abstraction%20over%20MapReduce.%0D%0A%0D%0AHowever%2C%20sometimes%20you%20may%20have%20code%20for%20an%20existing%20MapReduce%20job%20or%20want%20to%20drop%20directly%20to%20Hadoop%20for%20efficiency.%20Even%20if%20you%27re%20using%20raw%20MapReduce%20jobs%2C%20Cascading%20can%20still%20be%20useful%20in%20planni" title="Google Bookmarks"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;t=How%20to%20use%20a%20raw%20MapReduce%20job%20in%20Cascading" title="HackerNews"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/hackernews.png" title="HackerNews" alt="HackerNews" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.xcombinator.com%2F2009%2F11%2F11%2Fhow-to-use-a-raw-mapreduce-job-in-cascading%2F&amp;partner=sociable" title="PDF"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a><br />
	<a rel="nofollow"  href="http://www.xcombinator.com/feed/" title="RSS"><img src="http://www.xcombinator.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></p>
<p><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xcombinator.com/2009/11/11/how-to-use-a-raw-mapreduce-job-in-cascading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.587 seconds -->
