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 2017/06/20 03:56:44 UTC

[2/2] systemml git commit: [SYSTEMML-1722] Fix mvvar to non-default file system (w/o rename)

[SYSTEMML-1722] Fix mvvar to non-default file system (w/o rename)

This patch fixes the code path of mvvar to become aware of the source
and target file URI scheme in order to avoid a rename in case of
different schemes. 

Furthermore, this patch also removes the obsolete mv and rm file
instructions, which are unused for many years (since they were replaced
by mvvar and rmvar). 


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

Branch: refs/heads/master
Commit: e503d96f0af164139339dc471724881260b8dbe1
Parents: 68fe8f6
Author: Matthias Boehm <mb...@gmail.com>
Authored: Mon Jun 19 20:56:47 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Mon Jun 19 20:56:47 2017 -0700

----------------------------------------------------------------------
 .../hops/cost/CostEstimatorStaticRuntime.java   |   3 -
 .../controlprogram/caching/CacheableData.java   |   8 +-
 .../instructions/CPInstructionParser.java       |  12 +-
 .../runtime/instructions/cp/CPInstruction.java  |   2 +-
 .../instructions/cp/FileCPInstruction.java      | 130 -------------------
 5 files changed, 9 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/e503d96f/src/main/java/org/apache/sysml/hops/cost/CostEstimatorStaticRuntime.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/cost/CostEstimatorStaticRuntime.java b/src/main/java/org/apache/sysml/hops/cost/CostEstimatorStaticRuntime.java
index f8cd476..b868d0d 100644
--- a/src/main/java/org/apache/sysml/hops/cost/CostEstimatorStaticRuntime.java
+++ b/src/main/java/org/apache/sysml/hops/cost/CostEstimatorStaticRuntime.java
@@ -949,9 +949,6 @@ public class CostEstimatorStaticRuntime extends CostEstimator
 					//note: all relational ops are not sparsesafe
 					return d3m * d3n; //covers all combinations of scalar and matrix  
 					
-				case File: //opcodes: rm, mv
-					return DEFAULT_NFLOP_NOOP;
-					
 				case Variable: //opcodes: assignvar, cpvar, rmvar, rmfilevar, assignvarwithfile, attachfiletovar, valuepick, iqsize, read, write, createvar, setfilename, castAsMatrix
 					if( optype.equals("write") ){
 						boolean text = args[0].equals("textcell") || args[0].equals("csv");

http://git-wip-us.apache.org/repos/asf/systemml/blob/e503d96f/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java b/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
index 8532062..4084eb9 100644
--- a/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
+++ b/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
@@ -1357,9 +1357,13 @@ public abstract class CacheableData<T extends CacheBlock> extends Data
 		
 		try
 		{
+			//check for common file scheme (otherwise no copy/rename)
+			boolean eqScheme = IOUtilFunctions.isSameFileScheme(
+				new Path(_hdfsFileName), new Path(fName));
+			
 			//export or rename to target file on hdfs
-			if( (isDirty() || (!isEqualOutputFormat(outputFormat) && isEmpty(true))) ||
-				(getRDDHandle() != null && !MapReduceTool.existsFileOnHDFS(_hdfsFileName)))
+			if( isDirty() || !eqScheme || (!isEqualOutputFormat(outputFormat) && isEmpty(true)) 
+				|| (getRDDHandle()!=null && !MapReduceTool.existsFileOnHDFS(_hdfsFileName)) )
 			{
 				exportData(fName, outputFormat);
 				ret = true;

http://git-wip-us.apache.org/repos/asf/systemml/blob/e503d96f/src/main/java/org/apache/sysml/runtime/instructions/CPInstructionParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/CPInstructionParser.java b/src/main/java/org/apache/sysml/runtime/instructions/CPInstructionParser.java
index 9126ab7..7088c50 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/CPInstructionParser.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/CPInstructionParser.java
@@ -45,7 +45,6 @@ import org.apache.sysml.runtime.instructions.cp.ConvolutionCPInstruction;
 import org.apache.sysml.runtime.instructions.cp.CovarianceCPInstruction;
 import org.apache.sysml.runtime.instructions.cp.DataGenCPInstruction;
 import org.apache.sysml.runtime.instructions.cp.DataPartitionCPInstruction;
-import org.apache.sysml.runtime.instructions.cp.FileCPInstruction;
 import org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction;
 import org.apache.sysml.runtime.instructions.cp.IndexingCPInstruction;
 import org.apache.sysml.runtime.instructions.cp.MMChainCPInstruction;
@@ -143,11 +142,7 @@ public class CPInstructionParser extends InstructionParser
 		String2CPInstructionType.put( ">"    , CPINSTRUCTION_TYPE.RelationalBinary);
 		String2CPInstructionType.put( "<="   , CPINSTRUCTION_TYPE.RelationalBinary);
 		String2CPInstructionType.put( ">="   , CPINSTRUCTION_TYPE.RelationalBinary);
-
-		// File Instruction Opcodes 
-		String2CPInstructionType.put( "rm"   , CPINSTRUCTION_TYPE.File);
-		String2CPInstructionType.put( "mv"   , CPINSTRUCTION_TYPE.File);
-
+		
 		// Builtin Instruction Opcodes 
 		String2CPInstructionType.put( "log"  , CPINSTRUCTION_TYPE.Builtin);
 		String2CPInstructionType.put( "log_nz"  , CPINSTRUCTION_TYPE.Builtin);
@@ -360,10 +355,7 @@ public class CPInstructionParser extends InstructionParser
 				
 			case RelationalBinary:
 				return RelationalBinaryCPInstruction.parseInstruction(str);
-				
-			case File:
-				return FileCPInstruction.parseInstruction(str);
-				
+			
 			case Variable:
 				return VariableCPInstruction.parseInstruction(str);
 				

http://git-wip-us.apache.org/repos/asf/systemml/blob/e503d96f/src/main/java/org/apache/sysml/runtime/instructions/cp/CPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/CPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/CPInstruction.java
index dcd8d89..590dacb 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/cp/CPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/CPInstruction.java
@@ -33,7 +33,7 @@ public abstract class CPInstruction extends Instruction
 		AggregateUnary, AggregateBinary, AggregateTernary, ArithmeticBinary, 
 		Ternary, Quaternary, BooleanBinary, BooleanUnary, BuiltinBinary, BuiltinUnary, 
 		BuiltinMultiple, MultiReturnParameterizedBuiltin, ParameterizedBuiltin, MultiReturnBuiltin, 
-		Builtin, Reorg, RelationalBinary, File, Variable, External, Append, Rand, QSort, QPick, 
+		Builtin, Reorg, RelationalBinary, Variable, External, Append, Rand, QSort, QPick, 
 		MatrixIndexing, MMTSJ, PMMJ, MMChain, MatrixReshape, Partition, Compression, SpoofFused,
 		StringInit, CentralMoment, Covariance, UaggOuterChain, Convolution };
 	

http://git-wip-us.apache.org/repos/asf/systemml/blob/e503d96f/src/main/java/org/apache/sysml/runtime/instructions/cp/FileCPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/FileCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/FileCPInstruction.java
deleted file mode 100644
index 404c26e..0000000
--- a/src/main/java/org/apache/sysml/runtime/instructions/cp/FileCPInstruction.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.runtime.instructions.cp;
-
-import java.io.IOException;
-
-import org.apache.sysml.runtime.DMLRuntimeException;
-import org.apache.sysml.runtime.controlprogram.context.ExecutionContext;
-import org.apache.sysml.runtime.functionobjects.RemoveFile;
-import org.apache.sysml.runtime.functionobjects.RenameFile;
-import org.apache.sysml.runtime.instructions.InstructionUtils;
-import org.apache.sysml.runtime.matrix.operators.Operator;
-import org.apache.sysml.runtime.matrix.operators.SimpleOperator;
-import org.apache.sysml.runtime.util.MapReduceTool;
-
-
-
-public class FileCPInstruction extends CPInstruction 
-{
-	
-	private enum FileOperationCode {
-		RemoveFile, MoveFile
-	};
-
-	private FileOperationCode _code;
-	private String _input1;
-	private String _input2;
-	//private int _arity;
-	
-	public FileCPInstruction (Operator op, FileOperationCode code, String in1, String in2, int arity, String opcode, String istr )
-	{
-		super(op, opcode, istr);
-		_cptype = CPINSTRUCTION_TYPE.File;
-		_code = code;
-		_input1 = in1;
-		_input2 = in2;
-		//_arity = arity;
-	}
-
-	private static FileOperationCode getFileOperationCode ( String str ) 
-		throws DMLRuntimeException 
-	{
-		if ( str.equalsIgnoreCase("rm"))
-			return FileOperationCode.RemoveFile;
-		else if ( str.equalsIgnoreCase("mv") ) 
-			return FileOperationCode.MoveFile;
-		else
-			throw new DMLRuntimeException("Invalid function: " + str);
-	}
-	
-	public static FileCPInstruction parseInstruction ( String str ) 
-		throws DMLRuntimeException 
-	{
-		String opcode = InstructionUtils.getOpCode(str);
-		
-		int _arity = 2;
-		if ( opcode.equalsIgnoreCase("rm") ) 
-			_arity = 1;
-		
-		String[] parts = InstructionUtils.getInstructionPartsWithValueType ( str );
-		InstructionUtils.checkNumFields ( parts, _arity ); // there is no output, so we just have _arity
-		
-		String in1, in2;
-		opcode = parts[0];
-		FileOperationCode focode = getFileOperationCode(opcode); 
-		in1 = parts[1];
-		in2 = null;
-		if ( _arity == 2 )
-			in2 = parts[2];
-		
-		// Determine appropriate Function Object based on opcode
-		
-		if ( opcode.equalsIgnoreCase("rm") ) {
-			return new FileCPInstruction(new SimpleOperator(RemoveFile.getRemoveFileFnObject()), focode, in1, in2, _arity, opcode, str);
-		} 
-		else if ( opcode.equalsIgnoreCase("mv") ) {
-			return new FileCPInstruction(new SimpleOperator(RenameFile.getRenameFileFnObject()), focode, in1, in2, _arity, opcode, str);
-		}
-		return null;
-	}
-	
-	@Override
-	public void processInstruction(ExecutionContext ec) 
-		throws DMLRuntimeException 
-	{	
-		try 
-		{
-			switch(_code) 
-			{
-				case RemoveFile:
-					MapReduceTool.deleteFileIfExistOnHDFS(_input1);
-					MapReduceTool.deleteFileIfExistOnHDFS(_input1+".mtd");
-					break;
-				case MoveFile:
-					MapReduceTool.renameFileOnHDFS(_input1, _input2);
-					MapReduceTool.renameFileOnHDFS(_input1+".mtd", _input2+".mtd");
-					break;
-					
-				default:
-					throw new DMLRuntimeException("Unexpected opcode: " + _code);
-			}
-		} 
-		catch ( IOException e ) {
-			throw new DMLRuntimeException(e);
-		}
-		
-		// NO RESULT is produced
-		// pb.setVariable(output.getName(), sores);
-	}
-	
-	
-
-}