File count in an HDFS directory

前端 未结 6 2080
攒了一身酷
攒了一身酷 2021-01-31 10:36

In Java code, I want to connect to a directory in HDFS, learn the number of files in that directory, get their names and want to read them. I can already read the files but I co

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 10:48

    hadoop fs -du [-s] [-h] [-x] URI [URI ...]

    Displays sizes of files and directories contained in the given directory or the length of a file in case its just a file.

    Options:

    The -s option will result in an aggregate summary of file lengths being displayed, rather than the individual files. Without the -s option, calculation is done by going 1-level deep from the given path.
    The -h option will format file sizes in a “human-readable” fashion (e.g 64.0m instead of 67108864)
    The -x option will exclude snapshots from the result calculation. Without the -x option (default), the result is always calculated from all INodes, including all snapshots under the given path.
    

提交回复
热议问题