Change the ls shell command to sort results by file or dir names

Description

Currently, Alluxio shell ls command will list the sub-dirs and files by the creation time. This JIRA aims to change the behavior to be listing sub-dirs/files by alphabetical order by default, but still providing the options to list sub-dirs/files by creation time or file size or etc. To be more specific,

  • On "bin/alluxio ls /foo", output is sorted by the path name alphabetically.

  • On "bin/alluxio ls --sortedBy {size|creationTime|inMemoryPercentage|lastModificationTime|path} /foo", output will be sorted by the given field in the file status.

Tips:

  • Currently the output is sorted in alluxio.cli.fs.command.LsCommand#listStatusSortedByIncreasingCreationTime. This JIRA aims to provide option so we could choose on the fly which metric to sort by. Check alluxio/cli/fs/command/LsCommand.java

  • If -R the recursive flag is on, it is fine to only sort the output locally not globally (that may require to store all output first before a global sort, can be expensive)

Environment

None

Status

Assignee

Yinghao Yu

Reporter

Bin Fan

Labels

Components

Affects versions

1.6.0

Priority

Minor
Configure