You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by lr...@apache.org on 2015/12/03 19:45:59 UTC
[28/78] [abbrv] [partial] incubator-systemml git commit: Move files
to new package folder structure
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/CombineUnary.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/CombineUnary.java b/src/main/java/com/ibm/bi/dml/lops/CombineUnary.java
deleted file mode 100644
index da843e1..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/CombineUnary.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import java.util.HashSet;
-
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.*;
-
-
-/**
- * Lop to represent an combine operation -- used ONLY in the context of sort.
- */
-
-public class CombineUnary extends Lop
-{
-
-
-
- /**
- * @param input - input lop
- * @param op - operation type
- */
-
- public CombineUnary(Lop input1, DataType dt, ValueType vt)
- {
- super(Lop.Type.CombineUnary, dt, vt);
- this.addInput(input1);
- input1.addOutput(this);
-
- /*
- * This lop gets piggybacked into, and can ONLY be executed in SORT_KEYS job
- */
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = false;
- lps.addCompatibility(JobType.SORT);
- this.lps.setProperties( inputs, ExecType.MR, ExecLocation.Map, breaksAlignment, aligner, definesMRJob );
- }
-
- public String toString()
- {
- return "combineunary";
- }
-
- @Override
- public String getInstructions(int input_index1, int output_index)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( "combineunary" );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( getInputs().get(0).prepInputOperand(input_index1));
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( this.prepOutputOperand(output_index));
-
- return sb.toString();
- }
-
- public static CombineUnary constructCombineLop(Lop input1,
- DataType dt, ValueType vt) {
-
- HashSet<Lop> set1 = new HashSet<Lop>();
- set1.addAll(input1.getOutputs());
-
- for (Lop lop : set1) {
- if ( lop.type == Lop.Type.CombineUnary ) {
- return (CombineUnary)lop;
- }
- }
-
- CombineUnary comn = new CombineUnary(input1, dt, vt);
- comn.setAllPositions(input1.getBeginLine(), input1.getBeginColumn(), input1.getEndLine(), input1.getEndLine());
- return comn;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/CumulativeOffsetBinary.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/CumulativeOffsetBinary.java b/src/main/java/com/ibm/bi/dml/lops/CumulativeOffsetBinary.java
deleted file mode 100644
index 290824a..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/CumulativeOffsetBinary.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import com.ibm.bi.dml.lops.Aggregate.OperationTypes;
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.*;
-
-
-/**
- *
- *
- */
-public class CumulativeOffsetBinary extends Lop
-{
-
- private OperationTypes _op;
- private double _initValue = 0;
-
- public CumulativeOffsetBinary(Lop data, Lop offsets, DataType dt, ValueType vt, OperationTypes op, ExecType et)
- throws LopsException
- {
- super(Lop.Type.CumulativeOffsetBinary, dt, vt);
- checkSupportedOperations(op);
- _op = op;
-
- init(data, offsets, dt, vt, et);
- }
-
- public CumulativeOffsetBinary(Lop data, Lop offsets, DataType dt, ValueType vt, double init, OperationTypes op, ExecType et)
- throws LopsException
- {
- super(Lop.Type.CumulativeOffsetBinary, dt, vt);
- checkSupportedOperations(op);
- _op = op;
-
- //in case of Spark, CumulativeOffset includes CumulativeSplit and hence needs the init value
- _initValue = init;
-
- init(data, offsets, dt, vt, et);
- }
-
- /**
- *
- * @param input
- * @param dt
- * @param vt
- * @param et
- */
- private void init(Lop input1, Lop input2, DataType dt, ValueType vt, ExecType et)
- {
- this.addInput(input1);
- this.addInput(input2);
- input1.addOutput(this);
- input2.addOutput(this);
-
- if( et == ExecType.MR )
- {
- //setup MR parameters
- boolean breaksAlignment = true;
- boolean aligner = false;
- boolean definesMRJob = false;
-
- lps.addCompatibility(JobType.GMR);
- lps.addCompatibility(JobType.DATAGEN);
- lps.setProperties(inputs, et, ExecLocation.Reduce, breaksAlignment, aligner, definesMRJob);
- }
- else //Spark/CP
- {
- //setup Spark parameters
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = false;
- lps.addCompatibility(JobType.INVALID);
- lps.setProperties( inputs, et, ExecLocation.ControlProgram, breaksAlignment, aligner, definesMRJob );
- }
- }
-
- public String toString() {
- return "CumulativeOffsetBinary";
- }
-
- /**
- *
- * @param op
- * @throws LopsException
- */
- private void checkSupportedOperations(OperationTypes op)
- throws LopsException
- {
- //sanity check for supported aggregates
- if( !(op == OperationTypes.KahanSum || op == OperationTypes.Product ||
- op == OperationTypes.Min || op == OperationTypes.Max) )
- {
- throw new LopsException("Unsupported aggregate operation type: "+op);
- }
- }
-
- private String getOpcode() {
- switch( _op ) {
- case KahanSum: return "bcumoffk+";
- case Product: return "bcumoff*";
- case Min: return "bcumoffmin";
- case Max: return "bcumoffmax";
- default: return null;
- }
- }
-
- @Override
- public String getInstructions(int input_index1, int input_index2, int output_index)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getOpcode() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(0).prepInputOperand(input_index1) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(1).prepInputOperand(input_index2) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( this.prepOutputOperand(output_index) );
-
- return sb.toString();
- }
-
- @Override
- public String getInstructions(String input1, String input2, String output)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getOpcode() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(0).prepInputOperand(input1) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(1).prepInputOperand(input2) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( this.prepOutputOperand(output) );
- if( getExecType() == ExecType.SPARK ) {
- sb.append( OPERAND_DELIMITOR );
- sb.append( _initValue );
- }
-
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/CumulativePartialAggregate.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/CumulativePartialAggregate.java b/src/main/java/com/ibm/bi/dml/lops/CumulativePartialAggregate.java
deleted file mode 100644
index 7590316..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/CumulativePartialAggregate.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import com.ibm.bi.dml.lops.Aggregate.OperationTypes;
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.*;
-
-
-/**
- *
- *
- */
-public class CumulativePartialAggregate extends Lop
-{
-
- private OperationTypes _op;
-
- public CumulativePartialAggregate(Lop input, DataType dt, ValueType vt, OperationTypes op, ExecType et)
- throws LopsException
- {
- super(Lop.Type.CumulativePartialAggregate, dt, vt);
-
- //sanity check for supported aggregates
- if( !(op == OperationTypes.KahanSum || op == OperationTypes.Product ||
- op == OperationTypes.Min || op == OperationTypes.Max) )
- {
- throw new LopsException("Unsupported aggregate operation type: "+op);
- }
- _op = op;
-
- init(input, dt, vt, et);
- }
-
- /**
- *
- * @param input
- * @param dt
- * @param vt
- * @param et
- */
- private void init(Lop input, DataType dt, ValueType vt, ExecType et)
- {
- this.addInput(input);
- input.addOutput(this);
-
- if( et == ExecType.MR )
- {
- //setup MR parameters
- boolean breaksAlignment = true;
- boolean aligner = false;
- boolean definesMRJob = false;
-
- lps.addCompatibility(JobType.GMR);
- lps.addCompatibility(JobType.DATAGEN);
- lps.setProperties(inputs, et, ExecLocation.Map, breaksAlignment, aligner, definesMRJob);
- }
- else //Spark/CP
- {
- //setup Spark parameters
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = false;
- lps.addCompatibility(JobType.INVALID);
- lps.setProperties( inputs, et, ExecLocation.ControlProgram, breaksAlignment, aligner, definesMRJob );
- }
- }
-
- @Override
- public String toString() {
- return "CumulativePartialAggregate";
- }
-
- /**
- *
- * @return
- */
- private String getOpcode()
- {
- switch( _op ) {
- case KahanSum: return "ucumack+";
- case Product: return "ucumac*";
- case Min: return "ucumacmin";
- case Max: return "ucumacmax";
- default: return null;
- }
- }
-
- @Override
- public String getInstructions(int input_index, int output_index)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getOpcode() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(0).prepInputOperand(input_index) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( this.prepOutputOperand(output_index) );
-
- return sb.toString();
- }
-
- @Override
- public String getInstructions(String input, String output)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getOpcode() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(0).prepInputOperand(input) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( this.prepOutputOperand(output) );
-
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/CumulativeSplitAggregate.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/CumulativeSplitAggregate.java b/src/main/java/com/ibm/bi/dml/lops/CumulativeSplitAggregate.java
deleted file mode 100644
index fc22c5e..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/CumulativeSplitAggregate.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.*;
-
-
-/**
- *
- */
-public class CumulativeSplitAggregate extends Lop
-{
-
- private double _initValue = 0;
-
- public CumulativeSplitAggregate(Lop input, DataType dt, ValueType vt, double init)
- throws LopsException
- {
- super(Lop.Type.CumulativeSplitAggregate, dt, vt);
- _initValue = init;
- init(input, dt, vt, ExecType.MR);
- }
-
- /**
- *
- * @param input
- * @param dt
- * @param vt
- * @param et
- */
- private void init(Lop input, DataType dt, ValueType vt, ExecType et) {
- this.addInput(input);
- input.addOutput(this);
-
- boolean breaksAlignment = true;
- boolean aligner = false;
- boolean definesMRJob = false;
-
- lps.addCompatibility(JobType.GMR);
- lps.addCompatibility(JobType.DATAGEN);
- lps.setProperties(inputs, et, ExecLocation.Map, breaksAlignment, aligner, definesMRJob);
- }
-
- public String toString() {
- return "CumulativeSplitAggregate";
- }
-
- private String getOpcode() {
- return "ucumsplit";
- }
-
- @Override
- public String getInstructions(int input_index, int output_index)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getOpcode() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(0).prepInputOperand(input_index) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( prepOutputOperand(output_index) );
- sb.append( OPERAND_DELIMITOR );
- sb.append( String.valueOf(_initValue) );
-
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/Data.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/Data.java b/src/main/java/com/ibm/bi/dml/lops/Data.java
deleted file mode 100644
index eca031d..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/Data.java
+++ /dev/null
@@ -1,619 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import java.util.HashMap;
-
-import com.ibm.bi.dml.hops.Hop.FileFormatTypes;
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.OutputParameters.Format;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.DataExpression;
-import com.ibm.bi.dml.parser.Expression.DataType;
-import com.ibm.bi.dml.parser.Expression.ValueType;
-
-
-
-/**
- * Lop to represent data objects. Data objects represent matrices, vectors,
- * variables, literals. Can be for both input and output.
- */
-
-public class Data extends Lop
-{
-
- public enum OperationTypes {READ,WRITE};
-
- FileFormatTypes formatType = FileFormatTypes.BINARY;
- OperationTypes operation;
- boolean literal_var = false;
- boolean transient_var = false;
-
- private HashMap<String, Lop> _inputParams;
-
- /**
- * Method to create literal LOPs.
- *
- * @param vt
- * @param literalValue
- * @return
- * @throws LopsException
- */
- public static Data createLiteralLop(ValueType vt, String literalValue) throws LopsException {
- // All literals have default format type of TEXT
- return new Data(OperationTypes.READ, null, null, null, literalValue, DataType.SCALAR, vt, false, FileFormatTypes.BINARY);
- }
-
- /**
- * Constructor to setup read or write LOP
- * In case of write: <code>input</code> must be provided. This will always be added as the first element in <code>input</code> array.
- * For literals: this function is invoked through the static method <code>createLiteralLop</code>.
- *
- * @param op
- * @param input
- * @param inputParametersLops
- * @param name
- * @param literal
- * @param dt
- * @param vt
- * @param isTransient
- * @throws LopsException
- */
- public Data(Data.OperationTypes op, Lop input, HashMap<String, Lop>
- inputParametersLops, String name, String literal, DataType dt, ValueType vt, boolean isTransient, FileFormatTypes fmt) throws LopsException
- {
- super(Lop.Type.Data, dt, vt);
-
- operation = op;
-
- transient_var = isTransient;
-
- // Either <code>name</code> or <code>literal</code> can be non-null.
- if(literal != null){
- if (transient_var )
- throw new LopsException("Invalid parameter values while setting up a Data LOP -- transient flag is invalid for a literal.");
- literal_var = true;
- this.getOutputParameters().setLabel(literal);
- }
- else if(name != null) {
- if ( transient_var )
- this.getOutputParameters().setLabel(name); // tvar+name
- else
- this.getOutputParameters().setLabel("p"+op+name);
- }
- else {
- throw new LopsException("Invalid parameter values while setting up a Data LOP -- the lop must have either literal value or a name.");
- }
-
- // WRITE operation must have an input Lops, we always put this
- // input Lops as the first element of WRITE input. The parameters of
- // WRITE operation are then put as the following input elements.
- if(input != null && operation == OperationTypes.WRITE)
- {
- this.addInput(input);
- input.addOutput(this);
- }
-
- _inputParams = inputParametersLops;
-
- if ( _inputParams != null ) {
- for (Lop lop : inputParametersLops.values()) {
- this.addInput(lop);
- lop.addOutput(this);
- }
- if ( inputParametersLops.get(DataExpression.IO_FILENAME)!= null
- && inputParametersLops.get(DataExpression.IO_FILENAME) instanceof Data )
- {
- OutputParameters outParams = ((Data)inputParametersLops.get(DataExpression.IO_FILENAME)).getOutputParameters();
- String fName = outParams.getLabel();
- this.getOutputParameters().setFile_name(fName);
- }
- }
-
- setFileFormatAndProperties(fmt);
- }
-
- private void setLopProperties() {
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = false;
-
-
- if ( getFileFormatType() == FileFormatTypes.CSV ) {
- Lop input = getInputs().get(0);
- // If the input is data transform, then csv write can be piggybacked onto TRANSFORM job.
- // Otherwise, the input must be converted to csv format via WriteCSV MR job.
- if ( input instanceof ParameterizedBuiltin
- && ((ParameterizedBuiltin)input).getOp() == com.ibm.bi.dml.lops.ParameterizedBuiltin.OperationTypes.TRANSFORM ) {
- lps.addCompatibility(JobType.TRANSFORM);
- definesMRJob = false;
- }
- else {
- lps.addCompatibility(JobType.CSV_WRITE);
- definesMRJob = true;
- }
- }
- else {
- /*
- * This lop can be executed in all job types except for RAND, PARTITION.
- * RAND: because all inputs must be of type random.
- */
- lps.addCompatibility(JobType.ANY);
- // reads are not compatible with RAND because RAND must have all inputs that are random
- if ( operation == OperationTypes.READ )
- lps.removeCompatibility(JobType.DATAGEN);
- else if ( operation == OperationTypes.WRITE ) {
- // WRITE lops are not compatible with jobs that produce an
- // intermediate output, which MUST be consumed by other subsequent lops
- lps.removeCompatibility(JobType.MMCJ);
- // If at all, SORT job can only write in BinaryBlock format
- if(this.getDataType() == DataType.MATRIX && formatType != FileFormatTypes.BINARY)
- lps.removeCompatibility(JobType.SORT);
- lps.removeCompatibility(JobType.COMBINE);
- }
- }
- // ExecType is invalid for Data lop
- this.lps.setProperties ( inputs, ExecType.INVALID, ExecLocation.Data, breaksAlignment, aligner, definesMRJob );
- }
-
- /**
- * Data-Lop-specific method to set the execution type for persistent write.
- * TODO: split lops into MR/CP lop.
- *
- * @param et
- */
- public void setExecType( ExecType et )
- {
- lps.execType = et;
- }
-
- /**
- * Method to set format types for input, output files.
- * @param type
- * @throws LopsException
- */
- public void setFileFormatAndProperties(FileFormatTypes type) throws LopsException
- {
- this.formatType = type ;
- if(type == FileFormatTypes.BINARY)
- this.outParams.setFormat(Format.BINARY) ;
- else if(type == FileFormatTypes.TEXT)
- this.outParams.setFormat(Format.TEXT) ;
- else if (type == FileFormatTypes.MM)
- this.outParams.setFormat(Format.MM);
- else if (type == FileFormatTypes.CSV )
- this.outParams.setFormat(Format.CSV);
- else
- throw new LopsException("Unexpected format: " + type);
- setLopProperties();
- }
-
- /**
- * method to get format type for input, output files.
- * @return
- */
- public FileFormatTypes getFileFormatType()
- {
- return formatType ;
- }
-
- @Override
- public String toString() {
-
- return getID() + ":" + "File_Name: " + this.getOutputParameters().getFile_name() + " " +
- "Label: " + this.getOutputParameters().getLabel() + " " + "Operation: = " + operation + " " +
- "Format: " + this.outParams.getFormat() + " Datatype: " + getDataType() + " Valuetype: " + getValueType() + " num_rows = " + this.getOutputParameters().getNumRows() + " num_cols = " +
- this.getOutputParameters().getNumCols();
- }
-
- /**
- * method to get operation type, i.e. read/write.
- * @return
- */
-
- public OperationTypes getOperationType()
- {
- return operation;
- }
-
- /**
- * method to get inputParams
- * @return
- */
- public HashMap<String, Lop> getInputParams(){
- return _inputParams;
- }
-
- public Lop getNamedInputLop(String name) {
- return _inputParams.get(name);
- }
-
- /**
- * method to check if this data lop represents a literal.
- * @return
- */
-
- public boolean isLiteral()
- {
- return literal_var;
-
- }
-
- public boolean getBooleanValue() throws LopsException {
- if(literal_var) {
- return Boolean.parseBoolean(getOutputParameters().getLabel());
- }
- else
- throw new LopsException("Cannot obtain the value of a non-literal variable at compile time.");
- }
-
- public double getDoubleValue() throws LopsException {
- if(literal_var) {
- return Double.parseDouble(getOutputParameters().getLabel());
- }
- else
- throw new LopsException("Cannot obtain the value of a non-literal variable at compile time.");
- }
-
- public long getLongValue() throws LopsException {
- if(literal_var) {
- ValueType vt = getValueType();
- switch(vt) {
- case INT:
- return Long.parseLong(getOutputParameters().getLabel());
- case DOUBLE:
- return (long) Double.parseDouble(getOutputParameters().getLabel());
-
- default:
- throw new LopsException("Encountered a non-numeric value " + (vt) + ", while a numeric value is expected.");
- }
- }
- else
- throw new LopsException("Can not obtain the value of a non-literal variable at compile time.");
- }
-
- public String getStringValue() throws LopsException {
- if(literal_var) {
- return getOutputParameters().getLabel();
- }
- else
- throw new LopsException("Cannot obtain the value of a non-literal variable at compile time.");
- }
-
- /**
- * Method to check if this represents a transient variable.
- * @return
- */
- public boolean isTransient()
- {
- return transient_var;
- }
-
- /**
- *
- * @return
- */
- public boolean isPersistentWrite()
- {
- return operation == OperationTypes.WRITE && !transient_var;
- }
-
- /**
- * Method to generate appropriate MR write instructions.
- * Explicit write instructions are generated only in case of external file formats
- * (e.g., CSV) except for MatrixMarket. MM format is overridden by TextCell, instead.
- *
- */
- @Override
- public String getInstructions(int input_index, int output_index) throws LopsException {
-
- OutputParameters oparams = getOutputParameters();
-
- if ( operation != OperationTypes.WRITE )
- throw new LopsException("This method should only be executed for generating MR Write instructions.");
-
- if ( oparams.getFormat() != Format.CSV )
- throw new LopsException("MR Write instructions can not be generated for the output format: " + oparams.getFormat() );
-
- StringBuilder sb = new StringBuilder();
- sb.append( "MR" );
- sb.append( OPERAND_DELIMITOR );
-
- // Generate opcode based on the output format
- if ( oparams.getFormat() == Format.CSV )
- sb.append( "csvwrite" );
- else
- throw new LopsException("MR Write instructions can not be generated for the output format: " + oparams.getFormat() );
-
- sb.append( OPERAND_DELIMITOR );
- sb.append ( getInputs().get(0).prepInputOperand(input_index));
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( this.prepOutputOperand(output_index));
-
- // Attach format-specific properties
- if(oparams.getFormat() == Format.CSV) {
- Data headerLop = (Data) getNamedInputLop(DataExpression.DELIM_HAS_HEADER_ROW);
- Data delimLop = (Data) getNamedInputLop(DataExpression.DELIM_DELIMITER);
- Data sparseLop = (Data) getNamedInputLop(DataExpression.DELIM_SPARSE);
-
- if (headerLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_HAS_HEADER_ROW
- + " must be a literal.");
- if (delimLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_DELIMITER
- + " must be a literal.");
- if (sparseLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_SPARSE
- + " must be a literal.");
-
- sb.append(OPERAND_DELIMITOR);
- sb.append(headerLop.getBooleanValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(delimLop.getStringValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(sparseLop.getBooleanValue());
- }
- else {
- throw new LopsException("MR Write instructions can not be generated for the output format: " + oparams.getFormat() );
- }
-
- return sb.toString();
- }
-
- /**
- * Method to get CP instructions for reading/writing scalars and matrices from/to HDFS.
- * This method generates CP read/write instructions.
- */
- @Override
- public String getInstructions(String input1, String input2)
- throws LopsException
- {
- if ( getOutputParameters().getFile_name() == null && operation == OperationTypes.READ )
- throw new LopsException(this.printErrorLocation() + "Data.getInstructions(): Exepecting a SCALAR data type, encountered " + getDataType());
-
- StringBuilder sb = new StringBuilder();
- if(this.getExecType() == ExecType.SPARK)
- sb.append( "SPARK" );
- else
- sb.append( "CP" );
- sb.append( OPERAND_DELIMITOR );
- if ( operation == OperationTypes.READ )
- {
- sb.append( "read" );
- sb.append( OPERAND_DELIMITOR );
- sb.append ( this.prepInputOperand(input1) );
- }
- else if ( operation == OperationTypes.WRITE)
- {
- sb.append( "write" );
- sb.append( OPERAND_DELIMITOR );
- sb.append ( getInputs().get(0).prepInputOperand(input1) );
- }
- else
- throw new LopsException(this.printErrorLocation() + "In Data Lop, Unknown operation: " + operation);
-
- sb.append( OPERAND_DELIMITOR );
- Lop fnameLop = _inputParams.get(DataExpression.IO_FILENAME);
- boolean literal = (fnameLop instanceof Data && ((Data)fnameLop).isLiteral());
- sb.append ( prepOperand(input2, DataType.SCALAR, ValueType.STRING, literal) );
-
- // attach outputInfo in case of matrices
- OutputParameters oparams = getOutputParameters();
- if ( operation == OperationTypes.WRITE ) {
- sb.append( OPERAND_DELIMITOR );
- String fmt = "";
- if ( getDataType() == DataType.MATRIX ) {
- if ( oparams.getFormat() == Format.MM )
- fmt = "matrixmarket";
- else if (oparams.getFormat() == Format.TEXT)
- fmt = "textcell";
- else if (oparams.getFormat() == Format.CSV)
- fmt = "csv";
- else if ( oparams.getFormat() == Format.BINARY ){
- if ( oparams.getRowsInBlock() > 0 || oparams.getColsInBlock() > 0 )
- fmt = "binaryblock";
- else
- fmt = "binarycell" ;
- }
- else {
- throw new LopsException("Unexpected format: " + oparams.getFormat());
- }
- }
- else {
- // scalars will always be written in text format
- fmt = "textcell";
- }
-
- sb.append( prepOperand(fmt, DataType.SCALAR, ValueType.STRING, true));
-
- if(oparams.getFormat() == Format.CSV) {
- Data headerLop = (Data) getNamedInputLop(DataExpression.DELIM_HAS_HEADER_ROW);
- Data delimLop = (Data) getNamedInputLop(DataExpression.DELIM_DELIMITER);
- Data sparseLop = (Data) getNamedInputLop(DataExpression.DELIM_SPARSE);
-
- if (headerLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_HAS_HEADER_ROW
- + " must be a literal for a seq operation.");
- if (delimLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_DELIMITER
- + " must be a literal for a seq operation.");
- if (sparseLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_SPARSE
- + " must be a literal for a seq operation.");
-
- sb.append(OPERAND_DELIMITOR);
- sb.append(headerLop.getBooleanValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(delimLop.getStringValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(sparseLop.getBooleanValue());
-
- if ( this.getExecType() == ExecType.SPARK )
- {
- boolean isInputMatrixBlock = true;
- Lop input = getInputs().get(0);
- if ( input instanceof ParameterizedBuiltin
- && ((ParameterizedBuiltin)input).getOp() == ParameterizedBuiltin.OperationTypes.TRANSFORM ) {
- // in the case of transform input, the input will be Text strings insteadof MatrixBlocks
- // This information is used to have correct class information while accessing RDDs from the symbol table
- isInputMatrixBlock = false;
- }
- sb.append(OPERAND_DELIMITOR);
- sb.append(isInputMatrixBlock);
- }
- }
-
- }
-
- return sb.toString();
- }
-
- /**
- * Method to generate createvar instruction that updates symbol table with metadata, hdfsfile name, etc.
- *
- * @throws LopsException
- */
- public String getInstructions() throws LopsException {
- return getCreateVarInstructions(getOutputParameters().getFile_name(), getOutputParameters().getLabel());
- }
-
- public String getInstructions(String outputFileName) throws LopsException {
- return getCreateVarInstructions(outputFileName, getOutputParameters().getLabel() );
- }
-
- public String getCreateVarInstructions(String outputFileName, String outputLabel) throws LopsException {
- if ( getDataType() == DataType.MATRIX || getDataType() == DataType.FRAME ) {
-
- if ( isTransient() )
- throw new LopsException("getInstructions() should not be called for transient nodes.");
-
- OutputParameters oparams = getOutputParameters();
- String fmt = "";
- // TODO: following logic should change once we LOPs encode key-value-class information.
- if ( oparams.getFormat() == Format.TEXT )
- fmt = "textcell";
- else if ( oparams.getFormat() == Format.MM )
- fmt = "matrixmarket";
- else if ( oparams.getFormat() == Format.CSV )
- fmt = "csv";
- else {
- if ( oparams.getRowsInBlock() > 0 || oparams.getColsInBlock() > 0 )
- fmt = "binaryblock";
- else
- fmt = "binarycell";
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append( "CP" );
- sb.append( OPERAND_DELIMITOR );
- sb.append( "createvar" );
- sb.append( OPERAND_DELIMITOR );
- sb.append( outputLabel );
- sb.append( OPERAND_DELIMITOR );
- sb.append( outputFileName );
- sb.append( OPERAND_DELIMITOR );
- sb.append( false );
- sb.append( OPERAND_DELIMITOR ); // only persistent reads come here!
- sb.append( fmt );
- sb.append( OPERAND_DELIMITOR );
- sb.append( oparams.getNumRows() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( oparams.getNumCols() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( oparams.getRowsInBlock() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( oparams.getColsInBlock() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( oparams.getNnz() );
-
- /* Format-specific properties */
- if ( oparams.getFormat() == Format.CSV ) {
- sb.append( OPERAND_DELIMITOR );
- sb.append( createVarCSVHelper() );
- }
-
- return sb.toString();
- }
- else {
- throw new LopsException(this.printErrorLocation() + "In Data Lop, Unexpected data type " + getDataType());
- }
- }
-
- /**
- * Helper function that attaches CSV format-specific properties to createvar instruction.
- * The set of properties that are attached for a READ operation is different from that for a WRITE operation.
- *
- * @return
- * @throws LopsException
- */
- private String createVarCSVHelper() throws LopsException {
- StringBuilder sb = new StringBuilder();
- if ( operation == OperationTypes.READ ) {
- Data headerLop = (Data) getNamedInputLop(DataExpression.DELIM_HAS_HEADER_ROW);
- Data delimLop = (Data) getNamedInputLop(DataExpression.DELIM_DELIMITER);
- Data fillLop = (Data) getNamedInputLop(DataExpression.DELIM_FILL);
- Data fillValueLop = (Data) getNamedInputLop(DataExpression.DELIM_FILL_VALUE);
- Data naLop = (Data) getNamedInputLop(DataExpression.DELIM_NA_STRINGS);
-
- sb.append(headerLop.getBooleanValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(delimLop.getStringValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(fillLop.getBooleanValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(fillValueLop.getDoubleValue());
- if ( naLop != null ) {
- sb.append(OPERAND_DELIMITOR);
- sb.append(naLop.getStringValue());
- }
- }
- else { // (operation == OperationTypes.WRITE)
- Data headerLop = (Data) getNamedInputLop(DataExpression.DELIM_HAS_HEADER_ROW);
- Data delimLop = (Data) getNamedInputLop(DataExpression.DELIM_DELIMITER);
- Data sparseLop = (Data) getNamedInputLop(DataExpression.DELIM_SPARSE);
-
- if (headerLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_HAS_HEADER_ROW
- + " must be a literal for a seq operation.");
- if (delimLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_DELIMITER
- + " must be a literal for a seq operation.");
- if (sparseLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.DELIM_SPARSE
- + " must be a literal for a seq operation.");
-
- sb.append(headerLop.getBooleanValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(delimLop.getStringValue());
- sb.append(OPERAND_DELIMITOR);
- sb.append(sparseLop.getBooleanValue());
- }
- return sb.toString();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/DataGen.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/DataGen.java b/src/main/java/com/ibm/bi/dml/lops/DataGen.java
deleted file mode 100644
index 9cea440..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/DataGen.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import java.util.HashMap;
-
-import com.ibm.bi.dml.hops.Hop.DataGenMethod;
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.OutputParameters.Format;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.DataIdentifier;
-import com.ibm.bi.dml.parser.DataExpression;
-import com.ibm.bi.dml.parser.Statement;
-import com.ibm.bi.dml.parser.Expression.*;
-
-
-/**
- * <p>Defines a LOP that generates data.</p>
- */
-public class DataGen extends Lop
-{
-
- public static final String RAND_OPCODE = "rand"; //rand
- public static final String SEQ_OPCODE = "seq"; //sequence
- public static final String SINIT_OPCODE = "sinit"; //string initialize
- public static final String SAMPLE_OPCODE = "sample"; //sample.int
-
- private int _numThreads = 1;
-
- /** base dir for rand input */
- private String baseDir;
-
- private HashMap<String, Lop> _inputParams;
- DataGenMethod method;
-
- /**
- * <p>Creates a new Rand-LOP. The target identifier has to hold the dimensions of the new random object.</p>
- *
- * @param id target identifier
- * @param inputParameterLops Lops of input parameters
- * @param baseDir base dir for runtime
- * @param dt Data type
- * @param vt Value type
- * @param ExecType Execution type
- */
- public DataGen(DataGenMethod mthd, DataIdentifier id, HashMap<String, Lop>
- inputParametersLops, String baseDir, DataType dt, ValueType vt, ExecType et) throws LopsException
- {
- super(Type.DataGen, dt, vt);
- method = mthd;
-
- for (Lop lop : inputParametersLops.values()) {
- this.addInput(lop);
- lop.addOutput(this);
- }
-
- _inputParams = inputParametersLops;
-
- init(id, baseDir, et);
- }
-
- public DataGenMethod getDataGenMethod() {
- return method;
- }
-
- public void init(DataIdentifier id, String baseDir, ExecType et)
- {
- this.getOutputParameters().setFormat(Format.BINARY);
- this.getOutputParameters().setBlocked(true);
- this.getOutputParameters().setNumRows(id.getDim1());
- this.getOutputParameters().setNumCols(id.getDim2());
- this.getOutputParameters().setNnz(-1);
- this.getOutputParameters().setRowsInBlock(id.getRowsInBlock());
- this.getOutputParameters().setColsInBlock(id.getColumnsInBlock());
-
- this.baseDir = baseDir;
-
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob;
-
- if ( et == ExecType.MR ) {
- definesMRJob = true;
- lps.addCompatibility(JobType.DATAGEN);
- this.lps.setProperties( inputs, et, ExecLocation.Map, breaksAlignment, aligner, definesMRJob);
- }
- else {
- definesMRJob = false;
- lps.addCompatibility(JobType.INVALID);
- this.lps.setProperties( inputs, et, ExecLocation.ControlProgram, breaksAlignment, aligner, definesMRJob);
- }
- }
-
- /**
- * Function to generate CP/SP instructions for data generation via Rand and Seq.
- * Since DataGen Lop can have many inputs, ONLY the output variable name is
- * passed from piggybacking as the function argument <code>output</code>.
- */
- @Override
- public String getInstructions(String output)
- throws LopsException
- {
- switch( method )
- {
- case RAND:
- return getCPInstruction_Rand(output);
- case SINIT:
- return getCPInstruction_SInit(output);
- case SEQ:
- return getCPInstruction_Seq(output);
- case SAMPLE:
- return getCPInstruction_Sample(output);
-
- default:
- throw new LopsException("Unknown data generation method: " + method);
- }
- }
-
- @Override
- public String getInstructions(int inputIndex, int outputIndex)
- throws LopsException
- {
- switch(method) {
- case RAND:
- return getMRInstruction_Rand(inputIndex, outputIndex);
- case SEQ:
- return getMRInstruction_Seq(inputIndex, outputIndex);
-
- default:
- throw new LopsException("Unknown data generation method: " + method);
- }
- }
-
- /**
- * Private method that generates CP Instruction for Rand.
- * @param output
- * @return
- * @throws LopsException
- */
- private String getCPInstruction_Rand(String output)
- throws LopsException
- {
- //sanity checks
- if ( method != DataGenMethod.RAND )
- throw new LopsException("Invalid instruction generation for data generation method " + method);
- if( getInputs().size() != DataExpression.RAND_VALID_PARAM_NAMES.length ) {
- throw new LopsException(printErrorLocation() + "Invalid number of operands ("
- + getInputs().size() + ") for a Rand operation");
- }
-
- StringBuilder sb = new StringBuilder( );
-
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- sb.append(RAND_OPCODE);
- sb.append(OPERAND_DELIMITOR);
-
- Lop iLop = _inputParams.get(DataExpression.RAND_ROWS.toString());
- sb.append(iLop.prepScalarLabel());
- sb.append(OPERAND_DELIMITOR);
-
- iLop = _inputParams.get(DataExpression.RAND_COLS.toString());
- sb.append(iLop.prepScalarLabel());
- sb.append(OPERAND_DELIMITOR);
-
- sb.append(String.valueOf(getOutputParameters().getRowsInBlock()));
- sb.append(OPERAND_DELIMITOR);
-
- sb.append(String.valueOf(getOutputParameters().getColsInBlock()));
- sb.append(OPERAND_DELIMITOR);
-
- iLop = _inputParams.get(DataExpression.RAND_MIN.toString());
- sb.append(iLop.prepScalarLabel());
- sb.append(OPERAND_DELIMITOR);
-
- iLop = _inputParams.get(DataExpression.RAND_MAX.toString());
- sb.append(iLop.prepScalarLabel());
- sb.append(OPERAND_DELIMITOR);
-
- iLop = _inputParams.get(DataExpression.RAND_SPARSITY.toString()); //no variable support
- if (iLop.isVariable())
- throw new LopsException(printErrorLocation()
- + "Parameter " + DataExpression.RAND_SPARSITY
- + " must be a literal for a Rand operation.");
- sb.append(iLop.getOutputParameters().getLabel());
- sb.append(OPERAND_DELIMITOR);
-
- iLop = _inputParams.get(DataExpression.RAND_SEED.toString());
- sb.append(iLop.prepScalarLabel());
- sb.append(OPERAND_DELIMITOR);
-
- if ( getExecType() == ExecType.MR ) {
- sb.append(baseDir);
- sb.append(OPERAND_DELIMITOR);
- }
-
- iLop = _inputParams.get(DataExpression.RAND_PDF.toString()); //no variable support
- if (iLop.isVariable())
- throw new LopsException(printErrorLocation()
- + "Parameter " + DataExpression.RAND_PDF
- + " must be a literal for a Rand operation.");
- sb.append(iLop.getOutputParameters().getLabel());
- sb.append(OPERAND_DELIMITOR);
-
- iLop = _inputParams.get(DataExpression.RAND_LAMBDA.toString()); //no variable support
- sb.append(iLop == null ? "" : iLop.prepScalarLabel());
- sb.append(OPERAND_DELIMITOR);
-
- if( getExecType() == ExecType.CP ) {
- //append degree of parallelism
- sb.append( _numThreads );
- sb.append( OPERAND_DELIMITOR );
- }
-
- sb.append( prepOutputOperand(output));
-
- return sb.toString();
- }
-
- /**
- *
- * @param output
- * @return
- * @throws LopsException
- */
- private String getCPInstruction_SInit(String output)
- throws LopsException
- {
- if ( method != DataGenMethod.SINIT )
- throw new LopsException("Invalid instruction generation for data generation method " + method);
-
- //prepare instruction parameters
- Lop iLop = _inputParams.get(DataExpression.RAND_ROWS.toString());
- String rowsString = iLop.prepScalarLabel();
-
- iLop = _inputParams.get(DataExpression.RAND_COLS.toString());
- String colsString = iLop.prepScalarLabel();
-
- String rowsInBlockString = String.valueOf(this
- .getOutputParameters().getRowsInBlock());
- String colsInBlockString = String.valueOf(this
- .getOutputParameters().getColsInBlock());
-
- iLop = _inputParams.get(DataExpression.RAND_MIN.toString());
- String minString = iLop.getOutputParameters().getLabel();
- if (iLop.isVariable())
- throw new LopsException(this.printErrorLocation()
- + "Parameter " + DataExpression.RAND_MIN
- + " must be a literal for a Rand operation.");
-
- //generate instruction
- StringBuilder sb = new StringBuilder( );
- ExecType et = getExecType();
-
- sb.append( et );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append(SINIT_OPCODE);
- sb.append(OPERAND_DELIMITOR);
- sb.append(rowsString);
- sb.append(OPERAND_DELIMITOR);
- sb.append(colsString);
- sb.append(OPERAND_DELIMITOR);
- sb.append(rowsInBlockString);
- sb.append(OPERAND_DELIMITOR);
- sb.append(colsInBlockString);
- sb.append(OPERAND_DELIMITOR);
- sb.append(minString);
- sb.append(OPERAND_DELIMITOR);
- sb.append( this.prepOutputOperand(output));
-
- return sb.toString();
- }
-
- /**
- *
- * @param output
- * @return
- * @throws LopsException
- */
- private String getCPInstruction_Sample(String output)
- throws LopsException
- {
- if ( method != DataGenMethod.SAMPLE )
- throw new LopsException("Invalid instruction generation for data generation method " + method);
-
- //prepare instruction parameters
- Lop lsize = _inputParams.get(DataExpression.RAND_ROWS.toString());
- String size = lsize.prepScalarLabel();
-
- Lop lrange = _inputParams.get(DataExpression.RAND_MAX.toString());
- String range = lrange.prepScalarLabel();
-
- Lop lreplace = _inputParams.get(DataExpression.RAND_PDF.toString());
- String replace = lreplace.prepScalarLabel();
-
- Lop lseed = _inputParams.get(DataExpression.RAND_SEED.toString());
- String seed = lseed.prepScalarLabel();
-
- String rowsInBlockString = String.valueOf(this.getOutputParameters().getRowsInBlock());
- String colsInBlockString = String.valueOf(this.getOutputParameters().getColsInBlock());
-
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( "sample" );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( range );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( size );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( replace );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( seed );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( rowsInBlockString );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( colsInBlockString );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( prepOutputOperand(output) );
-
- return sb.toString();
- }
-
- /**
- * Private method that generates CP Instruction for Seq.
- * @param output
- * @return
- * @throws LopsException
- */
- private String getCPInstruction_Seq(String output) throws LopsException {
- if ( method != DataGenMethod.SEQ )
- throw new LopsException("Invalid instruction generation for data generation method " + method);
-
- StringBuilder sb = new StringBuilder( );
- ExecType et = getExecType();
- sb.append( et );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- Lop iLop = null;
-
- iLop = _inputParams.get(Statement.SEQ_FROM.toString());
- String fromString = iLop.prepScalarLabel();
-
- iLop = _inputParams.get(Statement.SEQ_TO.toString());
- String toString = iLop.prepScalarLabel();
-
- iLop = _inputParams.get(Statement.SEQ_INCR.toString());
- String incrString = iLop.prepScalarLabel();
-
- String rowsString = String.valueOf(this.getOutputParameters().getNumRows());
- String colsString = String.valueOf(this.getOutputParameters().getNumCols());
- String rowsInBlockString = String.valueOf(this.getOutputParameters().getRowsInBlock());
- String colsInBlockString = String.valueOf(this.getOutputParameters().getColsInBlock());
-
- sb.append( DataGen.SEQ_OPCODE );
- sb.append( OPERAND_DELIMITOR );
- sb.append( rowsString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( colsString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( rowsInBlockString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( colsInBlockString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( fromString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( toString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( incrString );
- sb.append( OPERAND_DELIMITOR );
- if ( et == ExecType.MR ) {
- sb.append( baseDir );
- sb.append( OPERAND_DELIMITOR );
- }
- sb.append( this.prepOutputOperand(output));
-
- return sb.toString();
- }
-
- /**
- * Private method to generate MR instruction for Rand.
- *
- * @param input_index
- * @param output_index
- * @return
- * @throws LopsException
- */
- private String getMRInstruction_Rand(int inputIndex, int outputIndex)
- throws LopsException
- {
- //sanity checks
- if( getInputs().size() != DataExpression.RAND_VALID_PARAM_NAMES.length) {
- throw new LopsException(printErrorLocation() + "Invalid number of operands ("
- + getInputs().size() + ") for a Rand operation");
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- sb.append( RAND_OPCODE );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( inputIndex );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( outputIndex );
- sb.append( OPERAND_DELIMITOR );
-
- Lop iLop = _inputParams.get(DataExpression.RAND_ROWS.toString());
- sb.append( iLop.prepScalarInputOperand(getExecType()) );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_COLS.toString());
- sb.append( iLop.prepScalarInputOperand(getExecType()) );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( String.valueOf(getOutputParameters().getRowsInBlock()) );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( String.valueOf(getOutputParameters().getColsInBlock()) );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_MIN.toString());
- sb.append( iLop.prepScalarInputOperand(getExecType()) );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_MAX.toString());
- sb.append( iLop.prepScalarInputOperand(getExecType()) );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_SPARSITY.toString()); //no variable support
- if (iLop.isVariable())
- throw new LopsException(this.printErrorLocation() + "Parameter "
- + DataExpression.RAND_SPARSITY + " must be a literal for a Rand operation.");
- sb.append( iLop.getOutputParameters().getLabel() );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_SEED.toString());
- sb.append( iLop.prepScalarLabel() );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( baseDir );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_PDF.toString()); //no variable support
- if (iLop.isVariable())
- throw new LopsException(this.printErrorLocation() + "Parameter "
- + DataExpression.RAND_PDF + " must be a literal for a Rand operation.");
- sb.append( iLop.getOutputParameters().getLabel() );
- sb.append( OPERAND_DELIMITOR );
-
- iLop = _inputParams.get(DataExpression.RAND_LAMBDA.toString()); //no variable support
- sb.append( iLop == null ? "" : iLop.prepScalarLabel() );
-
- return sb.toString();
- }
-
- /**
- * Private method to generate MR instruction for Seq.
- *
- * @param input_index
- * @param output_index
- * @return
- * @throws LopsException
- */
- private String getMRInstruction_Seq(int inputIndex, int outputIndex) throws LopsException {
- StringBuilder sb = new StringBuilder();
-
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- Lop iLop = null;
- iLop = _inputParams.get(Statement.SEQ_FROM.toString());
- String fromString = iLop.getOutputParameters().getLabel();
- if ( (iLop.getExecLocation() == ExecLocation.Data &&
- !((Data)iLop).isLiteral()) || !(iLop.getExecLocation() == ExecLocation.Data ))
- fromString = Lop.VARIABLE_NAME_PLACEHOLDER + fromString + Lop.VARIABLE_NAME_PLACEHOLDER;
-
- iLop = _inputParams.get(Statement.SEQ_TO.toString());
- String toString = iLop.getOutputParameters().getLabel();
- if ( iLop.getExecLocation() == ExecLocation.Data
- && !((Data)iLop).isLiteral() || !(iLop.getExecLocation() == ExecLocation.Data ) )
- toString = Lop.VARIABLE_NAME_PLACEHOLDER + toString + Lop.VARIABLE_NAME_PLACEHOLDER;
-
- iLop = _inputParams.get(Statement.SEQ_INCR.toString());
- String incrString = iLop.getOutputParameters().getLabel();
- if ( iLop.getExecLocation() == ExecLocation.Data
- && !((Data)iLop).isLiteral() || !(iLop.getExecLocation() == ExecLocation.Data ) )
- incrString = Lop.VARIABLE_NAME_PLACEHOLDER + incrString + Lop.VARIABLE_NAME_PLACEHOLDER;
-
- String rowsString = String.valueOf(this.getOutputParameters().getNumRows());
- String colsString = String.valueOf(this.getOutputParameters().getNumCols());
- String rowsInBlockString = String.valueOf(this.getOutputParameters().getRowsInBlock());
- String colsInBlockString = String.valueOf(this.getOutputParameters().getColsInBlock());
-
- sb.append( DataGen.SEQ_OPCODE );
- sb.append( OPERAND_DELIMITOR );
- sb.append( inputIndex );
- sb.append( OPERAND_DELIMITOR );
- sb.append( outputIndex );
- sb.append( OPERAND_DELIMITOR );
- sb.append( rowsString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( colsString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( rowsInBlockString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( colsInBlockString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( fromString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( toString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( incrString );
- sb.append( OPERAND_DELIMITOR );
- sb.append( baseDir );
-
- return sb.toString();
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append(method.toString());
- sb.append(" ; num_rows=" + this.getOutputParameters().getNumRows());
- sb.append(" ; num_cols=" + this.getOutputParameters().getNumCols());
- sb.append(" ; nnz=" + this.getOutputParameters().getNnz());
- sb.append(" ; num_rows_per_block=" + this.getOutputParameters().getRowsInBlock());
- sb.append(" ; num_cols_per_block=" + this.getOutputParameters().getColsInBlock());
- sb.append(" ; format=" + this.getOutputParameters().getFormat());
- sb.append(" ; blocked=" + this.getOutputParameters().isBlocked());
- sb.append(" ; dir=" + this.baseDir);
- return sb.toString();
- }
-
- public void setNumThreads(int k) {
- _numThreads = k;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/DataPartition.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/DataPartition.java b/src/main/java/com/ibm/bi/dml/lops/DataPartition.java
deleted file mode 100644
index 1434611..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/DataPartition.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.DataType;
-import com.ibm.bi.dml.parser.Expression.ValueType;
-import com.ibm.bi.dml.runtime.controlprogram.ParForProgramBlock.PDataPartitionFormat;
-
-
-/**
- * Lop to perform data partitioning.
- */
-public class DataPartition extends Lop
-{
-
- public static final String OPCODE = "partition";
-
- private PDataPartitionFormat _pformat = null;
-
- public DataPartition(Lop input, DataType dt, ValueType vt, ExecType et, PDataPartitionFormat pformat)
- throws LopsException
- {
- super(Lop.Type.DataPartition, dt, vt);
- this.addInput(input);
- input.addOutput(this);
-
- _pformat = pformat;
-
- //setup lop properties
- ExecLocation eloc = (et==ExecType.MR)? ExecLocation.MapAndReduce : ExecLocation.ControlProgram;
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = (et==ExecType.MR);
- lps.addCompatibility(JobType.DATA_PARTITION);
- lps.setProperties( inputs, et, eloc, breaksAlignment, aligner, definesMRJob );
- }
-
- @Override
- public String toString() {
-
- return "DataPartition";
- }
-
- //CP instruction generation
- @Override
- public String getInstructions(String input_index, String output_index)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( OPCODE );
- sb.append( OPERAND_DELIMITOR );
- sb.append( input_index );
- sb.append( DATATYPE_PREFIX );
- sb.append( getInputs().get(0).getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getInputs().get(0).getValueType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( output_index );
- sb.append( DATATYPE_PREFIX );
- sb.append( getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getValueType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( _pformat.toString() );
-
- return sb.toString();
- }
-
- //MR instruction generation
- @Override
- public String getInstructions(int input_index, int output_index)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( OPCODE );
- sb.append( OPERAND_DELIMITOR );
- sb.append( input_index );
- sb.append( DATATYPE_PREFIX );
- sb.append( getInputs().get(0).getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getInputs().get(0).getValueType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( output_index );
- sb.append( DATATYPE_PREFIX );
- sb.append( getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getValueType() );
- sb.append( OPERAND_DELIMITOR );
- sb.append( _pformat.toString() );
-
- return sb.toString();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/FunctionCallCP.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/FunctionCallCP.java b/src/main/java/com/ibm/bi/dml/lops/FunctionCallCP.java
deleted file mode 100644
index e5ee9be..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/FunctionCallCP.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-
-import java.util.ArrayList;
-
-import com.ibm.bi.dml.hops.Hop;
-import com.ibm.bi.dml.hops.HopsException;
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.DMLProgram;
-import com.ibm.bi.dml.parser.Expression.DataType;
-import com.ibm.bi.dml.parser.Expression.ValueType;
-
-
-/**
- *
- */
-public class FunctionCallCP extends Lop
-{
- private String _fnamespace;
- private String _fname;
- private String[] _outputs;
- private ArrayList<Lop> _outputLops = null;
-
- public FunctionCallCP(ArrayList<Lop> inputs, String fnamespace, String fname, String[] outputs, ArrayList<Hop> outputHops) throws HopsException, LopsException {
- this(inputs, fnamespace, fname, outputs);
- if(outputHops != null) {
- _outputLops = new ArrayList<Lop>();
- for(Hop h : outputHops) {
- _outputLops.add( h.constructLops() );
- }
- }
- }
-
- public FunctionCallCP(ArrayList<Lop> inputs, String fnamespace, String fname, String[] outputs)
- {
- super(Lop.Type.FunctionCallCP, DataType.UNKNOWN, ValueType.UNKNOWN);
- //note: data scalar in order to prevent generation of redundant createvar, rmvar
-
- _fnamespace = fnamespace;
- _fname = fname;
- _outputs = outputs;
-
- //wire inputs
- for( Lop in : inputs )
- {
- addInput( in );
- in.addOutput( this );
- }
-
- //lop properties: always in CP
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = false;
- lps.addCompatibility(JobType.INVALID);
- this.lps.setProperties(inputs, ExecType.CP, ExecLocation.ControlProgram, breaksAlignment, aligner, definesMRJob );
- }
-
- public ArrayList<Lop> getFunctionOutputs() {
- return _outputLops;
- }
-
- @Override
- public String toString() {
- return "function call: " + DMLProgram.constructFunctionKey(_fnamespace, _fname);
- }
-
- private String getInstructionsMultipleReturnBuiltins(String[] inputs, String[] outputs) {
- StringBuilder sb = new StringBuilder();
- sb.append("CP");
-
- sb.append(Lop.OPERAND_DELIMITOR);
- sb.append(_fname.toLowerCase());
-
- for(int i=0; i< inputs.length; i++) {
- sb.append(Lop.OPERAND_DELIMITOR);
- sb.append( getInputs().get(i).prepInputOperand(inputs[i]) );
- }
-
- for(int i=0; i< _outputs.length; i++) {
- sb.append(Lop.OPERAND_DELIMITOR);
- sb.append(_outputs[i]);
- }
-
- return sb.toString();
- }
-
- /**
- * Method to generate instructions for external functions as well as builtin functions with multiple returns.
- * Builtin functions have their namespace set to DMLProgram.INTERNAL_NAMESPACE ("_internal").
- */
- @Override
- public String getInstructions(String[] inputs, String[] outputs) throws LopsException
- {
- // Handle internal builtin functions
- if (_fnamespace.equalsIgnoreCase(DMLProgram.INTERNAL_NAMESPACE) ) {
- return getInstructionsMultipleReturnBuiltins(inputs, outputs);
- }
-
- //Instruction format extFunct:::[FUNCTION NAMESPACE]:::[FUNCTION NAME]:::[num input params]:::[num output params]:::[list of delimited input params ]:::[list of delimited ouput params]
- //These are the "bound names" for the inputs / outputs. For example, out1 = ns::foo(in1, in2) yields
- //extFunct:::ns:::foo:::2:::1:::in1:::in2:::out1
- //NOTE: we have to append full input operand information to distinguish literals from variables w/ equal name
-
- StringBuilder inst = new StringBuilder();
-
- inst.append("CP");
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append("extfunct");
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append(_fnamespace);
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append(_fname);
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append(inputs.length);
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append(_outputs.length);
-
- for(int i=0; i<inputs.length; i++) {
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append( getInputs().get(i).prepInputOperand(inputs[i]) );
- }
-
- // TODO function output dataops (phase 3) - take 'outputs' into account
- for( String out : _outputs ) {
- inst.append(Lop.OPERAND_DELIMITOR);
- inst.append(out);
- }
-
- return inst.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/Group.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/Group.java b/src/main/java/com/ibm/bi/dml/lops/Group.java
deleted file mode 100644
index 7af0ca1..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/Group.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.*;
-
-/**
- * Lop to represent a grouping operation.
- */
-
-public class Group extends Lop
-{
-
-
-
- public enum OperationTypes {Sort};
-
- OperationTypes operation;
-
- /**
- * Constructor to create a grouping operation.
- * @param input
- * @param op
- */
-
- public Group(Lop input, Group.OperationTypes op, DataType dt, ValueType vt)
- {
- super(Lop.Type.Grouping, dt, vt);
- operation = op;
- this.addInput(input);
- input.addOutput(this);
-
- /*
- * This lop can be executed in only in GMR and RAND.
- * MMCJ, REBLOCK, and PARTITION themselves has location MapAndReduce.
- */
- lps.addCompatibility(JobType.GMR);
- lps.addCompatibility(JobType.DATAGEN);
-
- boolean breaksAlignment = false;
- boolean aligner = true;
- boolean definesMRJob = true;
-
- this.lps.setProperties ( inputs, ExecType.MR, ExecLocation.MapAndReduce, breaksAlignment, aligner, definesMRJob );
- }
-
- @Override
- public String toString()
- {
- //return "Group " + "Operation: " + operation;
- return "Operation: " + operation;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/GroupedAggregate.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/GroupedAggregate.java b/src/main/java/com/ibm/bi/dml/lops/GroupedAggregate.java
deleted file mode 100644
index 974844b..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/GroupedAggregate.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import java.util.HashMap;
-import java.util.Map.Entry;
-
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Statement;
-import com.ibm.bi.dml.parser.Expression.*;
-
-
-/**
- * Lop to perform grouped aggregates
- *
- */
-public class GroupedAggregate extends Lop
-{
-
- private HashMap<String, Lop> _inputParams;
- private static final String opcode = "groupedagg";
- public static final String COMBINEDINPUT = "combinedinput";
-
- /**
- * Constructor to perform grouped aggregate.
- * inputParameterLops <- parameters required to compute different aggregates (hashmap)
- * "combinedinput" -- actual data
- * "function" -- aggregate function
- */
-
- private void init(HashMap<String, Lop> inputParameterLops,
- DataType dt, ValueType vt, ExecType et) {
- if ( et == ExecType.MR ) {
- /*
- * Inputs to ParameterizedBuiltinOp can be in an arbitrary order. However,
- * piggybacking (Dag.java:getAggAndOtherInstructions()) expects the first
- * input to be the data (named as "combinedinput") on which the aggregate
- * needs to be computed. Make sure that "combinedinput" is the first input
- * to GroupedAggregate lop.
- */
- this.addInput(inputParameterLops.get(COMBINEDINPUT));
- inputParameterLops.get(COMBINEDINPUT).addOutput(this);
-
- // process remaining parameters
- for ( Entry<String, Lop> e : inputParameterLops.entrySet() ) {
- String k = e.getKey();
- Lop lop = e.getValue();
- if ( !k.equalsIgnoreCase(COMBINEDINPUT) ) {
- this.addInput(lop);
- lop.addOutput(this);
- }
- }
-
- _inputParams = inputParameterLops;
-
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = true;
- lps.addCompatibility(JobType.GROUPED_AGG);
- this.lps.setProperties(inputs, et, ExecLocation.MapAndReduce, breaksAlignment, aligner, definesMRJob);
- }
- else {
- boolean breaksAlignment = false;
- boolean aligner = false;
- boolean definesMRJob = false;
-
- // First, add inputs corresponding to "target" and "groups"
- this.addInput(inputParameterLops.get(Statement.GAGG_TARGET));
- inputParameterLops.get(Statement.GAGG_TARGET).addOutput(this);
- this.addInput(inputParameterLops.get(Statement.GAGG_GROUPS));
- inputParameterLops.get(Statement.GAGG_GROUPS).addOutput(this);
-
- // process remaining parameters
- for ( Entry<String, Lop> e : inputParameterLops.entrySet() ) {
- String k = e.getKey();
- Lop lop = e.getValue();
- if ( !k.equalsIgnoreCase(Statement.GAGG_TARGET) && !k.equalsIgnoreCase(Statement.GAGG_GROUPS) ) {
- this.addInput(lop);
- lop.addOutput(this);
- }
- }
- _inputParams = inputParameterLops;
-
- lps.addCompatibility(JobType.INVALID);
- this.lps.setProperties(inputs, et, ExecLocation.ControlProgram, breaksAlignment, aligner, definesMRJob);
- }
- }
-
- public GroupedAggregate(
- HashMap<String, Lop> inputParameterLops,
- DataType dt, ValueType vt) {
- this(inputParameterLops, dt, vt, ExecType.MR);
- }
-
- public GroupedAggregate(
- HashMap<String, Lop> inputParameterLops,
- DataType dt, ValueType vt, ExecType et) {
- super(Lop.Type.GroupedAgg, dt, vt);
- init(inputParameterLops, dt, vt, et);
- }
-
- @Override
- public String toString() {
-
- return "Operation = GroupedAggregate";
- }
-
- /**
- * Function to generate CP Grouped Aggregate Instructions.
- *
- */
- @Override
- public String getInstructions(String output)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- sb.append( opcode );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- if ( _inputParams.get(Statement.GAGG_TARGET) == null || _inputParams.get(Statement.GAGG_GROUPS) == null || _inputParams.get("fn") == null )
- throw new LopsException(this.printErrorLocation() + "Invalid parameters to groupedAggregate -- \"target\", \"groups\", \"fn\" must be provided");
-
- String targetVar = _inputParams.get(Statement.GAGG_TARGET).getOutputParameters().getLabel();
- String groupsVar = _inputParams.get(Statement.GAGG_GROUPS).getOutputParameters().getLabel();
-
- sb.append( Statement.GAGG_TARGET );
- sb.append( Lop.NAME_VALUE_SEPARATOR );
- sb.append( targetVar );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- sb.append( Statement.GAGG_GROUPS );
- sb.append( Lop.NAME_VALUE_SEPARATOR );
- sb.append( groupsVar );
-
- if ( _inputParams.get(Statement.GAGG_WEIGHTS) != null )
- {
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( Statement.GAGG_WEIGHTS );
- sb.append( Lop.NAME_VALUE_SEPARATOR );
- sb.append( _inputParams.get(Statement.GAGG_WEIGHTS).getOutputParameters().getLabel() );
- }
-
- // Process all other name=value parameters, which are scalars
- String name, valueString;
- Lop value;
- for(Entry<String, Lop> e : _inputParams.entrySet()) {
- name = e.getKey();
- if ( !name.equalsIgnoreCase(Statement.GAGG_TARGET) && !name.equalsIgnoreCase(Statement.GAGG_GROUPS) && !name.equalsIgnoreCase(Statement.GAGG_WEIGHTS) ) {
- value = e.getValue();
- valueString = value.prepScalarLabel();
-
- sb.append( OPERAND_DELIMITOR );
- sb.append( name );
- sb.append( Lop.NAME_VALUE_SEPARATOR );
- sb.append( valueString );
- }
- }
-
- sb.append( OPERAND_DELIMITOR );
- sb.append( this.prepOutputOperand(output));
-
- return sb.toString();
- }
-
- /*@Override
- public String getInstructions(String input1, String input2, String output)
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
- sb.append( "groupedagg" );
- sb.append( OPERAND_DELIMITOR );
- sb.append( input1 );
- sb.append( DATATYPE_PREFIX );
- sb.append( getInputs().get(0).getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getInputs().get(0).getValueType() );
- sb.append( input2 );
- sb.append( DATATYPE_PREFIX );
- sb.append( getInputs().get(1).getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getInputs().get(1).getValueType() );
- sb.append( output );
- sb.append( DATATYPE_PREFIX );
- sb.append( getDataType() );
- sb.append( VALUETYPE_PREFIX );
- sb.append( getValueType() );
-
- return sb.toString();
- }*/
-
- @Override
- public String getInstructions(int input_index, int output_index)
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( Lop.OPERAND_DELIMITOR );
-
- sb.append( opcode );
- sb.append( OPERAND_DELIMITOR );
- sb.append( getInputs().get(0).prepInputOperand(input_index));
-
- // get the aggregate function
- sb.append( OPERAND_DELIMITOR );
- Lop funcLop = _inputParams.get(Statement.GAGG_FN);
- sb.append( funcLop.prepScalarInputOperand(getExecType()));
-
- // get the "optional" parameters
- if ( _inputParams.get(Statement.GAGG_FN_CM_ORDER) != null ) {
- sb.append( OPERAND_DELIMITOR );
- Lop orderLop = _inputParams.get(Statement.GAGG_FN_CM_ORDER);
- sb.append( orderLop.prepScalarInputOperand(getExecType()));
- }
-
- // add output_index to instruction
- sb.append( OPERAND_DELIMITOR );
- sb.append( this.prepOutputOperand(output_index));
-
- return sb.toString();
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/276d9257/src/main/java/com/ibm/bi/dml/lops/LeftIndex.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/ibm/bi/dml/lops/LeftIndex.java b/src/main/java/com/ibm/bi/dml/lops/LeftIndex.java
deleted file mode 100644
index d81b250..0000000
--- a/src/main/java/com/ibm/bi/dml/lops/LeftIndex.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * (C) Copyright IBM Corp. 2010, 2015
- *
- * Licensed 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 com.ibm.bi.dml.lops;
-
-import com.ibm.bi.dml.lops.LopProperties.ExecLocation;
-import com.ibm.bi.dml.lops.LopProperties.ExecType;
-import com.ibm.bi.dml.lops.compile.JobType;
-import com.ibm.bi.dml.parser.Expression.DataType;
-import com.ibm.bi.dml.parser.Expression.ValueType;
-
-
-public class LeftIndex extends Lop
-{
-
- /**
- * Constructor to setup a LeftIndexing operation.
- * Example: A[i:j, k:l] = B;
- *
- *
- * @param input
- * @param op
- * @return
- * @throws LopsException
- */
-
- private void init(Lop lhsMatrix, Lop rhsMatrix, Lop rowL, Lop rowU, Lop colL, Lop colU, ExecType et) throws LopsException {
- /*
- * A[i:j, k:l] = B;
- * B -> rhsMatrix
- * A -> lhsMatrix
- * i,j -> rowL, rowU
- * k,l -> colL, colU
- */
- this.addInput(lhsMatrix);
- this.addInput(rhsMatrix);
- this.addInput(rowL);
- this.addInput(rowU);
- this.addInput(colL);
- this.addInput(colU);
-
- lhsMatrix.addOutput(this);
- rhsMatrix.addOutput(this);
- rowL.addOutput(this);
- rowU.addOutput(this);
- colL.addOutput(this);
- colU.addOutput(this);
-
- boolean breaksAlignment = true;
- boolean aligner = false;
- boolean definesMRJob = false;
-
- if ( et == ExecType.MR ) {
- throw new LopsException(this.printErrorLocation() + "LeftIndexing lop is undefined for MR runtime");
- }
- else {
- lps.addCompatibility(JobType.INVALID);
- this.lps.setProperties(inputs, et, ExecLocation.ControlProgram, breaksAlignment, aligner, definesMRJob);
- }
- }
-
- public LeftIndex(
- Lop lhsInput, Lop rhsInput, Lop rowL, Lop rowU, Lop colL, Lop colU, DataType dt, ValueType vt, ExecType et)
- throws LopsException {
- super(Lop.Type.LeftIndex, dt, vt);
- init(lhsInput, rhsInput, rowL, rowU, colL, colU, et);
- }
-
- boolean isBroadcast = false;
- public LeftIndex(
- Lop lhsInput, Lop rhsInput, Lop rowL, Lop rowU, Lop colL, Lop colU, DataType dt, ValueType vt, ExecType et, boolean isBroadcast)
- throws LopsException {
- super(Lop.Type.LeftIndex, dt, vt);
- this.isBroadcast = isBroadcast;
- init(lhsInput, rhsInput, rowL, rowU, colL, colU, et);
- }
-
- private String getOpcode() {
- if(isBroadcast)
- return "mapLeftIndex";
- else
- return "leftIndex";
- }
-
- @Override
- public String getInstructions(String lhsInput, String rhsInput, String rowl, String rowu, String coll, String colu, String output)
- throws LopsException
- {
- StringBuilder sb = new StringBuilder();
- sb.append( getExecType() );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( getOpcode() );
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( getInputs().get(0).prepInputOperand(lhsInput));
- sb.append( OPERAND_DELIMITOR );
-
- if ( getInputs().get(1).getDataType() == DataType.SCALAR ) {
- sb.append( getInputs().get(1).prepScalarInputOperand(getExecType()));
- }
- else {
- sb.append( getInputs().get(1).prepInputOperand(rhsInput));
- }
- sb.append( OPERAND_DELIMITOR );
-
- // rowl, rowu
- sb.append(getInputs().get(2).prepScalarInputOperand(getExecType()));
- sb.append( OPERAND_DELIMITOR );
- sb.append(getInputs().get(3).prepScalarInputOperand(getExecType()));
- sb.append( OPERAND_DELIMITOR );
-
- // rowl, rowu
- sb.append(getInputs().get(4).prepScalarInputOperand(getExecType()));
- sb.append( OPERAND_DELIMITOR );
- sb.append(getInputs().get(5).prepScalarInputOperand(getExecType()));
- sb.append( OPERAND_DELIMITOR );
-
- sb.append( this.prepOutputOperand(output));
-
- return sb.toString();
- }
-
-/* @Override
- public String getInstructions(int input_index1, int input_index2, int input_index3, int input_index4, int input_index5, int output_index)
- throws LopsException {
-
- * Example: B = A[row_l:row_u, col_l:col_u]
- * A - input matrix (input_index1)
- * row_l - lower bound in row dimension
- * row_u - upper bound in row dimension
- * col_l - lower bound in column dimension
- * col_u - upper bound in column dimension
- *
- * Since row_l,row_u,col_l,col_u are scalars, values for input_index(2,3,4,5)
- * will be equal to -1. They should be ignored and the scalar value labels must
- * be derived from input lops.
-
- String rowl = this.getInputs().get(1).getOutputParameters().getLabel();
- if (this.getInputs().get(1).getExecLocation() != ExecLocation.Data
- || !((Data) this.getInputs().get(1)).isLiteral())
- rowl = "##" + rowl + "##";
- String rowu = this.getInputs().get(2).getOutputParameters().getLabel();
- if (this.getInputs().get(2).getExecLocation() != ExecLocation.Data
- || !((Data) this.getInputs().get(2)).isLiteral())
- rowu = "##" + rowu + "##";
- String coll = this.getInputs().get(3).getOutputParameters().getLabel();
- if (this.getInputs().get(3).getExecLocation() != ExecLocation.Data
- || !((Data) this.getInputs().get(3)).isLiteral())
- coll = "##" + coll + "##";
- String colu = this.getInputs().get(4).getOutputParameters().getLabel();
- if (this.getInputs().get(4).getExecLocation() != ExecLocation.Data
- || !((Data) this.getInputs().get(4)).isLiteral())
- colu = "##" + colu + "##";
-
- return getInstructions(Integer.toString(input_index1), rowl, rowu, coll, colu, Integer.toString(output_index));
- }
-*/
- @Override
- public String toString() {
- return "leftIndex";
- }
-
-}