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

globStatus() should always return a sorted list of files

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.8.0, 3.0.0-alpha1
    • Component/s: None
    • Labels:
    • Target Version/s:

      Description

      (FileSystem) globStatus() does not return a sorted file list anymore.

      But the API says: " ... Results are sorted by their names."

      Seems to be lost, when the Globber Object was introduced. Can't find a sort in actual code.

      code to check this behavior:

              Configuration conf = new Configuration();
              FileSystem fs = FileSystem.get(conf);
              Path path = new Path("/tmp/" + System.currentTimeMillis());
              fs.mkdirs(path);
              fs.deleteOnExit(path);
              fs.createNewFile(new Path(path, "2"));
              fs.createNewFile(new Path(path, "3"));
              fs.createNewFile(new Path(path, "1"));
      
              FileStatus[] status = fs.globStatus(new Path(path, "*"));
              Collection list = new ArrayList();
              for (FileStatus f: status) {
                  list.add(f.getPath().toString());
                  //System.out.println(f.getPath().toString());
              }
              boolean sorted = Ordering.natural().isOrdered(list);
              Assert.assertTrue(sorted);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cmccabe Colin P. McCabe
                Reporter:
                fborchers Felix Borchers
              • Votes:
                1 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: