Description
In sortAndSpill of MapTask.java, size is calculated wrongly when bufend < bufstart. we should change (bufvoid - bufend) + bufstart to (bufvoid - bufstart) + bufend.
Should change
long size = (bufend >= bufstart
? bufend - bufstart
: (bufvoid - bufend) + bufstart) +
partitions * APPROX_HEADER_LENGTH;
to:
long size = (bufend >= bufstart
? bufend - bufstart
: (bufvoid - bufstart) + bufend) +
partitions * APPROX_HEADER_LENGTH;
It is because when wraparound happen (bufend < bufstart) , the size should
bufvoid - bufstart (bigger one) + bufend(small one).
You can find similar code implementation in MapTask.java:
mapOutputByteCounter.increment(valend >= keystart ? valend - keystart : (bufvoid - keystart) + valend);