org.apache.hadoop.mapreduce

## Class TaskID

- java.lang.Object
- - org.apache.hadoop.mapreduce.ID
  - - org.apache.hadoop.mapred.ID
    - - org.apache.hadoop.mapreduce.TaskID

- All Implemented Interfaces:
    Comparable<ID>, Writable, WritableComparable<ID>
  Direct Known Subclasses:
    TaskID

      @InterfaceAudience.Public
       @InterfaceStability.Stable
      public class TaskID
      extends ID

  TaskID represents the immutable and unique identifier for a Map or Reduce Task. Each TaskID encompasses multiple attempts made to execute the Map or Reduce Task, each of which are uniquely indentified by their TaskAttemptID. TaskID consists of 3 parts. First part is the `JobID`, that this TaskInProgress belongs to. Second part of the TaskID is either 'm' or 'r' representing whether the task is a map task or a reduce task. And the third part is the task number.
  An example TaskID is : `task_200707121733_0003_m_000005` , which represents the fifth map task in the third job running at the jobtracker started at `200707121733`.

  Applications should never construct or parse TaskID strings , but rather use appropriate constructors or `forName(String)` method.

  See Also:
    `JobID`, `TaskAttemptID`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static NumberFormat` | `idFormat`
    `protected static String` | `TASK`
    `static String` | `TASK_ID_REGEX`
    `static Pattern` | `taskIdPattern`

    - ### Fields inherited from class org.apache.hadoop.mapreduce.ID

      `id, SEPARATOR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TaskID()` Default constructor for Writable.
    `TaskID(JobID jobId, boolean isMap, int id)` Deprecated.
    `TaskID(JobID jobId, TaskType type, int id)` Constructs a TaskID object from given `JobID`.
    `TaskID(String jtIdentifier, int jobId, boolean isMap, int id)` Deprecated.
    `TaskID(String jtIdentifier, int jobId, TaskType type, int id)` Constructs a TaskInProgressId object from given parts.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected StringBuilder` | `appendTo(StringBuilder builder)` Add the unique string to the given builder.
    `int` | `compareTo(ID o)` Compare TaskInProgressIds by first jobIds, then by tip numbers.
    `boolean` | `equals(Object o)`
    `static TaskID` | `forName(String str)` Construct a TaskID object from given string.
    `static String` | `getAllTaskTypes()` Returns a string of characters describing all possible `TaskType` values
    `JobID` | `getJobID()` Returns the `JobID` object that this tip belongs to.
    `static char` | `getRepresentingCharacter(TaskType type)` Gets the character representing the `TaskType`.
    `TaskType` | `getTaskType()` Get the type of the task.
    `static TaskType` | `getTaskType(char c)` Gets the `TaskType` corresponding to the character.
    `int` | `hashCode()`
    `boolean` | `isMap()` Deprecated.
    `void` | `readFields(DataInput in)` Deserialize the fields of this object from `in`.
    `String` | `toString()`
    `void` | `write(DataOutput out)` Serialize the fields of this object to `out`.

    - ### Methods inherited from class org.apache.hadoop.mapreduce.ID

      `getId`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TASK

          protected static final String TASK

      See Also:
        Constant Field Values

    - #### idFormat

          protected static final NumberFormat idFormat

    - #### TASK_ID_REGEX

          public static final String TASK_ID_REGEX

    - #### taskIdPattern

          public static final Pattern taskIdPattern

  - ### Constructor Detail

    - #### TaskID

          public TaskID(JobID jobId,
                        TaskType type,
                        int id)

      Constructs a TaskID object from given `JobID`.
      Parameters:
        `jobId` - JobID that this tip belongs to
        `type` - the `TaskType` of the task
        `id` - the tip number

    - #### TaskID

          public TaskID(String jtIdentifier,
                        int jobId,
                        TaskType type,
                        int id)

      Constructs a TaskInProgressId object from given parts.
      Parameters:
        `jtIdentifier` - jobTracker identifier
        `jobId` - job number
        `type` - the TaskType
        `id` - the tip number

    - #### TaskID

          @Deprecated
          public TaskID(JobID jobId,
                                    boolean isMap,
                                    int id)

      Deprecated.
      Constructs a TaskID object from given `JobID`.
      Parameters:
        `jobId` - JobID that this tip belongs to
        `isMap` - whether the tip is a map
        `id` - the tip number

    - #### TaskID

          @Deprecated
          public TaskID(String jtIdentifier,
                                    int jobId,
                                    boolean isMap,
                                    int id)

      Deprecated.
      Constructs a TaskInProgressId object from given parts.
      Parameters:
        `jtIdentifier` - jobTracker identifier
        `jobId` - job number
        `isMap` - whether the tip is a map
        `id` - the tip number

    - #### TaskID

          public TaskID()

      Default constructor for Writable. Sets the task type to `TaskType.REDUCE`, the ID to 0, and the job ID to an empty job ID.

  - ### Method Detail

    - #### getJobID

          public JobID getJobID()

      Returns the `JobID` object that this tip belongs to.
      Returns:
        the JobID object

    - #### isMap

          @Deprecated
          public boolean isMap()

      Deprecated.
      Returns whether this TaskID is a map ID.
      Returns:
        whether this TaskID is a map ID

    - #### getTaskType

          public TaskType getTaskType()

      Get the type of the task.
      Returns:
        the type of the task

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `ID`

    - #### compareTo

          public int compareTo(ID o)

      Compare TaskInProgressIds by first jobIds, then by tip numbers. Reducers are defined as greater than mappers.
      Specified by:
        `compareTo` in interface `Comparable<ID>`
      Overrides:
        `compareTo` in class `ID`
      Parameters:
        `o` - the TaskID against which to compare
      Returns:
        0 if equal, positive if this TaskID is greater, and negative if this TaskID is less

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `ID`

    - #### appendTo

          protected StringBuilder appendTo(StringBuilder builder)

      Add the unique string to the given builder.
      Parameters:
        `builder` - the builder to append to
      Returns:
        the builder that was passed in

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `ID`

    - #### readFields

          public void readFields(DataInput in)
                          throws IOException

      Description copied from interface: `Writable`
      Deserialize the fields of this object from `in`.

      For efficiency, implementations should attempt to re-use storage in the existing object where possible.

      Specified by:
        `readFields` in interface `Writable`
      Overrides:
        `readFields` in class `ID`
      Parameters:
        `in` - `DataInput` to deseriablize this object from.
      Throws:
        `IOException`

    - #### write

          public void write(DataOutput out)
                     throws IOException

      Description copied from interface: `Writable`
      Serialize the fields of this object to `out`.
      Specified by:
        `write` in interface `Writable`
      Overrides:
        `write` in class `ID`
      Parameters:
        `out` - `DataOuput` to serialize this object into.
      Throws:
        `IOException`

    - #### forName

          public static TaskID forName(String str)
                                throws IllegalArgumentException

      Construct a TaskID object from given string.
      Parameters:
        `str` - the target string
      Returns:
        constructed TaskID object or null if the given String is null
      Throws:
        `IllegalArgumentException` - if the given string is malformed

    - #### getRepresentingCharacter

          public static char getRepresentingCharacter(TaskType type)

      Gets the character representing the `TaskType`.
      Parameters:
        `type` - the TaskType
      Returns:
        the character

    - #### getTaskType

          public static TaskType getTaskType(char c)

      Gets the `TaskType` corresponding to the character.
      Parameters:
        `c` - the character
      Returns:
        the TaskType

    - #### getAllTaskTypes

          public static String getAllTaskTypes()

      Returns a string of characters describing all possible `TaskType` values
      Returns:
        a string of all task type characters

Copyright © 2022 Apache Software Foundation. All rights reserved.