[ 
https://issues.apache.org/jira/browse/MAPREDUCE-6714?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Templeton updated MAPREDUCE-6714:
----------------------------------------
    Attachment: MAPREDUCE-6714.001.patch

> 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
>         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: mapreduce-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: mapreduce-issues-h...@hadoop.apache.org

Reply via email to