All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.stratosphere.api.java.operators.TwoInputOperator Maven / Gradle / Ivy

/***********************************************************************************************************************
 *
 * Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
 *
 * 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 eu.stratosphere.api.java.operators;

import eu.stratosphere.api.java.DataSet;
import eu.stratosphere.types.TypeInformation;

/**
 * Base class for operations that operates on two input data sets.
 * 
 * @param  The data type of the first input data set.
 * @param  The data type of the second input data set.
 * @param  The data type of the returned data set.
 */
public abstract class TwoInputOperator> extends Operator {
	
	private final DataSet input1;
	private final DataSet input2;
	
	
	protected TwoInputOperator(DataSet input1, DataSet input2, TypeInformation resultType) {
		super(input1.getExecutionEnvironment(), resultType);
		
		DataSet.checkSameExecutionContext(input1, input2);
		this.input1 = input1;
		this.input2 = input2;
	}
	
	/**
	 * Gets the data set that this operation uses as its first input.
	 * 
	 * @return The data set that this operation uses as its first input.
	 */
	public DataSet getInput1() {
		return this.input1;
	}
	
	/**
	 * Gets the data set that this operation uses as its second input.
	 * 
	 * @return The data set that this operation uses as its second input.
	 */
	public DataSet getInput2() {
		return this.input2;
	}
	
	/**
	 * Gets the type information of the data type of the first input data set.
	 * This method returns equivalent information as {@code getInput1().getType()}.
	 * 
	 * @return The first input data type.
	 */
	public TypeInformation getInput1Type() {
		return this.input1.getType();
	}
	
	/**
	 * Gets the type information of the data type of the second input data set.
	 * This method returns equivalent information as {@code getInput2().getType()}.
	 * 
	 * @return The second input data type.
	 */
	public TypeInformation getInput2Type() {
		return this.input2.getType();
	}
	
	/**
	 * Translates this java API operator into a common API operator with two inputs.
	 * 
	 * @param input1 The first input of the operation, as a common API operator.
	 * @param input2 The second input of the operation, as a common API operator.
	 * @return The created common API operator.
	 */
	protected abstract eu.stratosphere.api.common.operators.DualInputOperator translateToDataFlow(
			eu.stratosphere.api.common.operators.Operator input1, eu.stratosphere.api.common.operators.Operator input2);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy