hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r385885 - in /lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs: DFSFileInfo.java FSDirectory.java
Date Tue, 14 Mar 2006 20:55:59 GMT
Author: cutting
Date: Tue Mar 14 12:55:57 2006
New Revision: 385885

URL: http://svn.apache.org/viewcvs?rev=385885&view=rev
Log:
Fix for HADOOP-79.  Some namenode optimizations.  Contributed by Konstantin Shvachko.

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSFileInfo.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSFileInfo.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSFileInfo.java?rev=385885&r1=385884&r2=385885&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSFileInfo.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSFileInfo.java Tue Mar 14 12:55:57
2006
@@ -45,12 +45,16 @@
     }
 
     /**
+     * Create DFSFileInfo by file INode 
      */
-    public DFSFileInfo(UTF8 path, long len, long contentsLen, boolean isDir) {
-        this.path = path;
-        this.len = len;
-        this.contentsLen = contentsLen;
-        this.isDir = isDir;
+    public DFSFileInfo( FSDirectory.INode node ) {
+        this.path = new UTF8(node.computeName());
+        this.isDir = node.isDir();
+        if( isDir ) {
+          this.len = 0;
+          this.contentsLen = node.computeContentsLength();
+        } else 
+          this.len = this.contentsLen = node.computeFileLength();
     }
 
     /**

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java?rev=385885&r1=385884&r2=385885&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/FSDirectory.java Tue Mar 14 12:55:57
2006
@@ -59,6 +59,14 @@
         }
 
         /**
+         * Check whether it's a directory
+         * @return
+         */
+        synchronized public boolean isDir() {
+          return (blocks == null);
+        }
+
+        /**
          * This is the external interface
          */
         INode getNode(String target) {
@@ -612,11 +620,7 @@
                 DFSFileInfo listing[] = new DFSFileInfo[contents.size()];
                 int i = 0;
                 for (Iterator it = contents.iterator(); it.hasNext(); i++) {
-                    INode cur = (INode) it.next();
-                    UTF8 curName = new UTF8(cur.computeName());
-                    listing[i] = new DFSFileInfo(curName, cur.computeFileLength(), cur.computeContentsLength(),
isDir(curName));
-                    //listing[i] = new DFSFileInfo(curName, cur.computeFileLength(), 0, isDir(curName));
-                    //listing[i] = new DFSFileInfo(curName, cur.computeFileLength(), 0, false);
+                    listing[i] = new DFSFileInfo( (INode) it.next() );
                 }
                 return listing;
             }
@@ -655,16 +659,12 @@
     }
 
     /**
-     * Check whether it's a directory
+     * Check whether the path specifies a directory
      */
     public boolean isDir(UTF8 src) {
         synchronized (rootDir) {
             INode node = rootDir.getNode(normalizePath(src));
-            if (node != null && node.blocks == null) {
-                return true;
-            } else {
-                return false;
-            }
+            return node != null && node.isDir();
         }
     }
 



Mime
View raw message