Uploaded image for project: 'Hadoop Map/Reduce'
  1. Hadoop Map/Reduce
  2. MAPREDUCE-6714

Refactor UncompressedSplitLineReader.fillBuffer()

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.0
    • Fix Version/s: 2.8.0, 3.0.0-alpha1
    • Component/s: None
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      MAPREDUCE-6635 made this change:

      -      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);
      +      }
      

      The result is one more comparison than necessary and code that's a little convoluted. The code can be simplified as:

            long leftBytesForSplit = splitLength - totalBytesRead;
      
            if (leftBytesForSplit < maxBytesToRead) {
              maxBytesToRead = (int)leftBytesForSplit;
            }
      

      The comparison will auto promote maxBytesToRead, making it safe.

        Activity

        Hide
        andrew.wang Andrew Wang added a comment -

        FYI for git greppers, this was typo'd as MAPREDUCE-6741 in the message.

        Show
        andrew.wang Andrew Wang added a comment - FYI for git greppers, this was typo'd as MAPREDUCE-6741 in the message.
        Hide
        ajisakaa Akira Ajisaka added a comment -

        Committed this to trunk, branch-2, and branch-2.8. Thanks Daniel Templeton for the contribution!

        Show
        ajisakaa Akira Ajisaka added a comment - Committed this to trunk, branch-2, and branch-2.8. Thanks Daniel Templeton for the contribution!
        Hide
        ajisakaa Akira Ajisaka added a comment -

        +1. Nice catch!

        Show
        ajisakaa Akira Ajisaka added a comment - +1. Nice catch!
        Hide
        templedf Daniel Templeton added a comment -

        The whitespace issue is unrelated. No new tests are needed because the test added by MAPREDUCE-6635 covers it.

        Show
        templedf Daniel Templeton added a comment - The whitespace issue is unrelated. No new tests are needed because the test added by MAPREDUCE-6635 covers it.
        Hide
        hadoopqa Hadoop QA added a comment -
        -1 overall



        Vote Subsystem Runtime Comment
        0 reexec 0m 30s Docker mode activated.
        +1 @author 0m 0s The patch does not contain any @author tags.
        -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
        +1 mvninstall 6m 27s trunk passed
        +1 compile 0m 23s trunk passed
        +1 checkstyle 0m 16s trunk passed
        +1 mvnsite 0m 29s trunk passed
        +1 mvneclipse 0m 13s trunk passed
        +1 findbugs 0m 47s trunk passed
        +1 javadoc 0m 22s trunk passed
        +1 mvninstall 0m 22s the patch passed
        +1 compile 0m 20s the patch passed
        +1 javac 0m 20s the patch passed
        +1 checkstyle 0m 13s the patch passed
        +1 mvnsite 0m 26s the patch passed
        +1 mvneclipse 0m 10s the patch passed
        -1 whitespace 0m 0s The patch has 20 line(s) that end in whitespace. Use git apply --whitespace=fix.
        +1 findbugs 0m 51s the patch passed
        +1 javadoc 0m 20s the patch passed
        +1 unit 1m 58s hadoop-mapreduce-client-core in the patch passed.
        +1 asflicense 0m 20s The patch does not generate ASF License warnings.
        15m 4s



        Subsystem Report/Notes
        Docker Image:yetus/hadoop:2c91fd8
        JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12809335/MAPREDUCE-6714.001.patch
        JIRA Issue MAPREDUCE-6714
        Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
        uname Linux 47d5f46c948d 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
        Build tool maven
        Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
        git revision trunk / 9581fb7
        Default Java 1.8.0_91
        findbugs v3.0.0
        whitespace https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6547/artifact/patchprocess/whitespace-eol.txt
        Test Results https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6547/testReport/
        modules C: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core U: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core
        Console output https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6547/console
        Powered by Apache Yetus 0.3.0 http://yetus.apache.org

        This message was automatically generated.

        Show
        hadoopqa Hadoop QA added a comment - -1 overall Vote Subsystem Runtime Comment 0 reexec 0m 30s Docker mode activated. +1 @author 0m 0s The patch does not contain any @author tags. -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. +1 mvninstall 6m 27s trunk passed +1 compile 0m 23s trunk passed +1 checkstyle 0m 16s trunk passed +1 mvnsite 0m 29s trunk passed +1 mvneclipse 0m 13s trunk passed +1 findbugs 0m 47s trunk passed +1 javadoc 0m 22s trunk passed +1 mvninstall 0m 22s the patch passed +1 compile 0m 20s the patch passed +1 javac 0m 20s the patch passed +1 checkstyle 0m 13s the patch passed +1 mvnsite 0m 26s the patch passed +1 mvneclipse 0m 10s the patch passed -1 whitespace 0m 0s The patch has 20 line(s) that end in whitespace. Use git apply --whitespace=fix. +1 findbugs 0m 51s the patch passed +1 javadoc 0m 20s the patch passed +1 unit 1m 58s hadoop-mapreduce-client-core in the patch passed. +1 asflicense 0m 20s The patch does not generate ASF License warnings. 15m 4s Subsystem Report/Notes Docker Image:yetus/hadoop:2c91fd8 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12809335/MAPREDUCE-6714.001.patch JIRA Issue MAPREDUCE-6714 Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux 47d5f46c948d 3.13.0-36-lowlatency #63-Ubuntu SMP PREEMPT Wed Sep 3 21:56:12 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / 9581fb7 Default Java 1.8.0_91 findbugs v3.0.0 whitespace https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6547/artifact/patchprocess/whitespace-eol.txt Test Results https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6547/testReport/ modules C: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core U: hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core Console output https://builds.apache.org/job/PreCommit-MAPREDUCE-Build/6547/console Powered by Apache Yetus 0.3.0 http://yetus.apache.org This message was automatically generated.

          People

          • Assignee:
            templedf Daniel Templeton
            Reporter:
            templedf Daniel Templeton
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development