hadoop-mapreduce-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akira AJISAKA (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MAPREDUCE-6714) Refactor UncompressedSplitLineReader.fillBuffer()
Date Fri, 10 Jun 2016 10:15:21 GMT

    [ https://issues.apache.org/jira/browse/MAPREDUCE-6714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15324179#comment-15324179
] 

Akira AJISAKA commented on MAPREDUCE-6714:
------------------------------------------

+1. Nice catch!

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


Mime
View raw message