public void setOutputs(CliSessionState ss, OutputStream fo) throws Exception {
    // Normally, only one of PRESORT, SORT, HASH, SORT_N_HASH, should be present
    // in a file. If there are multiple then the code will pick one in the order
    // specified below. This ensures the behavior remains the same as before this
    // refactoring.
    // It would be better to throw an error than silently pick one and ignore the
    // rest but it is out of the scope of the current change. 
    if (operations.contains(Operation.SORT)) {
      ss.out = new SortPrintStream(fo, "UTF-8");
    } else if (operations.contains(Operation.HASH)) {
      ss.out = new DigestPrintStream(fo, "UTF-8");
    } else if (operations.contains(Operation.SORT_N_HASH)) {
      ss.out = new SortAndDigestPrintStream(fo, "UTF-8");
    } else {
      ss.out = new SessionStream(fo, true, "UTF-8");
    }
  }
Operations present in a given file/test.
itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestResultProcessor.java