这个异常大概是这样

    Error: java.lang.RuntimeException: java.io.EOFException
            at org.apache.hadoop.io.WritableComparator.compare(WritableComparator.java:165)
            at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.compare(MapTask.java:1283)
            at org.apache.hadoop.util.QuickSort.fix(QuickSort.java:35)
            at org.apache.hadoop.util.QuickSort.sortInternal(QuickSort.java:87)
            at org.apache.hadoop.util.QuickSort.sort(QuickSort.java:63)
            at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.sortAndSpill(MapTask.java:1625)
            at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(MapTask.java:1505)
            at org.apache.hadoop.mapred.MapTask$NewOutputCollector.close(MapTask.java:735)
            at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:805)
            at org.apache.hadoop.mapred.MapTask.run(MapTask.java:347)
            at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:174)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Subject.java:422)
            at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1682)
            at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:168)
    Caused by: java.io.EOFException
            at java.io.DataInputStream.readFully(DataInputStream.java:197)
            at java.io.DataInputStream.readUTF(DataInputStream.java:609)
            at java.io.DataInputStream.readUTF(DataInputStream.java:564)
            at compare.Salary.readFields(Salary.java:73)
            at org.apache.hadoop.io.WritableComparator.compare(WritableComparator.java:158)
            ... 14 more

原因:

@Override
public void write(DataOutput dataOutput) throws IOException {
    dataOutput.write(this.empno);
    dataOutput.writeUTF(this.ename);
    dataOutput.writeUTF(this.job);
    dataOutput.write(this.mgr);
    dataOutput.writeUTF(this.hiredate);
    dataOutput.write(this.sal);
    dataOutput.write(this.comm);
    dataOutput.write(this.deptno);
}
@Override
public void readFields(DataInput dataInput) throws IOException {
    this.empno = dataInput.readInt();
    this.ename = dataInput.readUTF();
    this.job = dataInput.readUTF();
    this.mgr = dataInput.readInt();
    this.hiredate = dataInput.readUTF();
    this.sal = dataInput.readInt();
    this.comm = dataInput.readInt();
    this.deptno = dataInput.readInt();
}

read的时候用的是readInt

Reads four input bytes and returns an int value. Let a-d be the first through fourth bytes read. The value returned is:

,读四个字节,write的时候呢用的write-。-
Writes to the output stream the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
写一个字节,这个导致的异常,解决办法呢把write换成writeInt,就起了怪了doc说忽略24个高位你给我抛个异常emmmm