Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-13829

Remove redundant condition judgement in DirectoryScanner#scan

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.0
    • Fix Version/s: 3.2.0
    • Component/s: datanode
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      When i read the scan() of DirectoryScanner class in datanode, i found the following condition code could be more simplify and easy to understand.

      DirectoryScanner.java

      if (d < blockpoolReport.length) {
                  // There may be multiple on-disk records for the same block, don't increment
                  // the memory record pointer if so.
                  ScanInfo nextInfo = blockpoolReport[Math.min(d, blockpoolReport.length - 1)];
                  if (nextInfo.getBlockId() != info.getBlockId()) {
                    ++m;
                  }
      } else {
                  ++m;
       }
      

      as described above code segmet, i find the code of d < blockpoolReport.length and the max of d is blockpoolReport.length-1, so that result of Math.min(d, blockpoolReport.length - 1) always is d, so i think needn't to get min value of scan index and length for blockpoolReport.

      thanks!

        Attachments

          Activity

            People

            • Assignee:
              liaoyuxiangqin liaoyuxiangqin
              Reporter:
              liaoyuxiangqin liaoyuxiangqin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: