Fix backwards compatibility hadoop versions with guava version <14.0

Note that even hadoop 2.7.0 still depends on guava 11.0.2 as later guava
versions removed functionality used in hadoop (see HADOOP-10101). This
patch also cleanups some unnecessary warnings, recently introduced.

Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/ef7179bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/ef7179bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/ef7179bc

Branch: refs/heads/master
Commit: ef7179bcef86beaf9a9ad210f7aa2d3c987086d0
Parents: 281a32e
Author: Matthias Boehm <[email protected]>
Authored: Sat Mar 5 02:44:18 2016 -0800
Committer: Matthias Boehm <[email protected]>
Committed: Mon Mar 7 12:22:59 2016 -0800

----------------------------------------------------------------------
 .../org/apache/sysml/parser/AParserWrapper.java |  1 -
 .../parser/common/CommonSyntacticValidator.java | 28 +++++++++++++-------
 .../sysml/runtime/transform/DataTransform.java  |  5 +++-
 3 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/ef7179bc/src/main/java/org/apache/sysml/parser/AParserWrapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/AParserWrapper.java 
b/src/main/java/org/apache/sysml/parser/AParserWrapper.java
index 8db932a..7b7a797 100644
--- a/src/main/java/org/apache/sysml/parser/AParserWrapper.java
+++ b/src/main/java/org/apache/sysml/parser/AParserWrapper.java
@@ -54,7 +54,6 @@ public abstract class AParserWrapper
         * @param pydml true if a PyDML parser is needed
         * @return
         */
-       @SuppressWarnings("rawtypes")
        public static AParserWrapper createParser(boolean pydml)
        {
                AParserWrapper ret = null;

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/ef7179bc/src/main/java/org/apache/sysml/parser/common/CommonSyntacticValidator.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/parser/common/CommonSyntacticValidator.java 
b/src/main/java/org/apache/sysml/parser/common/CommonSyntacticValidator.java
index 68a586e..b1259d4 100644
--- a/src/main/java/org/apache/sysml/parser/common/CommonSyntacticValidator.java
+++ b/src/main/java/org/apache/sysml/parser/common/CommonSyntacticValidator.java
@@ -56,9 +56,6 @@ import 
org.apache.sysml.parser.dml.DmlParser.BuiltinFunctionExpressionContext;
 import org.apache.sysml.parser.dml.DmlSyntacticValidator;
 import org.apache.sysml.parser.pydml.PydmlSyntacticValidator;
 
-import com.google.common.primitives.Doubles;
-import com.google.common.primitives.Longs;
-
 /**
  * Contains fields and (helper) methods common to {@link 
DmlSyntacticValidator} and {@link PydmlSyntacticValidator}
  */
@@ -389,15 +386,26 @@ public abstract class CommonSyntacticValidator {
                        return new BooleanIdentifier(false, currentFile, 
linePosition, charPosition, linePosition, charPosition);
 
                // Check for long literal
-               Long l = Longs.tryParse(varValue);
-               if (l != null)
-                       return new IntIdentifier(l.longValue(), currentFile, 
linePosition, charPosition, linePosition, charPosition);
+               // NOTE: we use exception handling instead of Longs.tryParse 
for backwards compatibility with guava <14.1
+               // Also the alternative of Ints.tryParse and falling back to 
double would not be lossless in all cases. 
+               try {
+                       long lval = Long.parseLong(varValue);
+                       return new IntIdentifier(lval, currentFile, 
linePosition, charPosition, linePosition, charPosition);
+               }
+               catch(Exception ex) {
+                       //continue
+               }
                
                // Check for double literal
-               Double d = Doubles.tryParse(varValue);
-               if (d != null)
-                       return new DoubleIdentifier(d.doubleValue(), 
currentFile, linePosition, charPosition, linePosition, charPosition);
-
+               // NOTE: we use exception handling instead of Doubles.tryParse 
for backwards compatibility with guava <14.0
+               try {
+                       double dval = Double.parseDouble(varValue);
+                       return new DoubleIdentifier(dval, currentFile, 
linePosition, charPosition, linePosition, charPosition);
+               }
+               catch(Exception ex) {
+                       //continue
+               }
+                       
                // Otherwise it is a string literal (optionally enclosed within 
single or double quotes)
                String val = "";
                String text = varValue;

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/ef7179bc/src/main/java/org/apache/sysml/runtime/transform/DataTransform.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/runtime/transform/DataTransform.java 
b/src/main/java/org/apache/sysml/runtime/transform/DataTransform.java
index 2287f1b..4dde85b 100644
--- a/src/main/java/org/apache/sysml/runtime/transform/DataTransform.java
+++ b/src/main/java/org/apache/sysml/runtime/transform/DataTransform.java
@@ -1411,7 +1411,10 @@ public class DataTransform {
                }
        }
        
-       private static void checkIfOutputOverlapsWithTxMtd(String txMtdPath, 
String outputPath, FileSystem fs) throws DMLRuntimeException {
+       @SuppressWarnings("deprecation")
+       private static void checkIfOutputOverlapsWithTxMtd(String txMtdPath, 
String outputPath, FileSystem fs) 
+               throws DMLRuntimeException 
+       {
                Path path1 = new Path(txMtdPath).makeQualified(fs);
                Path path2 = new Path(outputPath).makeQualified(fs);
                

Reply via email to