HDFS-1774. Small optimization to FSDataset. Contributed by Uma Maheswara Rao G
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1148894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54c5bf2b8c
commit
cda43d71be
|
@ -579,6 +579,8 @@ Trunk (unreleased changes)
|
|||
and Random object creation to DFSUtil; move DFSClient.stringifyToken(..)
|
||||
to DelegationTokenIdentifier. (szetszwo)
|
||||
|
||||
HDFS-1774. Small optimization to FSDataset. (Uma Maheswara Rao G via eli)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-1458. Improve checkpoint performance by avoiding unnecessary image
|
||||
|
|
|
@ -99,23 +99,16 @@ public class FSDataset implements FSConstants, FSDatasetInterface {
|
|||
}
|
||||
} else {
|
||||
File[] files = FileUtil.listFiles(dir);
|
||||
int numChildren = 0;
|
||||
List<FSDir> dirList = new ArrayList<FSDir>();
|
||||
for (int idx = 0; idx < files.length; idx++) {
|
||||
if (files[idx].isDirectory()) {
|
||||
numChildren++;
|
||||
dirList.add(new FSDir(files[idx]));
|
||||
} else if (Block.isBlockFilename(files[idx])) {
|
||||
numBlocks++;
|
||||
}
|
||||
}
|
||||
if (numChildren > 0) {
|
||||
children = new FSDir[numChildren];
|
||||
int curdir = 0;
|
||||
for (int idx = 0; idx < files.length; idx++) {
|
||||
if (files[idx].isDirectory()) {
|
||||
children[curdir] = new FSDir(files[idx]);
|
||||
curdir++;
|
||||
}
|
||||
}
|
||||
if (dirList.size() > 0) {
|
||||
children = dirList.toArray(new FSDir[dirList.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue