Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-14470

CommandWithDestination#create used redundant ternary operator

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Duplicate
    • 3.0.0-alpha3
    • None
    • common, fs
    • None

    Description

      in if statement,the lazyPersist is always true, thus the ternary operator is redundant,
      lazyPersist == true in if statment, so lazyPersist ? 1 : getDefaultReplication(item.path) is redundant.

      related code like below, which is in org.apache.hadoop.fs.shell.CommandWithDestination lineNumber : 504 :

         FSDataOutputStream create(PathData item, boolean lazyPersist,
              boolean direct)
              throws IOException {
            try {
              if (lazyPersist) { // in if stament, lazyPersist is always true
            ……
                return create(item.path,
                              FsPermission.getFileDefault().applyUMask(
                                  FsPermission.getUMask(getConf())),
                              createFlags,
                              getConf().getInt(IO_FILE_BUFFER_SIZE_KEY,
                                  IO_FILE_BUFFER_SIZE_DEFAULT),
                              lazyPersist ? 1 : getDefaultReplication(item.path), // *this is redundant*
                              getDefaultBlockSize(),
                              null,
                              null);
              } else {
                return create(item.path, true);
              }
            } finally { // might have been created but stream was interrupted
              if (!direct) {
                deleteOnExit(item.path);
              }
            }
          }
      
      

      Attachments

        1. HADOOP-14470-001.patch
          0.9 kB
          Hongyuan Li

        Issue Links

          Activity

            People

              Hongyuan Li Hongyuan Li
              Hongyuan Li Hongyuan Li
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: