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/04/14 19:04:49 UTC

[3/3] incubator-systemml git commit: [SYSTEMML-558] Fix frame copy/indexing w/ different schemas, tests

[SYSTEMML-558] Fix frame copy/indexing w/ different schemas, tests

This patch generalizes the frame copy primitive to allow different
schemas for source and target frames. There are multiple usecases like
reading of frames in binary block, leftindexing, and frame reuse where
this flexibility leads to much better robustness. With regard to
performance, we still provide a fast special case if schemas of source
and target match (per column).

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

Branch: refs/heads/master
Commit: 356bd9b4690f1a921dee9f6281b23f7167727abd
Parents: cd1bc96
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Wed Apr 13 20:11:02 2016 -0700
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Thu Apr 14 10:04:03 2016 -0700

----------------------------------------------------------------------
 .../sysml/runtime/matrix/data/FrameBlock.java   | 25 ++++++++++++--------
 .../transform/TransformEncodeDecodeTest.java    |  3 ---
 2 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/356bd9b4/src/main/java/org/apache/sysml/runtime/matrix/data/FrameBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/FrameBlock.java b/src/main/java/org/apache/sysml/runtime/matrix/data/FrameBlock.java
index de3aca9..51b3243 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/FrameBlock.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/FrameBlock.java
@@ -38,6 +38,7 @@ import org.apache.sysml.parser.Expression.ValueType;
 import org.apache.sysml.runtime.DMLRuntimeException;
 import org.apache.sysml.runtime.controlprogram.caching.CacheBlock;
 import org.apache.sysml.runtime.util.IndexRange;
+import org.apache.sysml.runtime.util.UtilFunctions;
 
 /**
  * 
@@ -596,14 +597,10 @@ public class FrameBlock implements Writable, CacheBlock, Externalizable
 	/**
 	 * 
 	 * @param src
+	 * @throws DMLRuntimeException 
 	 */
 	public void copy(FrameBlock src) {
-		//allocate 
-		ensureAllocatedColumns(src.getNumRows());
-		
-		//actual copy 
-		for( int i=0; i<src.getNumColumns(); i++ )
-			_coldata.get(i).set(0, src.getNumRows()-1, src._coldata.get(i));
+		copy(0, src.getNumRows()-1, 0, src.getNumColumns()-1, src);
 	}
 
 	/**
@@ -613,16 +610,24 @@ public class FrameBlock implements Writable, CacheBlock, Externalizable
 	 * @param cl
 	 * @param cu
 	 * @param src
-	 * @throws DMLRuntimeException
 	 */
 	public void copy(int rl, int ru, int cl, int cu, FrameBlock src) 
-		throws DMLRuntimeException
 	{
+		//allocate columns if necessary
 		ensureAllocatedColumns(ru-rl+1);
 		
 		//copy values
-		for( int i=cl; i<=cu; i++ )
-			_coldata.get(i).set(rl, ru, src._coldata.get(i-cl));
+		for( int j=cl; j<=cu; j++ ) {
+			//special case: column memcopy 
+			if( _schema.get(j).equals(src._schema.get(j-cl)) )
+				_coldata.get(j).set(rl, ru, src._coldata.get(j-cl));
+			//general case w/ schema transformation
+			else 
+				for( int i=rl; i<=ru; i++ ) {
+					String tmp = src.get(i-rl, j)!=null ? src.get(i-rl, j).toString() : null;
+					set(i, j, UtilFunctions.stringToObject(_schema.get(j), tmp));
+				}
+		}
 	}
 		
 

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/356bd9b4/src/test/java/org/apache/sysml/test/integration/functions/transform/TransformEncodeDecodeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/transform/TransformEncodeDecodeTest.java b/src/test/java/org/apache/sysml/test/integration/functions/transform/TransformEncodeDecodeTest.java
index 551e529..9146183 100644
--- a/src/test/java/org/apache/sysml/test/integration/functions/transform/TransformEncodeDecodeTest.java
+++ b/src/test/java/org/apache/sysml/test/integration/functions/transform/TransformEncodeDecodeTest.java
@@ -82,7 +82,6 @@ public class TransformEncodeDecodeTest extends AutomatedTestBase
 		runTransformEncodeDecodeTest(ExecType.CP, true, "text");
 	}
 	
-	/*TODO to enable binary, we need to properly propagate schema first
 	@Test
 	public void runTestBinaryDenseCP() {
 		runTransformEncodeDecodeTest(ExecType.CP, false, "binary");
@@ -92,8 +91,6 @@ public class TransformEncodeDecodeTest extends AutomatedTestBase
 	public void runTestBinarySparseCP() {
 		runTransformEncodeDecodeTest(ExecType.CP, true, "binary");
 	}
-	*/
-
 	
 	/**
 	 *