[
https://issues.apache.org/jira/browse/MAPREDUCE-6714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15447501#comment-15447501
]
Andrew Wang commented on MAPREDUCE-6714:
----------------------------------------
FYI for git greppers, this was typo'd as MAPREDUCE-6741 in the message.
> 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
> Assignee: Daniel Templeton
> Fix For: 2.8.0
>
> Attachments: MAPREDUCE-6714.001.patch
>
>
> 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]