beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject [1/2] beam git commit: Restore non-recursive globs in GcsUtil
Date Thu, 18 May 2017 18:18:13 GMT
Repository: beam
Updated Branches:
  refs/heads/master 5e3c5c657 -> 18358005a


Restore non-recursive globs in GcsUtil


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/9b516748
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/9b516748
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/9b516748

Branch: refs/heads/master
Commit: 9b5167483c89423a0789658a33e51b3f5b6e8e16
Parents: 5e3c5c6
Author: Kenneth Knowles <klk@google.com>
Authored: Thu May 18 08:32:29 2017 -0700
Committer: Kenneth Knowles <klk@google.com>
Committed: Thu May 18 08:36:22 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/beam/sdk/util/GcsUtil.java |  8 +++++++-
 .../java/org/apache/beam/sdk/util/GcsUtilTest.java  | 16 +++++++++++-----
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/9b516748/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/util/GcsUtil.java
----------------------------------------------------------------------
diff --git a/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/util/GcsUtil.java
b/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/util/GcsUtil.java
index 94b733a..8d1fe74 100644
--- a/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/util/GcsUtil.java
+++ b/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/util/GcsUtil.java
@@ -176,7 +176,13 @@ public class GcsUtil {
       char c = src[i++];
       switch (c) {
         case '*':
-          dst.append(".*");
+          // One char lookahead for **
+          if (i < src.length && src[i] == '*') {
+            dst.append(".*");
+            ++i;
+          } else {
+            dst.append("[^/]*");
+          }
           break;
         case '?':
           dst.append("[^/]");

http://git-wip-us.apache.org/repos/asf/beam/blob/9b516748/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/util/GcsUtilTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/util/GcsUtilTest.java
b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/util/GcsUtilTest.java
index 5326450..2164e75 100644
--- a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/util/GcsUtilTest.java
+++ b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/util/GcsUtilTest.java
@@ -93,11 +93,17 @@ public class GcsUtilTest {
   @Test
   public void testGlobTranslation() {
     assertEquals("foo", GcsUtil.wildcardToRegexp("foo"));
-    assertEquals("fo.*o", GcsUtil.wildcardToRegexp("fo*o"));
-    assertEquals("f.*o\\.[^/]", GcsUtil.wildcardToRegexp("f*o.?"));
-    assertEquals("foo-[0-9].*", GcsUtil.wildcardToRegexp("foo-[0-9]*"));
-    assertEquals(".*.*foo", GcsUtil.wildcardToRegexp("**/*foo"));
-    assertEquals(".*.*foo", GcsUtil.wildcardToRegexp("**foo"));
+    assertEquals("fo[^/]*o", GcsUtil.wildcardToRegexp("fo*o"));
+    assertEquals("f[^/]*o\\.[^/]", GcsUtil.wildcardToRegexp("f*o.?"));
+    assertEquals("foo-[0-9][^/]*", GcsUtil.wildcardToRegexp("foo-[0-9]*"));
+    assertEquals("foo-[0-9].*", GcsUtil.wildcardToRegexp("foo-[0-9]**"));
+    assertEquals(".*foo", GcsUtil.wildcardToRegexp("**/*foo"));
+    assertEquals(".*foo", GcsUtil.wildcardToRegexp("**foo"));
+    assertEquals("foo/[^/]*", GcsUtil.wildcardToRegexp("foo/*"));
+    assertEquals("foo[^/]*", GcsUtil.wildcardToRegexp("foo*"));
+    assertEquals("foo/[^/]*/[^/]*/[^/]*", GcsUtil.wildcardToRegexp("foo/*/*/*"));
+    assertEquals("foo/[^/]*/.*", GcsUtil.wildcardToRegexp("foo/*/**"));
+    assertEquals("foo.*baz", GcsUtil.wildcardToRegexp("foo**baz"));
   }
 
   private static GcsOptions gcsOptionsWithTestCredential() {


Mime
View raw message