flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [11/26] flink git commit: [core] Remove obsolete OperatorUtil
Date Tue, 21 Jul 2015 19:10:50 GMT
[core] Remove obsolete OperatorUtil


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

Branch: refs/heads/master
Commit: 75d1639a5f82dc6b67cb6ab3f3824d1c9191fd23
Parents: 1d373a7
Author: Stephan Ewen <sewen@apache.org>
Authored: Mon Jul 20 13:02:21 2015 +0200
Committer: Stephan Ewen <sewen@apache.org>
Committed: Tue Jul 21 17:58:14 2015 +0200

----------------------------------------------------------------------
 .../api/common/operators/util/OperatorUtil.java | 150 -------------------
 .../common/io/GenericCsvInputFormatTest.java    |   3 +-
 .../common/operators/util/OperatorUtilTest.java | 132 ----------------
 3 files changed, 1 insertion(+), 284 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/75d1639a/flink-core/src/main/java/org/apache/flink/api/common/operators/util/OperatorUtil.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/operators/util/OperatorUtil.java
b/flink-core/src/main/java/org/apache/flink/api/common/operators/util/OperatorUtil.java
deleted file mode 100644
index 106b86a..0000000
--- a/flink-core/src/main/java/org/apache/flink/api/common/operators/util/OperatorUtil.java
+++ /dev/null
@@ -1,150 +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.flink.api.common.operators.util;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.flink.api.common.functions.CoGroupFunction;
-import org.apache.flink.api.common.functions.CrossFunction;
-import org.apache.flink.api.common.functions.FlatJoinFunction;
-import org.apache.flink.api.common.functions.GenericCollectorMap;
-import org.apache.flink.api.common.functions.GroupReduceFunction;
-import org.apache.flink.api.common.io.FileInputFormat;
-import org.apache.flink.api.common.io.FileOutputFormat;
-import org.apache.flink.api.common.io.InputFormat;
-import org.apache.flink.api.common.io.OutputFormat;
-import org.apache.flink.api.common.operators.DualInputOperator;
-import org.apache.flink.api.common.operators.GenericDataSinkBase;
-import org.apache.flink.api.common.operators.GenericDataSourceBase;
-import org.apache.flink.api.common.operators.Operator;
-import org.apache.flink.api.common.operators.SingleInputOperator;
-import org.apache.flink.api.common.operators.base.CoGroupOperatorBase;
-import org.apache.flink.api.common.operators.base.CollectorMapOperatorBase;
-import org.apache.flink.api.common.operators.base.CrossOperatorBase;
-import org.apache.flink.api.common.operators.base.GroupReduceOperatorBase;
-import org.apache.flink.api.common.operators.base.JoinOperatorBase;
-
-/**
- * Convenience methods when dealing with {@link Operator}s.
- */
-@SuppressWarnings("deprecation")
-public class OperatorUtil {
-	
-	@SuppressWarnings("rawtypes")
-	private final static Map<Class<?>, Class<? extends Operator>> STUB_CONTRACTS
=
-		new LinkedHashMap<Class<?>, Class<? extends Operator>>();
-
-	static {
-		STUB_CONTRACTS.put(GenericCollectorMap.class, CollectorMapOperatorBase.class);
-		STUB_CONTRACTS.put(GroupReduceFunction.class, GroupReduceOperatorBase.class);
-		STUB_CONTRACTS.put(CoGroupFunction.class, CoGroupOperatorBase.class);
-		STUB_CONTRACTS.put(CrossFunction.class, CrossOperatorBase.class);
-		STUB_CONTRACTS.put(FlatJoinFunction.class, JoinOperatorBase.class);
-		STUB_CONTRACTS.put(FileInputFormat.class, GenericDataSourceBase.class);
-		STUB_CONTRACTS.put(FileOutputFormat.class, GenericDataSinkBase.class);
-		STUB_CONTRACTS.put(InputFormat.class, GenericDataSourceBase.class);
-		STUB_CONTRACTS.put(OutputFormat.class, GenericDataSinkBase.class);
-	}
-
-	/**
-	 * Returns the associated {@link Operator} type for the given {@link org.apache.flink.api.common.functions.RichFunction}
class.
-	 * 
-	 * @param stubClass
-	 *        the stub class
-	 * @return the associated Operator type
-	 */
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public static Class<? extends Operator> getContractClass(final Class<?> stubClass)
{
-		if (stubClass == null) {
-			return null;
-		}
-		final Class<?> contract = STUB_CONTRACTS.get(stubClass);
-		if (contract != null) {
-			return (Class<? extends Operator<?>>) contract;
-		}
-		Iterator<Entry<Class<?>, Class<? extends Operator>>> stubContracts
= STUB_CONTRACTS.entrySet().iterator();
-		while (stubContracts.hasNext()) {
-			Map.Entry<Class<?>, Class<? extends Operator>> entry = stubContracts.next();
-			if (entry.getKey().isAssignableFrom(stubClass)) {
-				return entry.getValue();
-			}
-		}
-		return null;
-
-	}
-
-	/**
-	 * Returns the number of inputs for the given {@link Operator} type.<br>
-	 * Currently, it can be 0, 1, or 2.
-	 * 
-	 * @param contractType
-	 *        the type of the Operator
-	 * @return the number of input contracts
-	 */
-	public static int getNumInputs(final Class<? extends Operator<?>> contractType)
{
-
-		if (GenericDataSourceBase.class.isAssignableFrom(contractType)) {
-			return 0;
-		}
-		if (GenericDataSinkBase.class.isAssignableFrom(contractType)
-			|| SingleInputOperator.class.isAssignableFrom(contractType)) {
-			return 1;
-		}
-		if (DualInputOperator.class.isAssignableFrom(contractType)) {
-			return 2;
-		}
-		throw new IllegalArgumentException("not supported");
-	}
-
-
-	/**
-	 * Sets the inputs of the given {@link Operator}.<br>
-	 * Currently, the list can have 0, 1, or 2 elements and the number of elements must match
the type of the contract.
-	 * 
-	 * @param contract
-	 *        the Operator whose inputs should be set
-	 * @param inputs
-	 *        all input contracts to this contract
-	 */
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public static void setInputs(final Operator<?> contract, final List<List<Operator>>
inputs) {
-		if (contract instanceof GenericDataSinkBase) {
-			if (inputs.size() != 1) {
-				throw new IllegalArgumentException("wrong number of inputs");
-			}
-			((GenericDataSinkBase) contract).setInputs(inputs.get(0));
-		} else if (contract instanceof SingleInputOperator) {
-			if (inputs.size() != 1) {
-				throw new IllegalArgumentException("wrong number of inputs");
-			}
-			((SingleInputOperator) contract).setInputs(inputs.get(0));
-		} else if (contract instanceof DualInputOperator) {
-			if (inputs.size() != 2) {
-				throw new IllegalArgumentException("wrong number of inputs");
-			}
-			((DualInputOperator) contract).setFirstInputs(inputs.get(0));
-			((DualInputOperator) contract).setSecondInputs(inputs.get(1));
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/flink/blob/75d1639a/flink-core/src/test/java/org/apache/flink/api/common/io/GenericCsvInputFormatTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/io/GenericCsvInputFormatTest.java
b/flink-core/src/test/java/org/apache/flink/api/common/io/GenericCsvInputFormatTest.java
index 20b130c..14e618b 100644
--- a/flink-core/src/test/java/org/apache/flink/api/common/io/GenericCsvInputFormatTest.java
+++ b/flink-core/src/test/java/org/apache/flink/api/common/io/GenericCsvInputFormatTest.java
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-
 package org.apache.flink.api.common.io;
 
 import static org.junit.Assert.assertEquals;
@@ -41,7 +40,7 @@ import org.apache.flink.types.IntValue;
 import org.apache.flink.types.LongValue;
 import org.apache.flink.types.StringValue;
 import org.apache.flink.types.Value;
-import org.jets3t.service.io.GZipDeflatingInputStream;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/flink/blob/75d1639a/flink-core/src/test/java/org/apache/flink/api/common/operators/util/OperatorUtilTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/operators/util/OperatorUtilTest.java
b/flink-core/src/test/java/org/apache/flink/api/common/operators/util/OperatorUtilTest.java
deleted file mode 100644
index dd017eb..0000000
--- a/flink-core/src/test/java/org/apache/flink/api/common/operators/util/OperatorUtilTest.java
+++ /dev/null
@@ -1,132 +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.flink.api.common.operators.util;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.flink.api.common.functions.CoGroupFunction;
-import org.apache.flink.api.common.functions.FlatJoinFunction;
-import org.apache.flink.api.common.functions.GroupReduceFunction;
-import org.apache.flink.api.common.functions.RichFunction;
-import org.apache.flink.api.common.functions.GenericCollectorMap;
-import org.apache.flink.api.common.functions.CrossFunction;
-import org.apache.flink.api.common.io.DelimitedInputFormat;
-import org.apache.flink.api.common.io.FileOutputFormat;
-import org.apache.flink.api.common.operators.GenericDataSinkBase;
-import org.apache.flink.api.common.operators.GenericDataSourceBase;
-import org.apache.flink.api.common.operators.base.CoGroupOperatorBase;
-import org.apache.flink.api.common.operators.base.CollectorMapOperatorBase;
-import org.apache.flink.api.common.operators.base.CrossOperatorBase;
-import org.apache.flink.api.common.operators.base.GroupReduceOperatorBase;
-import org.apache.flink.api.common.operators.base.JoinOperatorBase;
-import org.apache.flink.types.IntValue;
-import org.junit.Test;
-
-/**
- * Tests {@link OperatorUtil}.
- */
-@SuppressWarnings("deprecation")
-public class OperatorUtilTest {
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnCoGroupForCoGroupStub() {
-		final Class<?> result = OperatorUtil.getContractClass(CoGrouper.class);
-		assertEquals(CoGroupOperatorBase.class, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnCrossForCrossStub() {
-		final Class<?> result = OperatorUtil.getContractClass(Crosser.class);
-		assertEquals(CrossOperatorBase.class, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnMapForMapStub() {
-		final Class<?> result = OperatorUtil.getContractClass(Mapper.class);
-		assertEquals(CollectorMapOperatorBase.class, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnMatchForMatchStub() {
-		final Class<?> result = OperatorUtil.getContractClass(Matcher.class);
-		assertEquals(JoinOperatorBase.class, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnNullForStub() {
-		final Class<?> result = OperatorUtil.getContractClass(RichFunction.class);
-		assertEquals(null, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnReduceForReduceStub() {
-		final Class<?> result = OperatorUtil.getContractClass(Reducer.class);
-		assertEquals(GroupReduceOperatorBase.class, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnSinkForOutputFormat() {
-		final Class<?> result = OperatorUtil.getContractClass(FileOutputFormat.class);
-		assertEquals(GenericDataSinkBase.class, result);
-	}
-
-	/**
-	 * Test {@link OperatorUtil#getContractClass(Class)}
-	 */
-	@Test
-	public void getContractClassShouldReturnSourceForInputFormat() {
-		final Class<?> result = OperatorUtil.getContractClass(DelimitedInputFormat.class);
-		assertEquals(GenericDataSourceBase.class, result);
-	}
-
-	@SuppressWarnings("serial")
-	static abstract class CoGrouper implements CoGroupFunction<IntValue, IntValue, IntValue>
{}
-
-	@SuppressWarnings("serial")
-	static abstract class Crosser implements CrossFunction<IntValue, IntValue, IntValue>
{}
-
-	static abstract class Mapper implements GenericCollectorMap<IntValue, IntValue> {}
-
-	@SuppressWarnings("serial")
-	static abstract class Matcher implements FlatJoinFunction<IntValue, IntValue, IntValue>
{}
-
-	@SuppressWarnings("serial")
-	static abstract class Reducer implements GroupReduceFunction<IntValue, IntValue> {}
-}


Mime
View raw message