title: Hadoop multiple inputs
body: <p>I am using hadoop map reduce and I want to compute two files. My first Map/Reduce iteration is giving me an a file with a pair ID number like this:</p>
  
  <pre><code>A 30
  D 20
  </code></pre>
  
  <p>My goal is to use that ID from the file to associate with another file and have another output with a trio: ID, Number, Name, like this:</p>
  
  <pre><code>A ABC 30
  D EFGH 20
  </code></pre>
  
  <p>But I am not sure whether using Map Reduce is the best way to do this. Would it be better for example to use a File Reader to Read the second input file and get the Name by ID? Or can I do it with Map Reduce? </p>
  
  <p>If so, I'm trying to find out how. I tried a MultipleInput solution:</p>
  
  <pre><code>MultipleInputs.addInputPath(job2, new Path(args[1]+"-tmp"),
      TextInputFormat.class, FlightsByCarrierMapper2.class);
  MultipleInputs.addInputPath(job2, new Path("inputplanes"),
      TextInputFormat.class, FlightsModeMapper.class); 
  </code></pre>
  
  <p>But I can't think of any solution to combine the two and get the output I want. The way I have right now is just giving me the list like this example:</p>
  
  <pre><code>A ABC
  A 30
  B ABCD
  C ABCDEF
  D EFGH
  D 20
  </code></pre>
  
  <p>After my Last Reduce I am getting this:</p>
  
  <pre><code>N125DL  767-332
  N125DL  7   , 
  N126AT  737-76N
  N126AT  19  , 
  N126DL  767-332
  N126DL  1   , 
  N127DL  767-332
  N127DL  7   , 
  N128DL  767-332
  N128DL  3
  </code></pre>
  
  <p>I want this: N127DL 7 767-332. And also, I don't want the ones which do not combine. </p>
  
  <p>And this is my reduce class:</p>
  
  <p>public class FlightsByCarrierReducer2 extends Reducer {</p>
  
  <pre><code>String merge = "";
  protected void reduce(Text token, Iterable&lt;Text&gt; values, Context context) 
                              throws IOException, InterruptedException {
  
      int i = 0;  
      for(Text value:values)
      {
          if(i == 0){
              merge = value.toString()+",";
          }
          else{
              merge += value.toString();
          }
          i++;
      }
  
          context.write(token, new Text(merge));
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Update:</strong></p>
  
  <p><a href="http://stat-computing.org/dataexpo/2009/the-data.html" rel="noreferrer">http://stat-computing.org/dataexpo/2009/the-data.html</a> this is the example I'm using. </p>
  
  <p>I'm trying with: TailNum and Cancelled which is (1 or 0) get the model name that corresponds to the TailNum. My file with model has a TailNumb, Model and other stuff. My current output is:</p>
  
  <p>N193JB ERJ 190-100 IGW </p>
  
  <p>N194DN 767-332 </p>
  
  <p>N19503 EMB-135ER  </p>
  
  <p>N19554 EMB-145LR </p>
  
  <p>N195DN 767-332 </p>
  
  <p>N195DN 2</p>
  
  <p>First comes the key, second the model, the keys that has flights cancelled, apperas below the model </p>
  
  <p>And I would like a trio Key,Model Number of Cancelled, Because I want number of Cancellations per model</p>