@Override
    public void reduce(
        PactString key, Iterator<PactString> tuples, Collector<PactNull, PactString> out) {
      boolean rank_tuple_found = false;
      boolean doc_tuple_found = false;

      PactString rank_tuple = new PactString();
      while (tuples.hasNext()) {
        PactString tuple = tuples.next();
        if (tuple.toString().split(Delimiter).length == 3) {
          rank_tuple_found = true;
          rank_tuple.setValue(tuple.getValue());
        } else if (tuple.toString().split(Delimiter).length == 2) {
          doc_tuple_found = true;
        }
      }

      if (rank_tuple_found && doc_tuple_found) {
        // emit the rank tuple
        out.collect(PactNull.getInstance(), rank_tuple);
      }
    }