Daniel Templeton created MAPREDUCE-6714:
-------------------------------------------
Summary: Refactor UncompressedSplitLineReader.fillBuffer()
Key: MAPREDUCE-6714
URL: https://issues.apache.org/jira/browse/MAPREDUCE-6714
Project: Hadoop Map/Reduce
Issue Type: Improvement
Affects Versions: 2.8.0
Reporter: Daniel Templeton
MAPREDUCE-6635 made this change:
{code}
- maxBytesToRead = Math.min(maxBytesToRead,
- (int)(splitLength - totalBytesRead));
+ long leftBytesForSplit = splitLength - totalBytesRead;
+ // check if leftBytesForSplit exceed Integer.MAX_VALUE
+ if (leftBytesForSplit <= Integer.MAX_VALUE) {
+ maxBytesToRead = Math.min(maxBytesToRead, (int)leftBytesForSplit);
+ }
{code}
The result is one more comparison than necessary and code that's a little
convoluted. The code can be simplified as:
{code}
long leftBytesForSplit = splitLength - totalBytesRead;
if (leftBytesForSplit < maxBytesToRead) {
maxBytesToRead = (int)leftBytesForSplit;
}
{code}
The comparison will auto promote {{maxBytesToRead}}, making it safe.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]