TaskID extends org.apache.hadoop.mapred.ID { @Override public void readFields(DataInput in) throws IOException { super.readFields(in); jobId.readFields(in); type = WritableUtils.readEnum(in, TaskType.class); } 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 testReadFields() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); out.writeInt(0); out.writeInt(1); WritableUtils.writeVInt(out, 4); out.write(new byte[] {0x31, 0x32, 0x33, 0x34}); WritableUtils.writeEnum(out, TaskType.REDUCE); DataInputByteBuffer in = new DataInputByteBuffer(); in.reset(ByteBuffer.wrap(baos.toByteArray())); TaskID instance = new TaskID(); instance.readFields(in); assertEquals("The readFields() method did not produce the expected task ID", "task_1234_0001_r_000000", instance.toString()); }