hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1101132 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/shell/PathData.java src/test/core/org/apache/hadoop/fs/shell/TestPathData.java
Date Mon, 09 May 2011 18:20:04 GMT
Author: szetszwo
Date: Mon May  9 18:20:04 2011
New Revision: 1101132

URL: http://svn.apache.org/viewvc?rev=1101132&view=rev
Log:
HADOOP-7265. Keep track of relative paths in PathData.  Contributed by Daryn Sharp

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/PathData.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/shell/TestPathData.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1101132&r1=1101131&r2=1101132&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Mon May  9 18:20:04 2011
@@ -124,6 +124,9 @@ Trunk (unreleased changes)
     HADOOP-7251. Refactor the getmerge command to conform to new FsCommand
     class.  (Daryn Sharp via szetszwo)
 
+    HADOOP-7265. Keep track of relative paths in PathData.  (Daryn Sharp
+    via szetszwo)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/PathData.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/PathData.java?rev=1101132&r1=1101131&r2=1101132&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/PathData.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/shell/PathData.java Mon May  9 18:20:04
2011
@@ -146,7 +146,11 @@ public class PathData {
     FileStatus[] stats = fs.listStatus(path);
     PathData[] items = new PathData[stats.length];
     for (int i=0; i < stats.length; i++) {
-      items[i] = new PathData(fs, stats[i]);
+      // preserve relative paths
+      String basename = stats[i].getPath().getName();
+      String parent = string;
+      if (!parent.endsWith(Path.SEPARATOR)) parent += Path.SEPARATOR;
+      items[i] = new PathData(fs, parent + basename, stats[i]);
     }
     return items;
   }

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/shell/TestPathData.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/shell/TestPathData.java?rev=1101132&r1=1101131&r2=1101132&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/shell/TestPathData.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/shell/TestPathData.java Mon May
 9 18:20:04 2011
@@ -54,6 +54,26 @@ public class TestPathData {
   }
 
   @Test
+  public void testUnqualifiedUriContents() throws Exception {
+    dirString = "/tmp";
+    item = new PathData(dirString, conf);
+    PathData[] items = item.getDirectoryContents();
+    for (PathData item : items) {
+      assertTrue(item.toString().startsWith(dirString));
+    }
+  }
+
+  @Test
+  public void testQualifiedUriContents() throws Exception {
+    dirString = "file:/tmp";
+    item = new PathData(dirString, conf);
+    PathData[] items = item.getDirectoryContents();
+    for (PathData item : items) {
+      assertTrue(item.toString().startsWith(dirString));
+    }
+  }
+
+  @Test
   public void testWithStringAndConfForBuggyPath() throws Exception {
     dirString = "file:///tmp";
     dir = new Path(dirString);



Mime
View raw message