You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by el...@apache.org on 2011/07/20 20:53:00 UTC
svn commit: r1148894 - in /hadoop/common/trunk/hdfs: CHANGES.txt
src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java
Author: eli
Date: Wed Jul 20 18:52:57 2011
New Revision: 1148894
URL: http://svn.apache.org/viewvc?rev=1148894&view=rev
Log:
HDFS-1774. Small optimization to FSDataset. Contributed by Uma Maheswara Rao G
Modified:
hadoop/common/trunk/hdfs/CHANGES.txt
hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java
Modified: hadoop/common/trunk/hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/CHANGES.txt?rev=1148894&r1=1148893&r2=1148894&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hdfs/CHANGES.txt Wed Jul 20 18:52:57 2011
@@ -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
Modified: hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java?rev=1148894&r1=1148893&r2=1148894&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java (original)
+++ hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/FSDataset.java Wed Jul 20 18:52:57 2011
@@ -99,23 +99,16 @@ public class FSDataset implements FSCons
}
} 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()]);
}
}
}