In which scenarios we do not allocate blocks to files?

44 views Asked by At

The HDFS Quota Guide says the following for Space Quota. In which scenarios we do not allocate blocks to files?

A quota of zero still permits files to be created, but no blocks can be added to the files.

1

There are 1 answers

0
xkrogen On BEST ANSWER

A file in HDFS is analogous to an INode in more typical file systems. It may or may not contain data, and blocks will only be created if data is added to the file. For example, in the following snippet, no blocks are created because no data is added to the file:

FileSystem fs = ...
Path p = ...
fs.create(p).close();

Whereas in the following, a block is created:

FileSystem fs = ...
Path p = ...
try (FSDataOutputStream out = fs.create(p)) {
    out.write(42);
}