Database Reference
In-Depth Information
Currently, none of the other Hadoop filesystems call progress() during writes. Pro-
gress is important in MapReduce applications, as you will see in later chapters.
FSDataOutputStream
The create() method on FileSystem returns an FSDataOutputStream , which,
like FSDataInputStream , has a method for querying the current position in the file:
package org . apache . hadoop . fs ;
public class FSDataOutputStream extends DataOutputStream implements
Syncable {
public long getPos () throws IOException {
// implementation elided
}
// implementation elided
}
However, unlike FSDataInputStream , FSDataOutputStream does not permit
seeking. This is because HDFS allows only sequential writes to an open file or appends to
an already written file. In other words, there is no support for writing to anywhere other
than the end of the file, so there is no value in being able to seek while writing.
Directories
FileSystem provides a method to create a directory:
public boolean mkdirs ( Path f ) throws IOException
This method creates all of the necessary parent directories if they don't already exist, just
like the java.io.File 's mkdirs() method. It returns true if the directory (and all
parent directories) was (were) successfully created.
Often, you don't need to explicitly create a directory, because writing a file by calling
create() will automatically create any parent directories.
Querying the Filesystem
File metadata: FileStatus
An important feature of any filesystem is the ability to navigate its directory structure and
retrieve information about the files and directories that it stores. The FileStatus class
Search WWH ::




Custom Search