Repository: incubator-systemml
Updated Branches:
  refs/heads/master ef60e959c -> 220569e85


Throw error message if SQLContext is not created in PySpark

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

Branch: refs/heads/master
Commit: 220569e8536d0cb1763161ced4efd19e529c53cf
Parents: ef60e95
Author: Niketan Pansare <[email protected]>
Authored: Wed Dec 9 09:29:36 2015 -0800
Committer: Niketan Pansare <[email protected]>
Committed: Wed Dec 9 09:29:36 2015 -0800

----------------------------------------------------------------------
 src/main/java/org/apache/sysml/api/MLOutput.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/220569e8/src/main/java/org/apache/sysml/api/MLOutput.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/MLOutput.java 
b/src/main/java/org/apache/sysml/api/MLOutput.java
index 8bcb7ce..6ba04eb 100644
--- a/src/main/java/org/apache/sysml/api/MLOutput.java
+++ b/src/main/java/org/apache/sysml/api/MLOutput.java
@@ -87,6 +87,9 @@ public class MLOutput {
         * @throws DMLRuntimeException
         */
        public DataFrame getDF(SQLContext sqlContext, String varName) throws 
DMLRuntimeException {
+               if(sqlContext == null) {
+                       throw new DMLRuntimeException("SQLContext is not 
created.");
+               }
                JavaPairRDD<MatrixIndexes,MatrixBlock> rdd = 
getBinaryBlockedRDD(varName);
                if(rdd != null) {
                        MatrixCharacteristics mc = _outMetadata.get(varName);
@@ -104,6 +107,9 @@ public class MLOutput {
         * @throws DMLRuntimeException
         */
        public DataFrame getDF(SQLContext sqlContext, String varName, boolean 
outputVector) throws DMLRuntimeException {
+               if(sqlContext == null) {
+                       throw new DMLRuntimeException("SQLContext is not 
created.");
+               }
                if(outputVector) {
                        JavaPairRDD<MatrixIndexes,MatrixBlock> rdd = 
getBinaryBlockedRDD(varName);
                        if(rdd != null) {
@@ -127,6 +133,9 @@ public class MLOutput {
         * @throws DMLRuntimeException
         */
        public DataFrame getDF(SQLContext sqlContext, String varName, 
HashMap<String, Tuple2<Long, Long>> range) throws DMLRuntimeException {
+               if(sqlContext == null) {
+                       throw new DMLRuntimeException("SQLContext is not 
created.");
+               }
                JavaPairRDD<MatrixIndexes,MatrixBlock> binaryBlockRDD = 
getBinaryBlockedRDD(varName);
                if(binaryBlockRDD == null) {
                        throw new DMLRuntimeException("Variable " + varName + " 
not found in the output symbol table.");
@@ -185,6 +194,12 @@ public class MLOutput {
        }
        
        public MLMatrix getMLMatrix(MLContext ml, SQLContext sqlContext, String 
varName) throws DMLRuntimeException {
+               if(sqlContext == null) {
+                       throw new DMLRuntimeException("SQLContext is not 
created.");
+               }
+               else if(ml == null) {
+                       throw new DMLRuntimeException("MLContext is not 
created.");
+               }
                JavaPairRDD<MatrixIndexes,MatrixBlock> rdd = 
getBinaryBlockedRDD(varName);
                if(rdd != null) {
                        MatrixCharacteristics mc = 
getMatrixCharacteristics(varName);

Reply via email to