TaskID extends org.apache.hadoop.mapred.ID { @Override public int hashCode() { return jobId.hashCode() * 524287 + id; } TaskID(JobID jobId, TaskType type, int id);  TaskID(String jtIdentifier, int jobId, TaskType type, int id); @Deprecated  TaskID(JobID jobId, boolean isMap, int id); @Deprecated  TaskID(String jtIdentifier, int jobId, boolean isMap, int id);  TaskID(); JobID getJobID(); @Deprecated boolean isMap(); TaskType getTaskType(); @Override boolean equals(Object o); @Override int compareTo(ID o); @Override String toString(); @Override int hashCode(); @Override void readFields(DataInput in); @Override void write(DataOutput out); static TaskID forName(String str); static char getRepresentingCharacter(TaskType type); static TaskType getTaskType(char c); static String getAllTaskTypes(); static final String TASK_ID_REGEX; static final Pattern taskIdPattern; }
@Test public void testHashCode() { TaskType[] types = TaskType.values(); for (int i = 0; i < types.length; i++) { JobID jobId = new JobID("1234" + i, i); TaskID taskId1 = new TaskID(jobId, types[i], i); TaskID taskId2 = new TaskID(jobId, types[i], i); assertTrue("The hashcode() method gave unequal hash codes for two equal " + "task IDs", taskId1.hashCode() == taskId2.hashCode()); } }