Header Ads Widget

File Size

 File Size :

1.

  • You can use the Hadoop fs -ls command to list files in the current directory as well as their details. 
  • The 5th column in the command output contains file size in bytes.
  • For example, command Hadoop fs -ls input gives the following output :

    Found 1 item

    -rw-r--r--   1  hduser    supergroup   45956  2020-07-8   20:57   /user/hduser/input/sou

 The size of the file sou is 45956 bytes.

2.

  • You can also find file size using hadoop fs -dus <path>
  • For example, if a directory on HDFS named "/user/frylock/input" contains 100 files and you need the total size for all of those files you could run:

        hadoop fs -dus /user/frylock/input

  • And you would get back the total size (in bytes) of all of the files in the "/user/frylock/input" directory.

3.

  • You can also use the following function to find the file size :
    public class GetflStatus
    {
    public long getflSize(String args) throws IOException, FileNotFoundException
    {
    Configuration config = new Configuration();
    Path path = new Path(args);
    FileSystem hdfs = path.getFileSystem(config);
    ContentSummary cSummary = hdfs.getContentSummary(path);
    long length = cSummary.getLength();
    return length;
    }
    }

Post a Comment

0 Comments