parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject parquet-mr git commit: PARQUET-349: VersionParser does not handle versions missing 'build' section
Date Tue, 08 Dec 2015 18:02:45 GMT
Repository: parquet-mr
Updated Branches:
  refs/heads/master 14097c64d -> f2615d9a6


PARQUET-349: VersionParser does not handle versions missing 'build' section

This change reworks the regular expression in VersionParser.java to allow for missing 'version'
and 'build' sections.

Author: Reuben Kuhnert <reuben.kuhnert@cloudera.com>

Closes #283 from sircodesalotOfTheRound/fix-version-test and squashes the following commits:

0f4a22f [Reuben Kuhnert] PARQUET-349: VersionParser does not handle versions missing 'build'
section.


Project: http://git-wip-us.apache.org/repos/asf/parquet-mr/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-mr/commit/f2615d9a
Tree: http://git-wip-us.apache.org/repos/asf/parquet-mr/tree/f2615d9a
Diff: http://git-wip-us.apache.org/repos/asf/parquet-mr/diff/f2615d9a

Branch: refs/heads/master
Commit: f2615d9a611db401cdedc022112c87ad938b5680
Parents: 14097c6
Author: Reuben Kuhnert <reuben.kuhnert@cloudera.com>
Authored: Tue Dec 8 10:02:31 2015 -0800
Committer: Ryan Blue <blue@apache.org>
Committed: Tue Dec 8 10:02:31 2015 -0800

----------------------------------------------------------------------
 .../java/org/apache/parquet/VersionParser.java     |  6 +++---
 .../test/java/org/apache/parquet/VersionTest.java  | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/f2615d9a/parquet-common/src/main/java/org/apache/parquet/VersionParser.java
----------------------------------------------------------------------
diff --git a/parquet-common/src/main/java/org/apache/parquet/VersionParser.java b/parquet-common/src/main/java/org/apache/parquet/VersionParser.java
index c1a94d3..fc4ff6c 100644
--- a/parquet-common/src/main/java/org/apache/parquet/VersionParser.java
+++ b/parquet-common/src/main/java/org/apache/parquet/VersionParser.java
@@ -31,7 +31,7 @@ import static org.apache.parquet.Preconditions.checkArgument;
  */
 public class VersionParser {
   // example: parquet-mr version 1.8.0rc2-SNAPSHOT (build ddb469afac70404ea63b72ed2f07a911a8592ff7)
-  public static final String FORMAT = "(.+) version ((.*) )?\\(build ?(.*)\\)";
+  public static final String FORMAT = "(.*?)\\s+version\\s*(?:([^(]*?)\\s*(?:\\(\\s*build\\s*([^)]*?)\\s*\\))?)?";
   public static final Pattern PATTERN = Pattern.compile(FORMAT);
 
   public static class ParsedVersion {
@@ -113,8 +113,8 @@ public class VersionParser {
     }
 
     String application = matcher.group(1);
-    String semver = matcher.group(3);
-    String appBuildHash = matcher.group(4);
+    String semver = matcher.group(2);
+    String appBuildHash = matcher.group(3);
 
     if (Strings.isNullOrEmpty(application)) {
       throw new VersionParseException("application cannot be null or empty");

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/f2615d9a/parquet-common/src/test/java/org/apache/parquet/VersionTest.java
----------------------------------------------------------------------
diff --git a/parquet-common/src/test/java/org/apache/parquet/VersionTest.java b/parquet-common/src/test/java/org/apache/parquet/VersionTest.java
index 75f8b76..30bd3bf 100644
--- a/parquet-common/src/test/java/org/apache/parquet/VersionTest.java
+++ b/parquet-common/src/test/java/org/apache/parquet/VersionTest.java
@@ -79,5 +79,22 @@ public class VersionTest {
     assertEquals(new ParsedVersion("parquet-mr", "1.6.0", null), VersionParser.parse("parquet-mr
version 1.6.0 (build)"));
     assertEquals(new ParsedVersion("parquet-mr", null, null), VersionParser.parse("parquet-mr
version (build)"));
     assertEquals(new ParsedVersion("parquet-mr", null, null), VersionParser.parse("parquet-mr
version (build )"));
+
+    // Missing entire build section
+    assertEquals(new ParsedVersion("parquet-mr", "1.6.0", null), VersionParser.parse("parquet-mr
version 1.6.0"));
+    assertEquals(new ParsedVersion("parquet-mr", "1.8.0rc4", null), VersionParser.parse("parquet-mr
version 1.8.0rc4"));
+    assertEquals(new ParsedVersion("parquet-mr", "1.8.0rc4-SNAPSHOT", null), VersionParser.parse("parquet-mr
version 1.8.0rc4-SNAPSHOT"));
+    assertEquals(new ParsedVersion("parquet-mr", null, null), VersionParser.parse("parquet-mr
version"));
+
+
+    // Various spaces
+    assertEquals(new ParsedVersion("parquet-mr", "1.6.0", null), VersionParser.parse("parquet-mr
    version    1.6.0"));
+    assertEquals(new ParsedVersion("parquet-mr", "1.8.0rc4", null), VersionParser.parse("parquet-mr
    version    1.8.0rc4"));
+    assertEquals(new ParsedVersion("parquet-mr", "1.8.0rc4-SNAPSHOT", null), VersionParser.parse("parquet-mr
     version    1.8.0rc4-SNAPSHOT  "));
+    assertEquals(new ParsedVersion("parquet-mr", null, null), VersionParser.parse("parquet-mr
     version"));
+    assertEquals(new ParsedVersion("parquet-mr", "1.6.0", null), VersionParser.parse("parquet-mr
version 1.6.0 (  build )"));
+    assertEquals(new ParsedVersion("parquet-mr", "1.6.0", null), VersionParser.parse("parquet-mr
    version 1.6.0 (    build)"));
+    assertEquals(new ParsedVersion("parquet-mr", null, null), VersionParser.parse("parquet-mr
    version (    build)"));
+    assertEquals(new ParsedVersion("parquet-mr", null, null), VersionParser.parse("parquet-mr
   version    (build    )"));
   }
 }


Mime
View raw message