title: Multiple for-each loops in Hadoop reducer
body: <p>I faced the problem of multiple for-each loops in Hadoop, is it even possible?</p>
  
  <p>What code I have now for reducer class:</p>
  
  <pre><code>public class R_PreprocessAllSMS extends Reducer&lt;Text, Text, Text, Text&gt;{
  private final static Text KEY = new Text();
  private final static Text VALUE = new Text();
  
      @Override
      public void reduce(Text key, Iterable&lt;Text&gt; values, Context context) throws IOException, InterruptedException {
          int sum = 0;
          for (Text value : values) {
              String[] splitString = value.toString().split("\t");
              sum += Integer.parseInt(splitString[1]);
          }
          if (sum &gt; 100) {
              for (Text value : values) {
                  String[] splitString = value.toString().split("\t");
                  System.out.println(key.toString() + splitString[0] + " " + splitString[1]);
                  KEY.set(key);
                  VALUE.set(splitString[0] + "\t" + splitString[1]);
                  context.write(KEY, VALUE);
              }
          }
      }
  }
  </code></pre>
  
  <p>But I want to have a possibility to search through given values for the second time and to emit those which we need. If it's not possible, what is the recommended way of doing that in Hadoop you'd advice?
  Thanks.</p>