You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2016/10/01 19:57:05 UTC

[4/4] incubator-systemml git commit: [SYSTEMML-995] Fix mlcontext frame input conversion and relock handling

[SYSTEMML-995] Fix mlcontext frame input conversion and relock handling

So far mlcontext, only supported data frames without vectors and without
index columns. This patch fixes the frame input conversion (extended
frame format and meta data handling) as well as errors due to
unnecessary reblock instructions (reblock despite binary input with
matching dimensions). Given the fixed reblock handling, this also
removes the unnecessary hack for matrices at runtime level. Finally,
there is a new testsuite for mlcontext frame inputs with different
properties.

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

Branch: refs/heads/master
Commit: 85a8746a701467ed04a7c5cc856b157920d6f0da
Parents: f019267
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Sat Oct 1 02:53:00 2016 -0700
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Sat Oct 1 02:53:00 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/sysml/api/MLContext.java    |   2 +-
 .../apache/sysml/api/mlcontext/FrameFormat.java |  14 +-
 .../api/mlcontext/MLContextConversionUtil.java  |  38 +-
 .../sysml/api/mlcontext/ScriptExecutor.java     |   2 +-
 .../RewriteRemovePersistentReadWrite.java       |  39 +-
 .../spark/ReblockSPInstruction.java             |  43 +--
 .../spark/utils/FrameRDDConverterUtils.java     |  22 +-
 .../mlcontext/DataFrameVectorScriptTest.java    | 367 +++++++++++++++++++
 .../functions/compress/ZPackageSuite.java       |   1 +
 .../functions/mlcontext/ZPackageSuite.java      |   1 +
 10 files changed, 472 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/api/MLContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/MLContext.java b/src/main/java/org/apache/sysml/api/MLContext.java
index ced3998..f179e1a 100644
--- a/src/main/java/org/apache/sysml/api/MLContext.java
+++ b/src/main/java/org/apache/sysml/api/MLContext.java
@@ -1605,7 +1605,7 @@ public class MLContext {
 		
 		//rewrite persistent reads/writes
 		if(inputSymbolTable != null) {
-			RewriteRemovePersistentReadWrite rewrite = new RewriteRemovePersistentReadWrite(inputs, outputs);
+			RewriteRemovePersistentReadWrite rewrite = new RewriteRemovePersistentReadWrite(inputs, outputs, inputSymbolTable);
 			ProgramRewriter rewriter2 = new ProgramRewriter(rewrite);
 			rewriter2.rewriteProgramHopDAGs(prog);
 		}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/api/mlcontext/FrameFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/mlcontext/FrameFormat.java b/src/main/java/org/apache/sysml/api/mlcontext/FrameFormat.java
index bce8e5d..f339eda 100644
--- a/src/main/java/org/apache/sysml/api/mlcontext/FrameFormat.java
+++ b/src/main/java/org/apache/sysml/api/mlcontext/FrameFormat.java
@@ -34,9 +34,19 @@ public enum FrameFormat {
 	 * (I J V) format (sparse). I and J represent frame coordinates and V
 	 * represents the value. The I J and V values are space-separated.
 	 */
-	IJV;
+	IJV,
+
+	/**
+	 * DataFrame without a row index.
+	 */
+	DF,
+
+	/**
+	 * DataFrame with a row index.
+	 */
+	DF_WITH_INDEX;
 
 	public boolean hasIDColumn() {
-		return false;
+		return this == DF_WITH_INDEX;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/api/mlcontext/MLContextConversionUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/mlcontext/MLContextConversionUtil.java b/src/main/java/org/apache/sysml/api/mlcontext/MLContextConversionUtil.java
index ca9cc2a..53564d9 100644
--- a/src/main/java/org/apache/sysml/api/mlcontext/MLContextConversionUtil.java
+++ b/src/main/java/org/apache/sysml/api/mlcontext/MLContextConversionUtil.java
@@ -62,6 +62,7 @@ import org.apache.sysml.runtime.matrix.data.InputInfo;
 import org.apache.sysml.runtime.matrix.data.MatrixBlock;
 import org.apache.sysml.runtime.matrix.data.MatrixIndexes;
 import org.apache.sysml.runtime.matrix.data.OutputInfo;
+import org.apache.sysml.runtime.matrix.data.Pair;
 import org.apache.sysml.runtime.util.DataConverter;
 import org.apache.sysml.runtime.util.UtilFunctions;
 
@@ -350,35 +351,30 @@ public class MLContextConversionUtil {
 	 * @return the {@code DataFrame} frame converted to a converted to a
 	 *         {@code FrameObject}
 	 */
-	public static FrameObject dataFrameToFrameObject(String variableName, DataFrame dataFrame,
-			FrameMetadata frameMetadata) {
+	public static FrameObject dataFrameToFrameObject(String variableName, DataFrame dataFrame, FrameMetadata frameMetadata) 
+	{
 		try {
-			if (frameMetadata == null) {
+			//setup meta data and java spark context
+			if (frameMetadata == null)
 				frameMetadata = new FrameMetadata();
-			}
-
+			boolean containsID = isDataFrameWithIDColumn(frameMetadata);
 			JavaSparkContext javaSparkContext = MLContextUtil
 					.getJavaSparkContext((MLContext) MLContextProxy.getActiveMLContextForAPI());
-			boolean containsID = isDataFrameWithIDColumn(frameMetadata);
 			MatrixCharacteristics mc = frameMetadata.asMatrixCharacteristics();
-			if (mc == null) {
+			if( mc == null )
 				mc = new MatrixCharacteristics();
-				long rows = dataFrame.count();
-				int cols = dataFrame.columns().length - ((containsID)?1:0);
-				mc.setDimension(rows, cols);
-				frameMetadata.setMatrixCharacteristics(mc);
-			}
 			
-			String[] colnames = new String[(int)mc.getCols()];
-			ValueType[] fschema = new ValueType[(int)mc.getCols()];
-			FrameRDDConverterUtils.convertDFSchemaToFrameSchema(dataFrame.schema(), colnames, fschema, containsID);	
-			frameMetadata.setFrameSchema(new FrameSchema(Arrays.asList(fschema)));
-
-			JavaPairRDD<Long, FrameBlock> binaryBlock = FrameRDDConverterUtils.dataFrameToBinaryBlock(javaSparkContext,
-					dataFrame, mc, containsID);
-
+			//convert data frame and obtain column names / schema
+			//TODO extend frame schema by column names (right now dropped)
+			Pair<String[], ValueType[]> ret = new Pair<String[], ValueType[]>(); 
+			JavaPairRDD<Long, FrameBlock> binaryBlock = FrameRDDConverterUtils
+				.dataFrameToBinaryBlock(javaSparkContext, dataFrame, mc, containsID, ret);
+			frameMetadata.setFrameSchema(new FrameSchema(Arrays.asList(ret.getValue())));
+			frameMetadata.setMatrixCharacteristics(mc); //required due to meta data copy
+			
 			return MLContextConversionUtil.binaryBlocksToFrameObject(variableName, binaryBlock, frameMetadata);
-		} catch (DMLRuntimeException e) {
+		} 
+		catch (DMLRuntimeException e) {
 			throw new MLContextException("Exception converting DataFrame to FrameObject", e);
 		}
 	}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java b/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
index 57e0076..183bddc 100644
--- a/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
+++ b/src/main/java/org/apache/sysml/api/mlcontext/ScriptExecutor.java
@@ -450,7 +450,7 @@ public class ScriptExecutor {
 					.toArray(new String[0]);
 			String[] outputs = (script.getOutputVariables() == null) ? new String[0]
 					: script.getOutputVariables().toArray(new String[0]);
-			RewriteRemovePersistentReadWrite rewrite = new RewriteRemovePersistentReadWrite(inputs, outputs);
+			RewriteRemovePersistentReadWrite rewrite = new RewriteRemovePersistentReadWrite(inputs, outputs, script.getSymbolTable());
 			ProgramRewriter programRewriter = new ProgramRewriter(rewrite);
 			try {
 				programRewriter.rewriteProgramHopDAGs(dmlProgram);

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemovePersistentReadWrite.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemovePersistentReadWrite.java b/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemovePersistentReadWrite.java
index 74db35a..0d5b807 100644
--- a/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemovePersistentReadWrite.java
+++ b/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemovePersistentReadWrite.java
@@ -20,6 +20,7 @@
 package org.apache.sysml.hops.rewrite;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 
 import org.apache.commons.logging.Log;
@@ -30,6 +31,13 @@ import org.apache.sysml.hops.Hop.DataOpTypes;
 import org.apache.sysml.hops.Hop.VisitStatus;
 import org.apache.sysml.hops.HopsException;
 import org.apache.sysml.parser.Expression.DataType;
+import org.apache.sysml.runtime.controlprogram.LocalVariableMap;
+import org.apache.sysml.runtime.controlprogram.caching.CacheableData;
+import org.apache.sysml.runtime.instructions.cp.Data;
+import org.apache.sysml.runtime.matrix.MatrixCharacteristics;
+import org.apache.sysml.runtime.matrix.MatrixFormatMetaData;
+import org.apache.sysml.runtime.matrix.MetaData;
+import org.apache.sysml.runtime.matrix.data.InputInfo;
 
 /**
  * This rewrite is a custom rewrite for JMLC in order to replace all persistent reads
@@ -43,15 +51,31 @@ public class RewriteRemovePersistentReadWrite extends HopRewriteRule
 	
 	private HashSet<String> _inputs = null;
 	private HashSet<String> _outputs = null;
+	private HashMap<String,MetaData> _inputsMeta = null;
 	
-	public RewriteRemovePersistentReadWrite( String[] in, String[] out )
+	public RewriteRemovePersistentReadWrite( String[] in, String[] out ) {
+		this(in, out, null);
+	}
+	
+	public RewriteRemovePersistentReadWrite( String[] in, String[] out, LocalVariableMap vars )
 	{
+		//store input and output names
 		_inputs = new HashSet<String>();
 		for( String var : in )
 			_inputs.add( var );
 		_outputs = new HashSet<String>();
 		for( String var : out )
 			_outputs.add( var );
+		
+		//store input meta data
+		_inputsMeta = new HashMap<String, MetaData>();
+		if( vars != null ) {
+			for( String varname : in ) {
+				Data dat = vars.get(varname);
+				if( dat != null && dat instanceof CacheableData<?> )
+					_inputsMeta.put(varname, ((CacheableData<?>)dat).getMetaData());
+			}
+		}
 	}
 	
 	@Override
@@ -110,6 +134,19 @@ public class RewriteRemovePersistentReadWrite extends HopRewriteRule
 						if (hop.getDataType() == DataType.SCALAR) {
 							dop.removeInput("iofilename");
 						}
+						
+						//disable unnecessary reblock of binary block w/ equal block sizes
+						if( dop.requiresReblock() && _inputsMeta.containsKey(dop.getName()) 
+							&& _inputsMeta.get(dop.getName()) instanceof MatrixFormatMetaData) {
+							MatrixFormatMetaData meta = (MatrixFormatMetaData)_inputsMeta.get(dop.getName());
+							MatrixCharacteristics mc = meta.getMatrixCharacteristics();
+							if( meta.getInputInfo() == InputInfo.BinaryBlockInputInfo
+								&& mc.getRowsPerBlock() == dop.getRowsInBlock() 
+								&& mc.getColsPerBlock() == dop.getColsInBlock() )
+							{
+								dop.setRequiresReblock(false);
+							}
+						}
 					} 
 					else
 						LOG.warn("Non-registered persistent read of variable '"+dop.getName()+"' (line "+dop.getBeginLine()+").");

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/runtime/instructions/spark/ReblockSPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/ReblockSPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/ReblockSPInstruction.java
index b61bb4f..05e051f 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/spark/ReblockSPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/ReblockSPInstruction.java
@@ -179,36 +179,20 @@ public class ReblockSPInstruction extends UnarySPInstruction
 		}
 		else if(iinfo == InputInfo.BinaryBlockInputInfo) 
 		{
-			/// HACK ALERT: Workaround for MLContext 
-			if(mc.getRowsPerBlock() == mcOut.getRowsPerBlock() && mc.getColsPerBlock() == mcOut.getColsPerBlock()) {
-				if(mo.getRDDHandle() != null) {
-					JavaPairRDD<MatrixIndexes, MatrixBlock> out = (JavaPairRDD<MatrixIndexes, MatrixBlock>) mo.getRDDHandle().getRDD();
-					
-					//put output RDD handle into symbol table
-					sec.setRDDHandleForVariable(output.getName(), out);
-					sec.addLineageRDD(output.getName(), input1.getName());
-					return;
-				}
-				else {
-					throw new DMLRuntimeException("Input RDD is not accessible through buffer pool for ReblockSPInstruction:" + iinfo);
-				}
-			}
-			else 
-			{
-				//BINARY BLOCK <- BINARY BLOCK (different sizes)
-				JavaPairRDD<MatrixIndexes, MatrixBlock> in1 = sec.getBinaryBlockRDDHandleForVariable(input1.getName());
-				
-				JavaPairRDD<MatrixIndexes, MatrixBlock> out = 
-						in1.flatMapToPair(new ExtractBlockForBinaryReblock(mc, mcOut));
-				out = RDDAggregateUtils.mergeByKey( out );
-				
-				//put output RDD handle into symbol table
-				sec.setRDDHandleForVariable(output.getName(), out);
-				sec.addLineageRDD(output.getName(), input1.getName());
-			}
+			//BINARY BLOCK <- BINARY BLOCK (different sizes)
+			JavaPairRDD<MatrixIndexes, MatrixBlock> in1 = sec.getBinaryBlockRDDHandleForVariable(input1.getName());
+			
+			JavaPairRDD<MatrixIndexes, MatrixBlock> out = 
+					in1.flatMapToPair(new ExtractBlockForBinaryReblock(mc, mcOut));
+			out = RDDAggregateUtils.mergeByKey( out );
+			
+			//put output RDD handle into symbol table
+			sec.setRDDHandleForVariable(output.getName(), out);
+			sec.addLineageRDD(output.getName(), input1.getName());
 		}
 		else {
-			throw new DMLRuntimeException("The given InputInfo is not implemented for ReblockSPInstruction:" + iinfo);
+			throw new DMLRuntimeException("The given InputInfo is not implemented "
+					+ "for ReblockSPInstruction:" + InputInfo.inputInfoToString(iinfo));
 		}
 	}
 	
@@ -264,7 +248,8 @@ public class ReblockSPInstruction extends UnarySPInstruction
 			csvInstruction.processInstruction(sec);
 		}
 		else {
-			throw new DMLRuntimeException("The given InputInfo is not implemented for ReblockSPInstruction:" + iinfo);
+			throw new DMLRuntimeException("The given InputInfo is not implemented "
+					+ "for ReblockSPInstruction: " + InputInfo.inputInfoToString(iinfo));
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/main/java/org/apache/sysml/runtime/instructions/spark/utils/FrameRDDConverterUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/utils/FrameRDDConverterUtils.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/utils/FrameRDDConverterUtils.java
index fbc8866..086c41e 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/spark/utils/FrameRDDConverterUtils.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/utils/FrameRDDConverterUtils.java
@@ -320,12 +320,29 @@ public class FrameRDDConverterUtils
 	 * @param mc
 	 * @param containsID
 	 * @return
-	 * @throws DMLRuntimeException
+	 * @throws DMLRuntimeException 
 	 */
 	public static JavaPairRDD<Long, FrameBlock> dataFrameToBinaryBlock(JavaSparkContext sc,
 			DataFrame df, MatrixCharacteristics mc, boolean containsID) 
 		throws DMLRuntimeException 
 	{
+		return dataFrameToBinaryBlock(sc, df, mc, containsID, new Pair<String[], ValueType[]>());
+	}
+	
+	/**
+	 * 
+	 * @param sc
+	 * @param df
+	 * @param mc
+	 * @param containsID
+	 * @param out
+	 * @return
+	 * @throws DMLRuntimeException
+	 */
+	public static JavaPairRDD<Long, FrameBlock> dataFrameToBinaryBlock(JavaSparkContext sc,
+			DataFrame df, MatrixCharacteristics mc, boolean containsID, Pair<String[],ValueType[]> out) 
+		throws DMLRuntimeException 
+	{
 		//determine unknown dimensions if required
 		if( !mc.dimsKnown() ) { //nnz are irrelevant here
 			int colVect = getColVectFromDFSchema(df.schema(), containsID);
@@ -345,7 +362,8 @@ public class FrameRDDConverterUtils
 		String[] colnames = new String[(int)mc.getCols()];
 		ValueType[] fschema = new ValueType[(int)mc.getCols()];
 		int colVect = convertDFSchemaToFrameSchema(df.schema(), colnames, fschema, containsID);
-				
+		out.set(colnames, fschema); //make schema available
+		
 		//convert rdd to binary block rdd
 		return prepinput.mapPartitionsToPair(
 				new DataFrameToBinaryBlockFunction(mc, colnames, fschema, containsID, colVect));

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/test/java/org/apache/sysml/test/integration/functions/mlcontext/DataFrameVectorScriptTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/mlcontext/DataFrameVectorScriptTest.java b/src/test/java/org/apache/sysml/test/integration/functions/mlcontext/DataFrameVectorScriptTest.java
new file mode 100644
index 0000000..05b8fce
--- /dev/null
+++ b/src/test/java/org/apache/sysml/test/integration/functions/mlcontext/DataFrameVectorScriptTest.java
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysml.test.integration.functions.mlcontext;
+
+import static org.apache.sysml.api.mlcontext.ScriptFactory.dml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.spark.SparkConf;
+import org.apache.spark.api.java.JavaRDD;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.apache.spark.mllib.linalg.DenseVector;
+import org.apache.spark.mllib.linalg.VectorUDT;
+import org.apache.spark.sql.DataFrame;
+import org.apache.spark.sql.Row;
+import org.apache.spark.sql.RowFactory;
+import org.apache.spark.sql.SQLContext;
+import org.apache.spark.sql.types.DataType;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.StructField;
+import org.apache.spark.sql.types.StructType;
+import org.junit.Test;
+import org.apache.sysml.api.mlcontext.FrameFormat;
+import org.apache.sysml.api.mlcontext.FrameMetadata;
+import org.apache.sysml.api.mlcontext.MLContext;
+import org.apache.sysml.api.mlcontext.Matrix;
+import org.apache.sysml.api.mlcontext.Script;
+import org.apache.sysml.conf.ConfigurationManager;
+import org.apache.sysml.parser.Expression.ValueType;
+import org.apache.sysml.runtime.DMLRuntimeException;
+import org.apache.sysml.runtime.instructions.spark.utils.RDDConverterUtils;
+import org.apache.sysml.runtime.matrix.MatrixCharacteristics;
+import org.apache.sysml.runtime.matrix.data.MatrixBlock;
+import org.apache.sysml.runtime.util.DataConverter;
+import org.apache.sysml.runtime.util.UtilFunctions;
+import org.apache.sysml.test.integration.AutomatedTestBase;
+import org.apache.sysml.test.integration.TestConfiguration;
+import org.apache.sysml.test.utils.TestUtils;
+
+
+public class DataFrameVectorScriptTest extends AutomatedTestBase 
+{
+	private final static String TEST_DIR = "functions/mlcontext/";
+	private final static String TEST_NAME = "DataFrameConversion";
+	private final static String TEST_CLASS_DIR = TEST_DIR + DataFrameVectorScriptTest.class.getSimpleName() + "/";
+
+	//schema restriction: single vector included
+	private final static ValueType[] schemaStrings = new ValueType[]{ValueType.OBJECT, ValueType.STRING, ValueType.STRING, ValueType.STRING};
+	private final static ValueType[] schemaDoubles = new ValueType[]{ValueType.DOUBLE, ValueType.DOUBLE, ValueType.OBJECT, ValueType.DOUBLE};
+	private final static ValueType[] schemaMixed1 = new ValueType[]{ValueType.OBJECT, ValueType.INT, ValueType.STRING, ValueType.DOUBLE, ValueType.INT};
+	private final static ValueType[] schemaMixed2 = new ValueType[]{ValueType.STRING, ValueType.OBJECT, ValueType.DOUBLE};
+	
+	private final static int rows1 = 2245;
+	private final static int colsVector = 7;
+	private final static double sparsity1 = 0.9;
+	private final static double sparsity2 = 0.1;
+	private final static double eps=0.0000000001;
+
+	@Override
+	public void setUp() {
+		addTestConfiguration(TEST_NAME, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] {"A", "B"}));
+	}
+
+	@Test
+	public void testVectorStringsConversionIDDenseUnknown() {
+		testDataFrameScriptInput(schemaStrings, true, false, true);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionIDDenseUnknown() {
+		testDataFrameScriptInput(schemaDoubles, true, false, true);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionIDDenseUnknown() {
+		testDataFrameScriptInput(schemaMixed1, true, false, true);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionIDDenseUnknown() {
+		testDataFrameScriptInput(schemaMixed2, true, false, true);
+	}
+	
+	@Test
+	public void testVectorStringsConversionIDDense() {
+		testDataFrameScriptInput(schemaStrings, true, false, false);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionIDDense() {
+		testDataFrameScriptInput(schemaDoubles, true, false, false);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionIDDense() {
+		testDataFrameScriptInput(schemaMixed1, true, false, false);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionIDDense() {
+		testDataFrameScriptInput(schemaMixed2, true, false, false);
+	}
+
+	@Test
+	public void testVectorStringsConversionIDSparseUnknown() {
+		testDataFrameScriptInput(schemaStrings, true, true, true);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionIDSparseUnknown() {
+		testDataFrameScriptInput(schemaDoubles, true, true, true);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionIDSparseUnknown() {
+		testDataFrameScriptInput(schemaMixed1, true, true, true);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionIDSparseUnknown() {
+		testDataFrameScriptInput(schemaMixed2, true, true, true);
+	}
+	
+	@Test
+	public void testVectorStringsConversionIDSparse() {
+		testDataFrameScriptInput(schemaStrings, true, true, false);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionIDSparse() {
+		testDataFrameScriptInput(schemaDoubles, true, true, false);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionIDSparse() {
+		testDataFrameScriptInput(schemaMixed1, true, true, false);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionIDSparse() {
+		testDataFrameScriptInput(schemaMixed2, true, true, false);
+	}
+
+	@Test
+	public void testVectorStringsConversionDenseUnknown() {
+		testDataFrameScriptInput(schemaStrings, false, false, true);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionDenseUnknown() {
+		testDataFrameScriptInput(schemaDoubles, false, false, true);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionDenseUnknown() {
+		testDataFrameScriptInput(schemaMixed1, false, false, true);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionDenseUnknown() {
+		testDataFrameScriptInput(schemaMixed2, false, false, true);
+	}
+	
+	@Test
+	public void testVectorStringsConversionDense() {
+		testDataFrameScriptInput(schemaStrings, false, false, false);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionDense() {
+		testDataFrameScriptInput(schemaDoubles, false, false, false);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionDense() {
+		testDataFrameScriptInput(schemaMixed1, false, false, false);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionDense() {
+		testDataFrameScriptInput(schemaMixed2, false, false, false);
+	}
+
+	@Test
+	public void testVectorStringsConversionSparseUnknown() {
+		testDataFrameScriptInput(schemaStrings, false, true, true);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionSparseUnknown() {
+		testDataFrameScriptInput(schemaDoubles, false, true, true);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionSparseUnknown() {
+		testDataFrameScriptInput(schemaMixed1, false, true, true);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionSparseUnknown() {
+		testDataFrameScriptInput(schemaMixed2, false, true, true);
+	}
+	
+	@Test
+	public void testVectorStringsConversionSparse() {
+		testDataFrameScriptInput(schemaStrings, false, true, false);
+	}
+	
+	@Test
+	public void testVectorDoublesConversionSparse() {
+		testDataFrameScriptInput(schemaDoubles, false, true, false);
+	}
+	
+	@Test
+	public void testVectorMixed1ConversionSparse() {
+		testDataFrameScriptInput(schemaMixed1, false, true, false);
+	}
+	
+	@Test
+	public void testVectorMixed2ConversionSparse() {
+		testDataFrameScriptInput(schemaMixed2, false, true, false);
+	}
+	
+	/**
+	 * 
+	 * @param schema
+	 * @param containsID
+	 * @param dense
+	 * @param unknownDims
+	 */
+	private void testDataFrameScriptInput(ValueType[] schema, boolean containsID, boolean dense, boolean unknownDims) {
+		
+		//TODO fix inconsistency ml context vs jmlc register Xf
+		
+		JavaSparkContext sc = null;
+		MLContext ml = null;
+		
+		try
+		{
+			//generate input data and setup metadata
+			int cols = schema.length + colsVector - 1;
+			double sparsity = dense ? sparsity1 : sparsity2; 
+			double[][] A = TestUtils.round(getRandomMatrix(rows1, cols, -10, 1000, sparsity, 2373)); 
+			MatrixBlock mbA = DataConverter.convertToMatrixBlock(A);
+			int blksz = ConfigurationManager.getBlocksize();
+			MatrixCharacteristics mc1 = new MatrixCharacteristics(rows1, cols, blksz, blksz, mbA.getNonZeros());
+			MatrixCharacteristics mc2 = unknownDims ? new MatrixCharacteristics() : new MatrixCharacteristics(mc1);
+			
+			//setup spark context
+			SparkConf conf = new SparkConf().setAppName("MLContextFrameTest").setMaster("local");
+			sc = new JavaSparkContext(conf);
+			SQLContext sqlctx = new SQLContext(sc);
+			
+			//create input data frame
+			DataFrame df = createDataFrame(sqlctx, mbA, containsID, schema);
+			FrameMetadata meta = new FrameMetadata(containsID ? FrameFormat.DF_WITH_INDEX : 
+				FrameFormat.DF, mc2.getRows(), mc2.getCols());
+			
+			//create mlcontext
+			ml = new MLContext(sc);
+			ml.setExplain(true);
+			
+			//run script and obtain result
+			Script script1 = dml(
+					//"Xf = read($Xffile); Xm = as.matrix(Xf); write(Xm, $Xmfile);")
+					"Xm = as.matrix(Xf);")
+				.in("Xf", df, meta).out("Xm");
+			Matrix Xm = ml.execute(script1).getMatrix("Xm");
+			MatrixBlock mbB = Xm.toBinaryBlockMatrix().getMatrixBlock();
+			
+			//compare frame blocks
+			double[][] B = DataConverter.convertToDoubleMatrix(mbB);
+			TestUtils.compareMatrices(A, B, rows1, cols, eps);
+		}
+		catch( Exception ex ) {
+			ex.printStackTrace();
+			throw new RuntimeException(ex);
+		}
+		finally {
+			// stop spark context to allow single jvm tests (otherwise the
+			// next test that tries to create a SparkContext would fail)
+			if( sc != null )
+				sc.stop();
+			// clear status mlcontext and spark exec context
+			if( ml != null )
+				ml.close();
+		}
+	}
+	
+	/**
+	 * 
+	 * @param sqlctx
+	 * @param mb
+	 * @param schema
+	 * @return
+	 * @throws DMLRuntimeException 
+	 */
+	@SuppressWarnings("resource")
+	private DataFrame createDataFrame(SQLContext sqlctx, MatrixBlock mb, boolean containsID, ValueType[] schema) 
+		throws DMLRuntimeException
+	{
+		//create in-memory list of rows
+		List<Row> list = new ArrayList<Row>();		 
+		int off = (containsID ? 1 : 0);
+		int clen = mb.getNumColumns() + off - colsVector + 1;
+		
+		for( int i=0; i<mb.getNumRows(); i++ ) {
+			Object[] row = new Object[clen];
+			if( containsID )
+				row[0] = i+1;
+			for( int j=0, j2=0; j<mb.getNumColumns(); j++, j2++ ) {
+				if( schema[j2] != ValueType.OBJECT ) {
+					row[j2+off] = UtilFunctions
+						.doubleToObject(schema[j2], mb.quickGetValue(i, j));
+				}
+				else {
+					double[] tmp = DataConverter.convertToDoubleVector(
+							mb.sliceOperations(i, i, j, j+colsVector-1, new MatrixBlock()));
+					row[j2+off] = new DenseVector(tmp);
+					j += colsVector-1;
+				}
+			}
+			list.add(RowFactory.create(row));
+		}
+		
+		//create data frame schema
+		List<StructField> fields = new ArrayList<StructField>();
+		if( containsID )
+			fields.add(DataTypes.createStructField(RDDConverterUtils.DF_ID_COLUMN, 
+					DataTypes.DoubleType, true));
+		for( int j=0; j<schema.length; j++ ) {
+			DataType dt = null;
+			switch(schema[j]) {
+				case STRING: dt = DataTypes.StringType; break;
+				case DOUBLE: dt = DataTypes.DoubleType; break;
+				case INT:    dt = DataTypes.LongType; break;
+				case OBJECT: dt = new VectorUDT(); break;
+				default: throw new RuntimeException("Unsupported value type.");
+			}
+			fields.add(DataTypes.createStructField("C"+(j+1), dt, true));
+		}
+		StructType dfSchema = DataTypes.createStructType(fields);
+				
+		//create rdd and data frame
+		JavaSparkContext sc = new JavaSparkContext(sqlctx.sparkContext());
+		JavaRDD<Row> rowRDD = sc.parallelize(list);
+		return sqlctx.createDataFrame(rowRDD, dfSchema);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/test_suites/java/org/apache/sysml/test/integration/functions/compress/ZPackageSuite.java
----------------------------------------------------------------------
diff --git a/src/test_suites/java/org/apache/sysml/test/integration/functions/compress/ZPackageSuite.java b/src/test_suites/java/org/apache/sysml/test/integration/functions/compress/ZPackageSuite.java
index 7d19ae9..52270e9 100644
--- a/src/test_suites/java/org/apache/sysml/test/integration/functions/compress/ZPackageSuite.java
+++ b/src/test_suites/java/org/apache/sysml/test/integration/functions/compress/ZPackageSuite.java
@@ -42,6 +42,7 @@ import org.junit.runners.Suite;
 	LargeCompressionTest.class,
 	LargeMatrixVectorMultTest.class,
 	LargeParMatrixVectorMultTest.class,
+	LargeParUnaryAggregateTest.class,
 	LargeVectorMatrixMultTest.class,
 	ParCompressionTest.class,
 	ParMatrixMultChainTest.class,

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/85a8746a/src/test_suites/java/org/apache/sysml/test/integration/functions/mlcontext/ZPackageSuite.java
----------------------------------------------------------------------
diff --git a/src/test_suites/java/org/apache/sysml/test/integration/functions/mlcontext/ZPackageSuite.java b/src/test_suites/java/org/apache/sysml/test/integration/functions/mlcontext/ZPackageSuite.java
index e5911ea..f1186a5 100644
--- a/src/test_suites/java/org/apache/sysml/test/integration/functions/mlcontext/ZPackageSuite.java
+++ b/src/test_suites/java/org/apache/sysml/test/integration/functions/mlcontext/ZPackageSuite.java
@@ -29,6 +29,7 @@ import org.junit.runners.Suite;
 	DataFrameMatrixConversionTest.class,
 	DataFrameRowFrameConversionTest.class,
 	DataFrameVectorFrameConversionTest.class,
+	DataFrameVectorScriptTest.class,
 	FrameTest.class,
 	GNMFTest.class
 })