HDFS-12542. Update javadoc and documentation for listStatus. Contributed by Ajay Kumar.

This commit is contained in:
Arpit Agarwal 2017-10-11 12:29:35 -07:00
parent bb0a742aac
commit 8acdf5c274
3 changed files with 33 additions and 6 deletions

View File

@ -1495,6 +1495,15 @@ protected URL getResolvedUrl(final HttpURLConnection connection
} }
} }
/**
* Get {@link FileStatus} of files/directories in the given path. If path
* corresponds to a file then {@link FileStatus} of that file is returned.
* Else if path represents a directory then {@link FileStatus} of all
* files/directories inside given path is returned.
*
* @param f given path
* @return the statuses of the files/directories in the given path
*/
@Override @Override
public FileStatus[] listStatus(final Path f) throws IOException { public FileStatus[] listStatus(final Path f) throws IOException {
statistics.incrementReadOps(1); statistics.incrementReadOps(1);
@ -1519,6 +1528,13 @@ FileStatus[] decodeResponse(Map<?,?> json) {
private static final byte[] EMPTY_ARRAY = new byte[] {}; private static final byte[] EMPTY_ARRAY = new byte[] {};
/**
* Get DirectoryEntries of the given path. DirectoryEntries contains an array
* of {@link FileStatus}, as well as iteration information.
*
* @param f given path
* @return DirectoryEntries for given path
*/
@Override @Override
public DirectoryEntries listStatusBatch(Path f, byte[] token) throws public DirectoryEntries listStatusBatch(Path f, byte[] token) throws
FileNotFoundException, IOException { FileNotFoundException, IOException {

View File

@ -705,14 +705,13 @@ private FileStatus[] toFileStatuses(JSONObject json, Path f) {
} }
/** /**
* List the statuses of the files/directories in the given path if the path is * Get {@link FileStatus} of files/directories in the given path. If path
* a directory. * corresponds to a file then {@link FileStatus} of that file is returned.
* Else if path represents a directory then {@link FileStatus} of all
* files/directories inside given path is returned.
* *
* @param f given path * @param f given path
* * @return the statuses of the files/directories in the given path
* @return the statuses of the files/directories in the given patch
*
* @throws IOException
*/ */
@Override @Override
public FileStatus[] listStatus(Path f) throws IOException { public FileStatus[] listStatus(Path f) throws IOException {
@ -725,6 +724,13 @@ public FileStatus[] listStatus(Path f) throws IOException {
return toFileStatuses(json, f); return toFileStatuses(json, f);
} }
/**
* Get {@link DirectoryEntries} of the given path. {@link DirectoryEntries}
* contains an array of {@link FileStatus}, as well as iteration information.
*
* @param f given path
* @return {@link DirectoryEntries} for given path
*/
@Override @Override
public DirectoryEntries listStatusBatch(Path f, byte[] token) throws public DirectoryEntries listStatusBatch(Path f, byte[] token) throws
FileNotFoundException, IOException { FileNotFoundException, IOException {

View File

@ -467,6 +467,8 @@ See also: [FileSystem](../../api/org/apache/hadoop/fs/FileSystem.html).getFileSt
{ {
"accessTime" : 1320171722771, "accessTime" : 1320171722771,
"blockSize" : 33554432, "blockSize" : 33554432,
"childrenNum" : 0,
"fileId" : 16388,
"group" : "supergroup", "group" : "supergroup",
"length" : 24930, "length" : 24930,
"modificationTime": 1320171722771, "modificationTime": 1320171722771,
@ -474,11 +476,14 @@ See also: [FileSystem](../../api/org/apache/hadoop/fs/FileSystem.html).getFileSt
"pathSuffix" : "a.patch", "pathSuffix" : "a.patch",
"permission" : "644", "permission" : "644",
"replication" : 1, "replication" : 1,
"storagePolicy" : 0,
"type" : "FILE" "type" : "FILE"
}, },
{ {
"accessTime" : 0, "accessTime" : 0,
"blockSize" : 0, "blockSize" : 0,
"childrenNum" : 0,
"fileId" : 16389,
"group" : "supergroup", "group" : "supergroup",
"length" : 0, "length" : 0,
"modificationTime": 1320895981256, "modificationTime": 1320895981256,