hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject svn commit: r616660 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FileSystem.java src/test/org/apache/hadoop/fs/TestGlobPaths.java
Date Wed, 30 Jan 2008 06:55:45 GMT
Author: nigel
Date: Tue Jan 29 22:55:44 2008
New Revision: 616660

URL: http://svn.apache.org/viewvc?rev=616660&view=rev
Log:
HADOOP-2732. Fix bug in path globbing. Contributed by Hairong Kuang.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/fs/FileSystem.java
    hadoop/core/trunk/src/test/org/apache/hadoop/fs/TestGlobPaths.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=616660&r1=616659&r2=616660&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Jan 29 22:55:44 2008
@@ -611,6 +611,8 @@
 
     HADOOP-2641. Added Apache license headers to 95 files. (nigel)
 
+    HADOOP-2732. Fix bug in path globbing.  (Hairong Kuang via nigel)
+
 Release 0.15.3 - 2008-01-18
 
   BUG FIXES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/fs/FileSystem.java?rev=616660&r1=616659&r2=616660&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/fs/FileSystem.java Tue Jan 29 22:55:44 2008
@@ -888,7 +888,6 @@
       int setOpen;
       int curlyOpen;
       boolean setRange;
-      boolean expectGroup;
 
       StringBuilder fileRegex = new StringBuilder();
 
@@ -900,7 +899,6 @@
       setOpen = 0;
       setRange = false;
       curlyOpen = 0;
-      expectGroup = false;
 
       for (int i = 0; i < len; i++) {
         char pCh;
@@ -929,11 +927,8 @@
         } else if (pCh == ',' && curlyOpen > 0) {
           fileRegex.append(")|");
           pCh = '(';
-          expectGroup = true;
         } else if (pCh == '}' && curlyOpen > 0) {
           // End of a group
-          if (expectGroup)
-            error("Unexpected end of a group", filePattern, i);
           curlyOpen--;
           fileRegex.append(")");
           pCh = ')';
@@ -956,8 +951,6 @@
           // Normal character, or the end of a character set range
           setOpen++;
           setRange = false;
-        } else if (curlyOpen > 0) {
-          expectGroup = false;
         }
         fileRegex.append(pCh);
       }

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/fs/TestGlobPaths.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/fs/TestGlobPaths.java?rev=616660&r1=616659&r2=616660&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/fs/TestGlobPaths.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/fs/TestGlobPaths.java Tue Jan 29 22:55:44
2008
@@ -268,7 +268,7 @@
     }
     try {
       // test standalone }
-      files = new String[] {USER_DIR+"/}bc"};
+      files = new String[] {USER_DIR+"/}bc", USER_DIR+"/}c"};
       matchedPath = prepareTesting(USER_DIR+"/}{a,b}c", files);
       assertEquals(matchedPath.length, 1);
       assertEquals(matchedPath[0], path[0]);
@@ -281,16 +281,30 @@
       assertEquals(matchedPath.length, 1);
       assertEquals(matchedPath[0], path[0]);
 
+      // test {,}
+      matchedPath = prepareTesting(USER_DIR+"/}{,}bc", files);
+      assertEquals(matchedPath.length, 1);
+      assertEquals(matchedPath[0], path[0]);
+
+      // test {b,}
+      matchedPath = prepareTesting(USER_DIR+"/}{b,}c", files);
+      assertEquals(matchedPath.length, 2);
+      assertEquals(matchedPath[0], path[0]);
+      assertEquals(matchedPath[1], path[1]);
+
+      // test {,b}
+      matchedPath = prepareTesting(USER_DIR+"/}{,b}c", files);
+      assertEquals(matchedPath.length, 2);
+      assertEquals(matchedPath[0], path[0]);
+      assertEquals(matchedPath[1], path[1]);
+
+      // test a combination of {} and ?
+      matchedPath = prepareTesting(USER_DIR+"/}{ac,?}", files);
+      assertEquals(matchedPath.length, 1);
+      assertEquals(matchedPath[0], path[1]);
+      
       // test ill-formed curly
       boolean hasException = false;
-      try {
-        prepareTesting(USER_DIR+"}{b,}c", files);
-      } catch (IOException e) {
-        assertTrue(e.getMessage().startsWith("Illegal file pattern:") );
-        hasException = true;
-      }
-      assertTrue(hasException);
-      hasException = false;
       try {
         prepareTesting(USER_DIR+"}{bc", files);
       } catch (IOException e) {



Mime
View raw message