code: public synchronized static String getUniqueFile(TaskAttemptContext context,
                                                    String name,
                                                    String extension) {
      TaskID taskId = context.getTaskAttemptID().getTaskID();
      int partition = taskId.getId();
      StringBuilder result = new StringBuilder();
      result.append(name);
      result.append('-');
      result.append(taskId.isMap() ? 'm' : 'r');
      result.append('-');
      result.append(NUMBER_FORMAT.format(partition));
      result.append(extension);
      return result.toString();
    }
docs: Generate a unique filename, based on the task id, name, and extension
  @param context the task that is calling this
  @param name the base filename
  @param extension the filename extension
  @return a string like $name-[mr]-$id$extension