/** * (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; } }