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

Remove redundant condition judgement in DirectoryScanner#scan

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.1.0
    • 3.2.0
    • datanode
    • None
    • 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

        1. HDFS-13829.001.patch
          0.9 kB
          liaoyuxiangqin

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: