/*
 * 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.flink.api.common.operators.base;

import org.apache.flink.api.common.functions.CrossFunction;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
import org.apache.flink.api.common.operators.DualInputOperator;
import org.apache.flink.api.common.operators.util.UserCodeClassWrapper;
import org.apache.flink.api.common.operators.util.UserCodeObjectWrapper;
import org.apache.flink.api.common.operators.util.UserCodeWrapper;


/**
 * @see org.apache.flink.api.common.functions.CrossFunction
 */
public class CrossOperatorBase<IN1, IN2, OUT, FT extends CrossFunction<?, ?, ?>> extends DualInputOperator<IN1, IN2, OUT, FT> {
	
	public CrossOperatorBase(UserCodeWrapper<FT> udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
		super(udf, operatorInfo, name);
	}
	
	public CrossOperatorBase(FT udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
		this(new UserCodeObjectWrapper<FT>(udf), operatorInfo, name);
	}
	
	public CrossOperatorBase(Class<? extends FT> udf, BinaryOperatorInformation<IN1, IN2, OUT> operatorInfo, String name) {
		this(new UserCodeClassWrapper<FT>(udf), operatorInfo, name);
	}
	
	// --------------------------------------------------------------------------------------------
	
	/**
	 * Marker interface to declare the second input as the smaller one.
	 */
	public static interface CrossWithSmall {}
	
	/**
	 * Marker interface to declare the second input as the larger one.
	 */
	public static interface CrossWithLarge {}
}

@@ -800,17 +800,16 @@
 e.%0A */%0A%0A
-%0A
 package 
@@ -853,16 +853,68 @@
 .base;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 import o
@@ -961,24 +961,150 @@
 ssFunction;%0A
+import org.apache.flink.api.common.functions.RuntimeContext;%0Aimport org.apache.flink.api.common.functions.util.FunctionUtils;%0A
 import org.a
@@ -1440,17 +1440,16 @@
 apper;%0A%0A
-%0A
 /**%0A * @
@@ -1583,15 +1583,21 @@
 ion%3C
-?, ?, ?
+IN1, IN2, OUT
 %3E%3E e
@@ -2090,32 +2090,32 @@
  String name) %7B%0A
-
 %09%09this(new UserC
@@ -2262,16 +2262,740 @@
 --------
+%0A%0A%09@Override%0A%09protected List%3COUT%3E executeOnCollections(List%3CIN1%3E inputData1, List%3CIN2%3E inputData2, RuntimeContext ctx) throws Exception %7B%0A%09%09CrossFunction%3CIN1, IN2, OUT%3E function = this.userFunction.getUserCodeObject();%0A%09%09%0A%09%09FunctionUtils.setFunctionRuntimeContext(function, ctx);%0A%09%09FunctionUtils.openFunction(function, this.parameters);%0A%09%09%0A%09%09ArrayList%3COUT%3E result = new ArrayList%3COUT%3E(inputData1.size() * inputData2.size());%0A%09%09for (IN1 element1 : inputData1) %7B%0A%09%09%09for (IN2 element2 : inputData2) %7B%0A%09%09%09%09result.add(function.cross(element1, element2));%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09FunctionUtils.closeFunction(function);%0A%09%09%0A%09%09return result;%0A%09%7D%0A%09%0A%09// --------------------------------------------------------------------------------------------
 %0A%09%0A%09/**%0A

Implement collection-based Cross