private static String getIdFromFilename(String filepath, boolean isPrefixed, boolean isTaskAttempt) {
    String filename = filepath;
    int dirEnd = filepath.lastIndexOf(Path.SEPARATOR);
    if (dirEnd != -1) {
      filename = filepath.substring(dirEnd + 1);
    }

    ParsedOutputFileName parsedOutputFileName = ParsedOutputFileName.parse(filename);
    String taskId;
    if (parsedOutputFileName.matches()) {
      if (isTaskAttempt) {
        taskId = parsedOutputFileName.getAttemptId();
      } else {
        taskId = isPrefixed ? parsedOutputFileName.getPrefixedTaskId() : parsedOutputFileName.getTaskId();
      }
    } else {
      taskId = filename;
      LOG.warn("Unable to get task id from file name: {}. Using last component {}"
          + " as task id.", filepath, taskId);
    }
    if (isTaskAttempt) {
      LOG.debug("TaskAttemptId for {} = {}", filepath, taskId);
    } else {
      LOG.debug("TaskId for {} = {}", filepath, taskId);
    }
    return taskId;
  }
Get the part-spec + task id from the filename. It is assumed that the filename is derived
from the output of getTaskId

@param filename
         filename to extract taskid from
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java