You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2016/02/02 18:23:01 UTC
[01/38] flink git commit: [hotfix] Reduce the heavy sysout verbosity
for certain tests
Repository: flink
Updated Branches:
refs/heads/master 360f02b1f -> 8fc7e7af2
[hotfix] Reduce the heavy sysout verbosity for certain tests
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/6f042e78
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/6f042e78
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/6f042e78
Branch: refs/heads/master
Commit: 6f042e7894be388fa8e400a08002584c10781e60
Parents: 21a7158
Author: Stephan Ewen <se...@apache.org>
Authored: Mon Feb 1 16:46:03 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 16:55:44 2016 +0100
----------------------------------------------------------------------
.../jar/CheckpointedStreamingProgram.java | 10 ----------
.../flink/test/recovery/FastFailuresITCase.java | 18 +++++++++++++++---
2 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/6f042e78/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
index 47253da..cda5a7b 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CheckpointedStreamingProgram.java
@@ -27,8 +27,6 @@ import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;
import java.lang.RuntimeException;
-import java.net.URL;
-import java.net.URLClassLoader;
/**
* A simple streaming program, which is using the state checkpointing of Flink.
@@ -40,14 +38,6 @@ public class CheckpointedStreamingProgram {
private static final int CHECKPOINT_INTERVALL = 100;
public static void main(String[] args) throws Exception {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- URL[] urls = ((URLClassLoader)cl).getURLs();
-
- for(URL url: urls){
- System.out.println(url.getFile());
- }
- System.out.println("CheckpointedStreamingProgram classpath: ");
-
final String jarFile = args[0];
final String host = args[1];
final int port = Integer.parseInt(args[2]);
http://git-wip-us.apache.org/repos/asf/flink/blob/6f042e78/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java b/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
index 0684fde..2a139c7 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/recovery/FastFailuresITCase.java
@@ -21,11 +21,13 @@ package org.apache.flink.test.recovery;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.ConfigConstants;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
+import org.apache.flink.test.util.ForkableFlinkMiniCluster;
import org.junit.Test;
@@ -33,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.fail;
+@SuppressWarnings("serial")
public class FastFailuresITCase {
static final AtomicInteger FAILURES_SO_FAR = new AtomicInteger();
@@ -40,12 +43,21 @@ public class FastFailuresITCase {
@Test
public void testThis() {
- StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
-
+ Configuration config = new Configuration();
+ config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 2);
+ config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, 2);
+
+ ForkableFlinkMiniCluster cluster = new ForkableFlinkMiniCluster(config, false);
+ cluster.start();
+
+ StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment(
+ "localhost", cluster.getLeaderRPCPort());
+
+ env.getConfig().disableSysoutLogging();
env.getConfig().setExecutionRetryDelay(0);
env.setParallelism(4);
env.enableCheckpointing(1000);
-
+
DataStream<Tuple2<Integer, Integer>> input = env.addSource(new RichSourceFunction<Tuple2<Integer, Integer>>() {
@Override
[11/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
deleted file mode 100644
index f7e4e42..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
+++ /dev/null
@@ -1,405 +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.java.typeutils;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.AvroSerializer;
-import org.apache.flink.api.java.typeutils.runtime.PojoComparator;
-import org.apache.flink.api.java.typeutils.runtime.PojoSerializer;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-
-import com.google.common.base.Joiner;
-import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
-
-/**
- * TypeInformation for "Java Beans"-style types. Flink refers to them as POJOs,
- * since the conditions are slightly different from Java Beans.
- * A type is considered a FLink POJO type, if it fulfills the conditions below.
- * <ul>
- * <li>It is a public class, and standalone (not a non-static inner class)</li>
- * <li>It has a public no-argument constructor.</li>
- * <li>All fields are either public, or have public getters and setters.</li>
- * </ul>
- *
- * @param <T> The type represented by this type information.
- */
-public class PojoTypeInfo<T> extends CompositeType<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final static String REGEX_FIELD = "[\\p{L}_\\$][\\p{L}\\p{Digit}_\\$]*";
- private final static String REGEX_NESTED_FIELDS = "("+REGEX_FIELD+")(\\.(.+))?";
- private final static String REGEX_NESTED_FIELDS_WILDCARD = REGEX_NESTED_FIELDS
- +"|\\"+ExpressionKeys.SELECT_ALL_CHAR
- +"|\\"+ExpressionKeys.SELECT_ALL_CHAR_SCALA;
-
- private static final Pattern PATTERN_NESTED_FIELDS = Pattern.compile(REGEX_NESTED_FIELDS);
- private static final Pattern PATTERN_NESTED_FIELDS_WILDCARD = Pattern.compile(REGEX_NESTED_FIELDS_WILDCARD);
-
- private final PojoField[] fields;
-
- private final int totalFields;
-
- public PojoTypeInfo(Class<T> typeClass, List<PojoField> fields) {
- super(typeClass);
-
- Preconditions.checkArgument(Modifier.isPublic(typeClass.getModifiers()),
- "POJO " + typeClass + " is not public");
-
- this.fields = fields.toArray(new PojoField[fields.size()]);
-
- Arrays.sort(this.fields, new Comparator<PojoField>() {
- @Override
- public int compare(PojoField o1, PojoField o2) {
- return o1.getField().getName().compareTo(o2.getField().getName());
- }
- });
-
- int counterFields = 0;
-
- for(PojoField field : fields) {
- counterFields += field.getTypeInformation().getTotalFields();
- }
-
- totalFields = counterFields;
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public int getArity() {
- return fields.length;
- }
-
- @Override
- public int getTotalFields() {
- return totalFields;
- }
-
- @Override
- public boolean isSortKeyType() {
- // Support for sorting POJOs that implement Comparable is not implemented yet.
- // Since the order of fields in a POJO type is not well defined, sorting on fields
- // gives only some undefined order.
- return false;
- }
-
-
- @Override
- public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) {
-
- Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression);
- if(!matcher.matches()) {
- throw new InvalidFieldReferenceException("Invalid POJO field reference \""+fieldExpression+"\".");
- }
-
- String field = matcher.group(0);
- if(field.equals(ExpressionKeys.SELECT_ALL_CHAR) || field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
- // handle select all
- int keyPosition = 0;
- for(PojoField pField : fields) {
- if(pField.getTypeInformation() instanceof CompositeType) {
- CompositeType<?> cType = (CompositeType<?>)pField.getTypeInformation();
- cType.getFlatFields(String.valueOf(ExpressionKeys.SELECT_ALL_CHAR), offset + keyPosition, result);
- keyPosition += cType.getTotalFields()-1;
- } else {
- result.add(
- new NamedFlatFieldDescriptor(
- pField.getField().getName(),
- offset + keyPosition,
- pField.getTypeInformation()));
- }
- keyPosition++;
- }
- return;
- } else {
- field = matcher.group(1);
- }
-
- // get field
- int fieldPos = -1;
- TypeInformation<?> fieldType = null;
- for (int i = 0; i < fields.length; i++) {
- if (fields[i].getField().getName().equals(field)) {
- fieldPos = i;
- fieldType = fields[i].getTypeInformation();
- break;
- }
- }
- if (fieldPos == -1) {
- throw new InvalidFieldReferenceException("Unable to find field \""+field+"\" in type "+this+".");
- }
- String tail = matcher.group(3);
- if(tail == null) {
- if(fieldType instanceof CompositeType) {
- // forward offset
- for(int i=0; i<fieldPos; i++) {
- offset += this.getTypeAt(i).getTotalFields();
- }
- // add all fields of composite type
- ((CompositeType<?>) fieldType).getFlatFields("*", offset, result);
- } else {
- // we found the field to add
- // compute flat field position by adding skipped fields
- int flatFieldPos = offset;
- for(int i=0; i<fieldPos; i++) {
- flatFieldPos += this.getTypeAt(i).getTotalFields();
- }
- result.add(new FlatFieldDescriptor(flatFieldPos, fieldType));
- }
- } else {
- if(fieldType instanceof CompositeType<?>) {
- // forward offset
- for(int i=0; i<fieldPos; i++) {
- offset += this.getTypeAt(i).getTotalFields();
- }
- ((CompositeType<?>) fieldType).getFlatFields(tail, offset, result);
- } else {
- throw new InvalidFieldReferenceException("Nested field expression \""+tail+"\" not possible on atomic type "+fieldType+".");
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
-
- Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
- if(!matcher.matches()) {
- if (fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR) || fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
- throw new InvalidFieldReferenceException("Wildcard expressions are not allowed here.");
- } else {
- throw new InvalidFieldReferenceException("Invalid format of POJO field expression \""+fieldExpression+"\".");
- }
- }
-
- String field = matcher.group(1);
- // get field
- int fieldPos = -1;
- TypeInformation<?> fieldType = null;
- for (int i = 0; i < fields.length; i++) {
- if (fields[i].getField().getName().equals(field)) {
- fieldPos = i;
- fieldType = fields[i].getTypeInformation();
- break;
- }
- }
- if (fieldPos == -1) {
- throw new InvalidFieldReferenceException("Unable to find field \""+field+"\" in type "+this+".");
- }
-
- String tail = matcher.group(3);
- if(tail == null) {
- // we found the type
- return (TypeInformation<X>) fieldType;
- } else {
- if(fieldType instanceof CompositeType<?>) {
- return ((CompositeType<?>) fieldType).getTypeAt(tail);
- } else {
- throw new InvalidFieldReferenceException("Nested field expression \""+tail+"\" not possible on atomic type "+fieldType+".");
- }
- }
- }
-
- @Override
- public <X> TypeInformation<X> getTypeAt(int pos) {
- if (pos < 0 || pos >= this.fields.length) {
- throw new IndexOutOfBoundsException();
- }
- @SuppressWarnings("unchecked")
- TypeInformation<X> typed = (TypeInformation<X>) fields[pos].getTypeInformation();
- return typed;
- }
-
- @Override
- protected TypeComparatorBuilder<T> createTypeComparatorBuilder() {
- return new PojoTypeComparatorBuilder();
- }
-
- // used for testing. Maybe use mockito here
- public PojoField getPojoFieldAt(int pos) {
- if (pos < 0 || pos >= this.fields.length) {
- throw new IndexOutOfBoundsException();
- }
- return this.fields[pos];
- }
-
- public String[] getFieldNames() {
- String[] result = new String[fields.length];
- for (int i = 0; i < fields.length; i++) {
- result[i] = fields[i].getField().getName();
- }
- return result;
- }
-
- @Override
- public int getFieldIndex(String fieldName) {
- for (int i = 0; i < fields.length; i++) {
- if (fields[i].getField().getName().equals(fieldName)) {
- return i;
- }
- }
- return -1;
- }
-
- @Override
- public TypeSerializer<T> createSerializer(ExecutionConfig config) {
- if(config.isForceKryoEnabled()) {
- return new KryoSerializer<T>(getTypeClass(), config);
- }
- if(config.isForceAvroEnabled()) {
- return new AvroSerializer<T>(getTypeClass());
- }
-
- TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[fields.length ];
- Field[] reflectiveFields = new Field[fields.length];
-
- for (int i = 0; i < fields.length; i++) {
- fieldSerializers[i] = fields[i].getTypeInformation().createSerializer(config);
- reflectiveFields[i] = fields[i].getField();
- }
-
- return new PojoSerializer<T>(getTypeClass(), fieldSerializers, reflectiveFields, config);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof PojoTypeInfo) {
- @SuppressWarnings("unchecked")
- PojoTypeInfo<T> pojoTypeInfo = (PojoTypeInfo<T>)obj;
-
- return pojoTypeInfo.canEqual(this) &&
- super.equals(pojoTypeInfo) &&
- Arrays.equals(fields, pojoTypeInfo.fields) &&
- totalFields == pojoTypeInfo.totalFields;
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return 31 * (31 * Arrays.hashCode(fields) + totalFields) + super.hashCode();
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof PojoTypeInfo;
- }
-
- @Override
- public String toString() {
- List<String> fieldStrings = new ArrayList<String>();
- for (PojoField field : fields) {
- fieldStrings.add(field.getField().getName() + ": " + field.getTypeInformation().toString());
- }
- return "PojoType<" + getTypeClass().getName()
- + ", fields = [" + Joiner.on(", ").join(fieldStrings) + "]"
- + ">";
- }
-
- // --------------------------------------------------------------------------------------------
-
- private class PojoTypeComparatorBuilder implements TypeComparatorBuilder<T> {
-
- private ArrayList<TypeComparator> fieldComparators;
- private ArrayList<Field> keyFields;
-
- public PojoTypeComparatorBuilder() {
- fieldComparators = new ArrayList<TypeComparator>();
- keyFields = new ArrayList<Field>();
- }
-
-
- @Override
- public void initializeTypeComparatorBuilder(int size) {
- fieldComparators.ensureCapacity(size);
- keyFields.ensureCapacity(size);
- }
-
- @Override
- public void addComparatorField(int fieldId, TypeComparator<?> comparator) {
- fieldComparators.add(comparator);
- keyFields.add(fields[fieldId].getField());
- }
-
- @Override
- public TypeComparator<T> createTypeComparator(ExecutionConfig config) {
- Preconditions.checkState(
- keyFields.size() > 0,
- "No keys were defined for the PojoTypeComparatorBuilder.");
-
- Preconditions.checkState(
- fieldComparators.size() > 0,
- "No type comparators were defined for the PojoTypeComparatorBuilder.");
-
- Preconditions.checkState(
- keyFields.size() == fieldComparators.size(),
- "Number of key fields and field comparators is not equal.");
-
- return new PojoComparator<T>(
- keyFields.toArray(new Field[keyFields.size()]),
- fieldComparators.toArray(new TypeComparator[fieldComparators.size()]),
- createSerializer(config),
- getTypeClass());
- }
- }
-
- public static class NamedFlatFieldDescriptor extends FlatFieldDescriptor {
-
- private String fieldName;
-
- public NamedFlatFieldDescriptor(String name, int keyPosition, TypeInformation<?> type) {
- super(keyPosition, type);
- this.fieldName = name;
- }
-
- public String getFieldName() {
- return fieldName;
- }
-
- @Override
- public String toString() {
- return "NamedFlatFieldDescriptor [name="+fieldName+" position="+getPosition()+" typeInfo="+getType()+"]";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java
deleted file mode 100644
index 22a18f1..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java
+++ /dev/null
@@ -1,37 +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.java.typeutils;
-
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-
-/**
- * This interface can be implemented by functions and input formats to tell the framework
- * about their produced data type. This method acts as an alternative to the reflection analysis
- * that is otherwise performed and is useful in situations where the produced data type may vary
- * depending on parameterization.
- */
-public interface ResultTypeQueryable<T> {
-
- /**
- * Gets the data type (as a {@link TypeInformation}) produced by this function or input format.
- *
- * @return The data type produced by this function or input format.
- */
- TypeInformation<T> getProducedType();
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java
deleted file mode 100644
index 30710e5..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java
+++ /dev/null
@@ -1,248 +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.java.typeutils;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-
-import com.google.common.base.Preconditions;
-import com.google.common.primitives.Ints;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-//CHECKSTYLE.OFF: AvoidStarImport - Needed for TupleGenerator
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.*;
-import org.apache.flink.api.java.typeutils.runtime.Tuple0Serializer;
-//CHECKSTYLE.ON: AvoidStarImport
-import org.apache.flink.api.java.typeutils.runtime.TupleComparator;
-import org.apache.flink.api.java.typeutils.runtime.TupleSerializer;
-import org.apache.flink.types.Value;
-
-/**
- * A {@link TypeInformation} for the tuple types of the Java API.
- *
- * @param <T> The type of the tuple.
- */
-public final class TupleTypeInfo<T extends Tuple> extends TupleTypeInfoBase<T> {
-
- private static final long serialVersionUID = 1L;
-
- protected final String[] fieldNames;
-
- @SuppressWarnings("unchecked")
- public TupleTypeInfo(TypeInformation<?>... types) {
- this((Class<T>) Tuple.getTupleClass(types.length), types);
- }
-
- public TupleTypeInfo(Class<T> tupleType, TypeInformation<?>... types) {
- super(tupleType, types);
-
- Preconditions.checkArgument(
- types.length <= Tuple.MAX_ARITY,
- "The tuple type exceeds the maximum supported arity.");
-
- this.fieldNames = new String[types.length];
-
- for (int i = 0; i < types.length; i++) {
- fieldNames[i] = "f" + i;
- }
- }
-
- @Override
- public String[] getFieldNames() {
- return fieldNames;
- }
-
- @Override
- public int getFieldIndex(String fieldName) {
- int fieldIndex = Integer.parseInt(fieldName.substring(1));
- if (fieldIndex >= getArity()) {
- return -1;
- }
- return fieldIndex;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public TupleSerializer<T> createSerializer(ExecutionConfig executionConfig) {
- if (getTypeClass() == Tuple0.class) {
- return (TupleSerializer<T>) Tuple0Serializer.INSTANCE;
- }
-
- TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[getArity()];
- for (int i = 0; i < types.length; i++) {
- fieldSerializers[i] = types[i].createSerializer(executionConfig);
- }
-
- Class<T> tupleClass = getTypeClass();
-
- return new TupleSerializer<T>(tupleClass, fieldSerializers);
- }
-
- @Override
- protected TypeComparatorBuilder<T> createTypeComparatorBuilder() {
- return new TupleTypeComparatorBuilder();
- }
-
- private class TupleTypeComparatorBuilder implements TypeComparatorBuilder<T> {
-
- private final ArrayList<TypeComparator> fieldComparators = new ArrayList<TypeComparator>();
- private final ArrayList<Integer> logicalKeyFields = new ArrayList<Integer>();
-
- @Override
- public void initializeTypeComparatorBuilder(int size) {
- fieldComparators.ensureCapacity(size);
- logicalKeyFields.ensureCapacity(size);
- }
-
- @Override
- public void addComparatorField(int fieldId, TypeComparator<?> comparator) {
- fieldComparators.add(comparator);
- logicalKeyFields.add(fieldId);
- }
-
- @Override
- public TypeComparator<T> createTypeComparator(ExecutionConfig config) {
- Preconditions.checkState(
- fieldComparators.size() > 0,
- "No field comparators were defined for the TupleTypeComparatorBuilder."
- );
-
- Preconditions.checkState(
- logicalKeyFields.size() > 0,
- "No key fields were defined for the TupleTypeComparatorBuilder."
- );
-
- Preconditions.checkState(
- fieldComparators.size() == logicalKeyFields.size(),
- "The number of field comparators and key fields is not equal."
- );
-
- final int maxKey = Collections.max(logicalKeyFields);
-
- Preconditions.checkState(
- maxKey >= 0,
- "The maximum key field must be greater or equal than 0."
- );
-
- TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1];
-
- for (int i = 0; i <= maxKey; i++) {
- fieldSerializers[i] = types[i].createSerializer(config);
- }
-
- return new TupleComparator<T>(
- Ints.toArray(logicalKeyFields),
- fieldComparators.toArray(new TypeComparator[fieldComparators.size()]),
- fieldSerializers
- );
- }
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TupleTypeInfo) {
- @SuppressWarnings("unchecked")
- TupleTypeInfo<T> other = (TupleTypeInfo<T>) obj;
- return other.canEqual(this) &&
- super.equals(other) &&
- Arrays.equals(fieldNames, other.fieldNames);
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof TupleTypeInfo;
- }
-
- @Override
- public int hashCode() {
- return 31 * super.hashCode() + Arrays.hashCode(fieldNames);
- }
-
- @Override
- public String toString() {
- return "Java " + super.toString();
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static <X extends Tuple> TupleTypeInfo<X> getBasicTupleTypeInfo(Class<?>... basicTypes) {
- if (basicTypes == null || basicTypes.length == 0) {
- throw new IllegalArgumentException();
- }
-
- TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length];
- for (int i = 0; i < infos.length; i++) {
- Class<?> type = basicTypes[i];
- if (type == null) {
- throw new IllegalArgumentException("Type at position " + i + " is null.");
- }
-
- TypeInformation<?> info = BasicTypeInfo.getInfoFor(type);
- if (info == null) {
- throw new IllegalArgumentException("Type at position " + i + " is not a basic type.");
- }
- infos[i] = info;
- }
-
- @SuppressWarnings("unchecked")
- TupleTypeInfo<X> tupleInfo = (TupleTypeInfo<X>) new TupleTypeInfo<Tuple>(infos);
- return tupleInfo;
- }
-
- @SuppressWarnings("unchecked")
- public static <X extends Tuple> TupleTypeInfo<X> getBasicAndBasicValueTupleTypeInfo(Class<?>... basicTypes) {
- if (basicTypes == null || basicTypes.length == 0) {
- throw new IllegalArgumentException();
- }
-
- TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length];
- for (int i = 0; i < infos.length; i++) {
- Class<?> type = basicTypes[i];
- if (type == null) {
- throw new IllegalArgumentException("Type at position " + i + " is null.");
- }
-
- TypeInformation<?> info = BasicTypeInfo.getInfoFor(type);
- if (info == null) {
- try {
- info = ValueTypeInfo.getValueTypeInfo((Class<Value>) type);
- if (!((ValueTypeInfo<?>) info).isBasicValueType()) {
- throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type.");
- }
- } catch (ClassCastException | InvalidTypesException e) {
- throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type.", e);
- }
- }
- infos[i] = info;
- }
-
-
- return (TupleTypeInfo<X>) new TupleTypeInfo<>(infos);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java
deleted file mode 100644
index 469476f..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java
+++ /dev/null
@@ -1,251 +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.java.typeutils;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-
-public abstract class TupleTypeInfoBase<T> extends CompositeType<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final static String REGEX_FIELD = "(f?)([0-9]+)";
- private final static String REGEX_NESTED_FIELDS = "("+REGEX_FIELD+")(\\.(.+))?";
- private final static String REGEX_NESTED_FIELDS_WILDCARD = REGEX_NESTED_FIELDS
- +"|\\"+ExpressionKeys.SELECT_ALL_CHAR
- +"|\\"+ExpressionKeys.SELECT_ALL_CHAR_SCALA;
-
- private static final Pattern PATTERN_FIELD = Pattern.compile(REGEX_FIELD);
- private static final Pattern PATTERN_NESTED_FIELDS = Pattern.compile(REGEX_NESTED_FIELDS);
- private static final Pattern PATTERN_NESTED_FIELDS_WILDCARD = Pattern.compile(REGEX_NESTED_FIELDS_WILDCARD);
-
- // --------------------------------------------------------------------------------------------
-
- protected final TypeInformation<?>[] types;
-
- private final int totalFields;
-
- public TupleTypeInfoBase(Class<T> tupleType, TypeInformation<?>... types) {
- super(tupleType);
-
- this.types = Preconditions.checkNotNull(types);
-
- int fieldCounter = 0;
-
- for(TypeInformation<?> type : types) {
- fieldCounter += type.getTotalFields();
- }
-
- totalFields = fieldCounter;
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- @Override
- public boolean isTupleType() {
- return true;
- }
-
- public boolean isCaseClass() {
- return false;
- }
-
- @Override
- public int getArity() {
- return types.length;
- }
-
- @Override
- public int getTotalFields() {
- return totalFields;
- }
-
- @Override
- public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) {
-
- Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression);
- if (!matcher.matches()) {
- throw new InvalidFieldReferenceException("Invalid tuple field reference \""+fieldExpression+"\".");
- }
-
- String field = matcher.group(0);
- if (field.equals(ExpressionKeys.SELECT_ALL_CHAR) || field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
- // handle select all
- int keyPosition = 0;
- for (TypeInformation<?> type : types) {
- if (type instanceof CompositeType) {
- CompositeType<?> cType = (CompositeType<?>) type;
- cType.getFlatFields(String.valueOf(ExpressionKeys.SELECT_ALL_CHAR), offset + keyPosition, result);
- keyPosition += cType.getTotalFields() - 1;
- } else {
- result.add(new FlatFieldDescriptor(offset + keyPosition, type));
- }
- keyPosition++;
- }
- } else {
- String fieldStr = matcher.group(1);
- Matcher fieldMatcher = PATTERN_FIELD.matcher(fieldStr);
-
- if (!fieldMatcher.matches()) {
- throw new RuntimeException("Invalid matcher pattern");
- }
-
- field = fieldMatcher.group(2);
- int fieldPos = Integer.valueOf(field);
-
- if (fieldPos >= this.getArity()) {
- throw new InvalidFieldReferenceException("Tuple field expression \"" + fieldStr + "\" out of bounds of " + this.toString() + ".");
- }
- TypeInformation<?> fieldType = this.getTypeAt(fieldPos);
- String tail = matcher.group(5);
- if (tail == null) {
- if (fieldType instanceof CompositeType) {
- // forward offsets
- for (int i = 0; i < fieldPos; i++) {
- offset += this.getTypeAt(i).getTotalFields();
- }
- // add all fields of composite type
- ((CompositeType<?>) fieldType).getFlatFields("*", offset, result);
- } else {
- // we found the field to add
- // compute flat field position by adding skipped fields
- int flatFieldPos = offset;
- for (int i = 0; i < fieldPos; i++) {
- flatFieldPos += this.getTypeAt(i).getTotalFields();
- }
- result.add(new FlatFieldDescriptor(flatFieldPos, fieldType));
- }
- } else {
- if (fieldType instanceof CompositeType<?>) {
- // forward offset
- for (int i = 0; i < fieldPos; i++) {
- offset += this.getTypeAt(i).getTotalFields();
- }
- ((CompositeType<?>) fieldType).getFlatFields(tail, offset, result);
- } else {
- throw new InvalidFieldReferenceException("Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + ".");
- }
- }
- }
- }
-
- @Override
- public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
-
- Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
- if(!matcher.matches()) {
- if (fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR) || fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
- throw new InvalidFieldReferenceException("Wildcard expressions are not allowed here.");
- } else {
- throw new InvalidFieldReferenceException("Invalid format of tuple field expression \""+fieldExpression+"\".");
- }
- }
-
- String fieldStr = matcher.group(1);
- Matcher fieldMatcher = PATTERN_FIELD.matcher(fieldStr);
- if(!fieldMatcher.matches()) {
- throw new RuntimeException("Invalid matcher pattern");
- }
- String field = fieldMatcher.group(2);
- int fieldPos = Integer.valueOf(field);
-
- if(fieldPos >= this.getArity()) {
- throw new InvalidFieldReferenceException("Tuple field expression \""+fieldStr+"\" out of bounds of "+this.toString()+".");
- }
- TypeInformation<X> fieldType = this.getTypeAt(fieldPos);
- String tail = matcher.group(5);
- if(tail == null) {
- // we found the type
- return fieldType;
- } else {
- if(fieldType instanceof CompositeType<?>) {
- return ((CompositeType<?>) fieldType).getTypeAt(tail);
- } else {
- throw new InvalidFieldReferenceException("Nested field expression \""+tail+"\" not possible on atomic type "+fieldType+".");
- }
- }
- }
-
- @Override
- public <X> TypeInformation<X> getTypeAt(int pos) {
- if (pos < 0 || pos >= this.types.length) {
- throw new IndexOutOfBoundsException();
- }
-
- @SuppressWarnings("unchecked")
- TypeInformation<X> typed = (TypeInformation<X>) this.types[pos];
- return typed;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TupleTypeInfoBase) {
- @SuppressWarnings("unchecked")
- TupleTypeInfoBase<T> other = (TupleTypeInfoBase<T>) obj;
-
- return other.canEqual(this) &&
- super.equals(other) &&
- Arrays.equals(types, other.types) &&
- totalFields == other.totalFields;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof TupleTypeInfoBase;
- }
-
- @Override
- public int hashCode() {
- return 31 * (31 * super.hashCode() + Arrays.hashCode(types)) + totalFields;
- }
-
- @Override
- public String toString() {
- StringBuilder bld = new StringBuilder("Tuple");
- bld.append(types.length);
- if (types.length > 0) {
- bld.append('<').append(types[0]);
-
- for (int i = 1; i < types.length; i++) {
- bld.append(", ").append(types[i]);
- }
-
- bld.append('>');
- }
- return bld.toString();
- }
-
- @Override
- public boolean hasDeterministicFieldOrder() {
- return true;
- }
-}
[05/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java
deleted file mode 100644
index cd405bc..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java
+++ /dev/null
@@ -1,179 +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.java.typeutils;
-
-import static org.junit.Assert.*;
-
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.tuple.Tuple4;
-import org.junit.Test;
-
-public class CompositeTypeTest {
-
- private final TupleTypeInfo<?> tupleTypeInfo = new TupleTypeInfo<Tuple4<Integer, Integer, Integer, Integer>>(
- BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
-
-
- private final TupleTypeInfo<Tuple3<Integer, String, Long>> inNestedTuple1 = new TupleTypeInfo<Tuple3<Integer, String, Long>>(
- BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO);
-
- private final TupleTypeInfo<Tuple2<Double, Double>> inNestedTuple2 = new TupleTypeInfo<Tuple2<Double, Double>>(
- BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO);
-
- private final TupleTypeInfo<?> nestedTypeInfo = new TupleTypeInfo<Tuple4<Integer, Tuple3<Integer, String, Long>, Integer, Tuple2<Double, Double>>>(
- BasicTypeInfo.INT_TYPE_INFO,
- inNestedTuple1,
- BasicTypeInfo.INT_TYPE_INFO,
- inNestedTuple2);
-
- private final TupleTypeInfo<Tuple2<Integer, Tuple2<Integer, Integer>>> inNestedTuple3 = new TupleTypeInfo<Tuple2<Integer, Tuple2<Integer, Integer>>>(
- BasicTypeInfo.INT_TYPE_INFO,
- new TupleTypeInfo<Tuple2<Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO));
-
- private final TupleTypeInfo<?> deepNestedTupleTypeInfo = new TupleTypeInfo<Tuple3<Integer, Tuple2<Integer, Tuple2<Integer, Integer>>, Integer>>(
- BasicTypeInfo.INT_TYPE_INFO,
- inNestedTuple3,
- BasicTypeInfo.INT_TYPE_INFO );
-
- private final PojoTypeInfo<?> pojoTypeInfo = ((PojoTypeInfo<?>) TypeExtractor.getForClass
- (MyPojo.class));
-
- private final TupleTypeInfo<?> pojoInTupleTypeInfo = new TupleTypeInfo<Tuple2<Integer, MyPojo>>(BasicTypeInfo.INT_TYPE_INFO, pojoTypeInfo);
-
- @Test
- public void testGetFlatFields() {
- assertEquals(0, tupleTypeInfo.getFlatFields("0").get(0).getPosition());
- assertEquals(1, tupleTypeInfo.getFlatFields("1").get(0).getPosition());
- assertEquals(2, tupleTypeInfo.getFlatFields("2").get(0).getPosition());
- assertEquals(3, tupleTypeInfo.getFlatFields("3").get(0).getPosition());
- assertEquals(0, tupleTypeInfo.getFlatFields("f0").get(0).getPosition());
- assertEquals(1, tupleTypeInfo.getFlatFields("f1").get(0).getPosition());
- assertEquals(2, tupleTypeInfo.getFlatFields("f2").get(0).getPosition());
- assertEquals(3, tupleTypeInfo.getFlatFields("f3").get(0).getPosition());
-
- assertEquals(0, nestedTypeInfo.getFlatFields("0").get(0).getPosition());
- assertEquals(1, nestedTypeInfo.getFlatFields("1.0").get(0).getPosition());
- assertEquals(2, nestedTypeInfo.getFlatFields("1.1").get(0).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("1.2").get(0).getPosition());
- assertEquals(4, nestedTypeInfo.getFlatFields("2").get(0).getPosition());
- assertEquals(5, nestedTypeInfo.getFlatFields("3.0").get(0).getPosition());
- assertEquals(6, nestedTypeInfo.getFlatFields("3.1").get(0).getPosition());
- assertEquals(4, nestedTypeInfo.getFlatFields("f2").get(0).getPosition());
- assertEquals(5, nestedTypeInfo.getFlatFields("f3.f0").get(0).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("1").size());
- assertEquals(1, nestedTypeInfo.getFlatFields("1").get(0).getPosition());
- assertEquals(2, nestedTypeInfo.getFlatFields("1").get(1).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("1").get(2).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("1.*").size());
- assertEquals(1, nestedTypeInfo.getFlatFields("1.*").get(0).getPosition());
- assertEquals(2, nestedTypeInfo.getFlatFields("1.*").get(1).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("1.*").get(2).getPosition());
- assertEquals(2, nestedTypeInfo.getFlatFields("3").size());
- assertEquals(5, nestedTypeInfo.getFlatFields("3").get(0).getPosition());
- assertEquals(6, nestedTypeInfo.getFlatFields("3").get(1).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("f1").size());
- assertEquals(1, nestedTypeInfo.getFlatFields("f1").get(0).getPosition());
- assertEquals(2, nestedTypeInfo.getFlatFields("f1").get(1).getPosition());
- assertEquals(3, nestedTypeInfo.getFlatFields("f1").get(2).getPosition());
- assertEquals(2, nestedTypeInfo.getFlatFields("f3").size());
- assertEquals(5, nestedTypeInfo.getFlatFields("f3").get(0).getPosition());
- assertEquals(6, nestedTypeInfo.getFlatFields("f3").get(1).getPosition());
- assertEquals(BasicTypeInfo.INT_TYPE_INFO,
- nestedTypeInfo.getFlatFields("0").get(0).getType());
- assertEquals(BasicTypeInfo.STRING_TYPE_INFO,
- nestedTypeInfo.getFlatFields("1.1").get(0).getType());
- assertEquals(BasicTypeInfo.LONG_TYPE_INFO,
- nestedTypeInfo.getFlatFields("1").get(2).getType());
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO,
- nestedTypeInfo.getFlatFields("3").get(1).getType());
-
- assertEquals(3, deepNestedTupleTypeInfo.getFlatFields("1").size());
- assertEquals(1, deepNestedTupleTypeInfo.getFlatFields("1").get(0).getPosition());
- assertEquals(2, deepNestedTupleTypeInfo.getFlatFields("1").get(1).getPosition());
- assertEquals(3, deepNestedTupleTypeInfo.getFlatFields("1").get(2).getPosition());
- assertEquals(5, deepNestedTupleTypeInfo.getFlatFields("*").size());
- assertEquals(0, deepNestedTupleTypeInfo.getFlatFields("*").get(0).getPosition());
- assertEquals(1, deepNestedTupleTypeInfo.getFlatFields("*").get(1).getPosition());
- assertEquals(2, deepNestedTupleTypeInfo.getFlatFields("*").get(2).getPosition());
- assertEquals(3, deepNestedTupleTypeInfo.getFlatFields("*").get(3).getPosition());
- assertEquals(4, deepNestedTupleTypeInfo.getFlatFields("*").get(4).getPosition());
-
- assertEquals(0, pojoTypeInfo.getFlatFields("a").get(0).getPosition());
- assertEquals(1, pojoTypeInfo.getFlatFields("b").get(0).getPosition());
- assertEquals(2, pojoTypeInfo.getFlatFields("*").size());
- assertEquals(0, pojoTypeInfo.getFlatFields("*").get(0).getPosition());
- assertEquals(1, pojoTypeInfo.getFlatFields("*").get(1).getPosition());
-
- assertEquals(1, pojoInTupleTypeInfo.getFlatFields("f1.a").get(0).getPosition());
- assertEquals(2, pojoInTupleTypeInfo.getFlatFields("1.b").get(0).getPosition());
- assertEquals(2, pojoInTupleTypeInfo.getFlatFields("1").size());
- assertEquals(1, pojoInTupleTypeInfo.getFlatFields("1.*").get(0).getPosition());
- assertEquals(2, pojoInTupleTypeInfo.getFlatFields("1").get(1).getPosition());
- assertEquals(2, pojoInTupleTypeInfo.getFlatFields("f1.*").size());
- assertEquals(1, pojoInTupleTypeInfo.getFlatFields("f1.*").get(0).getPosition());
- assertEquals(2, pojoInTupleTypeInfo.getFlatFields("f1").get(1).getPosition());
- assertEquals(3, pojoInTupleTypeInfo.getFlatFields("*").size());
- assertEquals(0, pojoInTupleTypeInfo.getFlatFields("*").get(0).getPosition());
- assertEquals(1, pojoInTupleTypeInfo.getFlatFields("*").get(1).getPosition());
- assertEquals(2, pojoInTupleTypeInfo.getFlatFields("*").get(2).getPosition());
-
- }
-
- @Test
- public void testFieldAtStringRef() {
-
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("0"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("2"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("f1"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("f3"));
-
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("0"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("1.0"));
- assertEquals(BasicTypeInfo.STRING_TYPE_INFO, nestedTypeInfo.getTypeAt("1.1"));
- assertEquals(BasicTypeInfo.LONG_TYPE_INFO, nestedTypeInfo.getTypeAt("1.2"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("2"));
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, nestedTypeInfo.getTypeAt("3.0"));
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, nestedTypeInfo.getTypeAt("3.1"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("f2"));
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, nestedTypeInfo.getTypeAt("f3.f0"));
- assertEquals(inNestedTuple1, nestedTypeInfo.getTypeAt("1"));
- assertEquals(inNestedTuple2, nestedTypeInfo.getTypeAt("3"));
- assertEquals(inNestedTuple1, nestedTypeInfo.getTypeAt("f1"));
- assertEquals(inNestedTuple2, nestedTypeInfo.getTypeAt("f3"));
-
- assertEquals(inNestedTuple3, deepNestedTupleTypeInfo.getTypeAt("1"));
-
- assertEquals(BasicTypeInfo.STRING_TYPE_INFO, pojoTypeInfo.getTypeAt("a"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, pojoTypeInfo.getTypeAt("b"));
-
- assertEquals(BasicTypeInfo.STRING_TYPE_INFO, pojoInTupleTypeInfo.getTypeAt("f1.a"));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, pojoInTupleTypeInfo.getTypeAt("1.b"));
- assertEquals(pojoTypeInfo, pojoInTupleTypeInfo.getTypeAt("1"));
- assertEquals(pojoTypeInfo, pojoInTupleTypeInfo.getTypeAt("f1"));
-
- }
-
- public static class MyPojo {
- public String a;
- public int b;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java
deleted file mode 100644
index caa3402..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java
+++ /dev/null
@@ -1,60 +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.java.typeutils;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.typeutils.Either.Right;
-import org.apache.flink.util.TestLogger;
-import org.junit.Test;
-
-public class EitherTypeInfoTest extends TestLogger {
-
- Either<Integer, String> intEither = Either.Left(1);
- Either<Integer, String> stringEither = Either.Right("boo");
- Either<Integer, Tuple2<Double, Long>> tuple2Either = new Right<>(new Tuple2<Double, Long>(42.0, 2l));
-
- @Test
- public void testEitherTypeEquality() {
- EitherTypeInfo<Integer, String> eitherInfo1 = new EitherTypeInfo<Integer, String>(
- BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
-
- EitherTypeInfo<Integer, String> eitherInfo2 = new EitherTypeInfo<Integer, String>(
- BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
-
- assertEquals(eitherInfo1, eitherInfo2);
- assertEquals(eitherInfo1.hashCode(), eitherInfo2.hashCode());
- }
-
- @Test
- public void testEitherTypeInEquality() {
- EitherTypeInfo<Integer, String> eitherInfo1 = new EitherTypeInfo<Integer, String>(
- BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
-
- EitherTypeInfo<Integer, Tuple2<Double, Long>> eitherInfo2 = new EitherTypeInfo<Integer, Tuple2<Double, Long>>(
- BasicTypeInfo.INT_TYPE_INFO, new TupleTypeInfo<Tuple2<Double, Long>>(
- TypeExtractor.getForClass(Double.class), TypeExtractor.getForClass(String.class)));
-
- assertNotEquals(eitherInfo1, eitherInfo2);
- assertNotEquals(eitherInfo1.hashCode(), eitherInfo2.hashCode());
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java
deleted file mode 100644
index b200566..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java
+++ /dev/null
@@ -1,51 +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.java.typeutils;
-
-import org.apache.flink.util.TestLogger;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class EnumTypeInfoTest extends TestLogger {
-
- enum TestEnum {
- ONE, TWO
- }
-
- enum AlternativeEnum {
- ONE, TWO
- }
-
- @Test
- public void testEnumTypeEquality() {
- EnumTypeInfo<TestEnum> enumTypeInfo1 = new EnumTypeInfo<TestEnum>(TestEnum.class);
- EnumTypeInfo<TestEnum> enumTypeInfo2 = new EnumTypeInfo<TestEnum>(TestEnum.class);
-
- assertEquals(enumTypeInfo1, enumTypeInfo2);
- assertEquals(enumTypeInfo1.hashCode(), enumTypeInfo2.hashCode());
- }
-
- @Test
- public void testEnumTypeInequality() {
- EnumTypeInfo<TestEnum> enumTypeInfo1 = new EnumTypeInfo<TestEnum>(TestEnum.class);
- EnumTypeInfo<AlternativeEnum> enumTypeInfo2 = new EnumTypeInfo<AlternativeEnum>(AlternativeEnum.class);
-
- assertNotEquals(enumTypeInfo1, enumTypeInfo2);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java
deleted file mode 100644
index fad43df..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java
+++ /dev/null
@@ -1,47 +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.java.typeutils;
-
-import org.apache.flink.util.TestLogger;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class GenericTypeInfoTest extends TestLogger {
-
- static class TestClass {}
- static class AlternativeClass {}
-
- @Test
- public void testGenericTypeInfoEquality() {
- GenericTypeInfo<TestClass> tpeInfo1 = new GenericTypeInfo<>(TestClass.class);
- GenericTypeInfo<TestClass> tpeInfo2 = new GenericTypeInfo<>(TestClass.class);
-
- assertEquals(tpeInfo1, tpeInfo2);
- assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
- }
-
- @Test
- public void testGenericTypeInfoInequality() {
- GenericTypeInfo<TestClass> tpeInfo1 = new GenericTypeInfo<>(TestClass.class);
- GenericTypeInfo<AlternativeClass> tpeInfo2 = new GenericTypeInfo<>(AlternativeClass.class);
-
- assertNotEquals(tpeInfo1, tpeInfo2);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java
deleted file mode 100644
index ee57475..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java
+++ /dev/null
@@ -1,47 +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.java.typeutils;
-
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.util.TestLogger;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class MissingTypeInfoTest extends TestLogger {
- static final String functionName = "foobar";
- static final InvalidTypesException testException = new InvalidTypesException("Test exception.");
-
- @Test
- public void testMissingTypeInfoEquality() {
- MissingTypeInfo tpeInfo1 = new MissingTypeInfo(functionName, testException);
- MissingTypeInfo tpeInfo2 = new MissingTypeInfo(functionName, testException);
-
- assertEquals(tpeInfo1, tpeInfo2);
- assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
- }
-
- @Test
- public void testMissingTypeInfoInequality() {
- MissingTypeInfo tpeInfo1 = new MissingTypeInfo(functionName, testException);
- MissingTypeInfo tpeInfo2 = new MissingTypeInfo("alt" + functionName, testException);
-
- assertNotEquals(tpeInfo1, tpeInfo2);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java
deleted file mode 100644
index f3b39c0..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java
+++ /dev/null
@@ -1,58 +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.java.typeutils;
-
-import org.apache.flink.util.TestLogger;
-import org.junit.Test;
-
-import java.util.ArrayList;
-
-import static org.junit.Assert.*;
-
-public class ObjectArrayTypeInfoTest extends TestLogger {
-
- public static class TestClass{}
-
- @Test
- public void testObjectArrayTypeInfoEquality() {
- ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo1 = ObjectArrayTypeInfo.getInfoFor(
- TestClass[].class,
- new GenericTypeInfo<TestClass>(TestClass.class));
-
- ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo2 = ObjectArrayTypeInfo.getInfoFor(
- TestClass[].class,
- new GenericTypeInfo<TestClass>(TestClass.class));
-
- assertEquals(tpeInfo1, tpeInfo2);
- assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
- }
-
- @Test
- public void testObjectArrayTypeInfoInequality() {
- ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo1 = ObjectArrayTypeInfo.getInfoFor(
- TestClass[].class,
- new GenericTypeInfo<TestClass>(TestClass.class));
-
- ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo2 = ObjectArrayTypeInfo.getInfoFor(
- TestClass[].class,
- new PojoTypeInfo<TestClass>(TestClass.class, new ArrayList<PojoField>()));
-
- assertNotEquals(tpeInfo1, tpeInfo2);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java
deleted file mode 100644
index dbe5115..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java
+++ /dev/null
@@ -1,153 +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.java.typeutils;
-
-import static org.junit.Assert.*;
-
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.util.InstantiationUtil;
-import org.junit.Test;
-
-import java.io.IOException;
-
-public class PojoTypeInfoTest {
-
- @Test
- public void testPojoTypeInfoEquality() {
- try {
- TypeInformation<TestPojo> info1 = TypeExtractor.getForClass(TestPojo.class);
- TypeInformation<TestPojo> info2 = TypeExtractor.getForClass(TestPojo.class);
-
- assertTrue(info1 instanceof PojoTypeInfo);
- assertTrue(info2 instanceof PojoTypeInfo);
-
- assertTrue(info1.equals(info2));
- assertTrue(info1.hashCode() == info2.hashCode());
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testPojoTypeInfoInequality() {
- try {
- TypeInformation<TestPojo> info1 = TypeExtractor.getForClass(TestPojo.class);
- TypeInformation<AlternatePojo> info2 = TypeExtractor.getForClass(AlternatePojo.class);
-
- assertTrue(info1 instanceof PojoTypeInfo);
- assertTrue(info2 instanceof PojoTypeInfo);
-
- assertFalse(info1.equals(info2));
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testSerializabilityOfPojoTypeInfo() throws IOException, ClassNotFoundException {
- PojoTypeInfo<TestPojo> pojoTypeInfo = (PojoTypeInfo<TestPojo>)TypeExtractor.getForClass(TestPojo.class);
-
- byte[] serializedPojoTypeInfo = InstantiationUtil.serializeObject(pojoTypeInfo);
- PojoTypeInfo<TestPojo> deserializedPojoTypeInfo = (PojoTypeInfo<TestPojo>)InstantiationUtil.deserializeObject(
- serializedPojoTypeInfo,
- getClass().getClassLoader());
-
- assertEquals(pojoTypeInfo, deserializedPojoTypeInfo);
- }
-
- @Test
- public void testPrimitivePojo() {
- TypeInformation<PrimitivePojo> info1 = TypeExtractor.getForClass(PrimitivePojo.class);
-
- assertTrue(info1 instanceof PojoTypeInfo);
- }
-
- @Test
- public void testUnderscorePojo() {
- TypeInformation<UnderscorePojo> info1 = TypeExtractor.getForClass(UnderscorePojo.class);
-
- assertTrue(info1 instanceof PojoTypeInfo);
- }
-
- public static final class TestPojo {
-
- public int someInt;
-
- private String aString;
-
- public Double[] doubleArray;
-
-
- public void setaString(String aString) {
- this.aString = aString;
- }
-
- public String getaString() {
- return aString;
- }
- }
-
- public static final class AlternatePojo {
-
- public int someInt;
-
- private String aString;
-
- public Double[] doubleArray;
-
-
- public void setaString(String aString) {
- this.aString = aString;
- }
-
- public String getaString() {
- return aString;
- }
- }
-
- public static final class PrimitivePojo {
-
- private int someInt;
-
- public void setSomeInt(Integer someInt) {
- this.someInt = someInt;
- }
-
- public Integer getSomeInt() {
- return this.someInt;
- }
- }
-
- public static final class UnderscorePojo {
-
- private int some_int;
-
- public void setSomeInt(int some_int) {
- this.some_int = some_int;
- }
-
- public Integer getSomeInt() {
- return this.some_int;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java
deleted file mode 100644
index b6cff34..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java
+++ /dev/null
@@ -1,96 +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.java.typeutils;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple1;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.util.TestLogger;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TupleTypeInfoTest extends TestLogger {
-
- @Test
- public void testTupleTypeInfoSymmetricEqualityRelation() {
- TupleTypeInfo<Tuple1<Integer>> tupleTypeInfo = new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO);
-
- TupleTypeInfoBase<Tuple1> anonymousTupleTypeInfo = new TupleTypeInfoBase<Tuple1>(
- (Class<Tuple1>)Tuple1.class,
- (TypeInformation<?>)BasicTypeInfo.INT_TYPE_INFO) {
-
- private static final long serialVersionUID = -7985593598027660836L;
-
- @Override
- public TypeSerializer<Tuple1> createSerializer(ExecutionConfig config) {
- return null;
- }
-
- @Override
- protected TypeComparatorBuilder<Tuple1> createTypeComparatorBuilder() {
- return null;
- }
-
- @Override
- public String[] getFieldNames() {
- return new String[0];
- }
-
- @Override
- public int getFieldIndex(String fieldName) {
- return 0;
- }
- };
-
- boolean tupleVsAnonymous = tupleTypeInfo.equals(anonymousTupleTypeInfo);
- boolean anonymousVsTuple = anonymousTupleTypeInfo.equals(tupleTypeInfo);
-
- Assert.assertTrue("Equality relation should be symmetric", tupleVsAnonymous == anonymousVsTuple);
- }
-
- @Test
- public void testTupleTypeInfoEquality() {
- TupleTypeInfo<Tuple2<Integer, String>> tupleTypeInfo1 = new TupleTypeInfo<>(
- BasicTypeInfo.INT_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO);
-
- TupleTypeInfo<Tuple2<Integer, String>> tupleTypeInfo2 = new TupleTypeInfo<>(
- BasicTypeInfo.INT_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO);
-
- Assert.assertEquals(tupleTypeInfo1, tupleTypeInfo2);
- Assert.assertEquals(tupleTypeInfo1.hashCode(), tupleTypeInfo2.hashCode());
- }
-
- @Test
- public void testTupleTypeInfoInequality() {
- TupleTypeInfo<Tuple2<Integer, String>> tupleTypeInfo1 = new TupleTypeInfo<>(
- BasicTypeInfo.INT_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO);
-
- TupleTypeInfo<Tuple2<Integer, Boolean>> tupleTypeInfo2 = new TupleTypeInfo<>(
- BasicTypeInfo.INT_TYPE_INFO,
- BasicTypeInfo.BOOLEAN_TYPE_INFO);
-
- Assert.assertNotEquals(tupleTypeInfo1, tupleTypeInfo2);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java
deleted file mode 100644
index e225460..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java
+++ /dev/null
@@ -1,338 +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.java.typeutils;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.junit.Assert;
-import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.types.BooleanValue;
-import org.apache.flink.types.ByteValue;
-import org.apache.flink.types.CharValue;
-import org.apache.flink.types.DoubleValue;
-import org.apache.flink.types.FloatValue;
-import org.apache.flink.types.IntValue;
-import org.apache.flink.types.ListValue;
-import org.apache.flink.types.LongValue;
-import org.apache.flink.types.MapValue;
-import org.apache.flink.types.NullValue;
-import org.apache.flink.types.ShortValue;
-import org.apache.flink.types.StringValue;
-import org.apache.hadoop.io.Writable;
-import org.junit.Test;
-
-public class TypeInfoParserTest {
-
- @Test
- public void testBasicTypes() {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, TypeInfoParser.parse("Integer"));
- Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, TypeInfoParser.parse("Double"));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, TypeInfoParser.parse("Byte"));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, TypeInfoParser.parse("Float"));
- Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, TypeInfoParser.parse("Short"));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, TypeInfoParser.parse("Long"));
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, TypeInfoParser.parse("Character"));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, TypeInfoParser.parse("String"));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeInfoParser.parse("Boolean"));
- Assert.assertEquals(BasicTypeInfo.VOID_TYPE_INFO, TypeInfoParser.parse("Void"));
- Assert.assertEquals(BasicTypeInfo.DATE_TYPE_INFO, TypeInfoParser.parse("Date"));
-
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, TypeInfoParser.parse("java.lang.Integer"));
- Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, TypeInfoParser.parse("java.lang.Double"));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, TypeInfoParser.parse("java.lang.Byte"));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, TypeInfoParser.parse("java.lang.Float"));
- Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, TypeInfoParser.parse("java.lang.Short"));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, TypeInfoParser.parse("java.lang.Long"));
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, TypeInfoParser.parse("java.lang.Character"));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, TypeInfoParser.parse("java.lang.String"));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeInfoParser.parse("java.lang.Boolean"));
- Assert.assertEquals(BasicTypeInfo.VOID_TYPE_INFO, TypeInfoParser.parse("java.lang.Void"));
- Assert.assertEquals(BasicTypeInfo.DATE_TYPE_INFO, TypeInfoParser.parse("java.util.Date"));
-
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, TypeInfoParser.parse("int"));
- Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, TypeInfoParser.parse("double"));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, TypeInfoParser.parse("byte"));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, TypeInfoParser.parse("float"));
- Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, TypeInfoParser.parse("short"));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, TypeInfoParser.parse("long"));
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, TypeInfoParser.parse("char"));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeInfoParser.parse("boolean"));
- Assert.assertEquals(BasicTypeInfo.VOID_TYPE_INFO, TypeInfoParser.parse("void"));
- }
-
- @Test
- public void testValueTypes() {
- helperValueType("StringValue", StringValue.class);
- helperValueType("IntValue", IntValue.class);
- helperValueType("ByteValue", ByteValue.class);
- helperValueType("ShortValue", ShortValue.class);
- helperValueType("CharValue", CharValue.class);
- helperValueType("DoubleValue", DoubleValue.class);
- helperValueType("FloatValue", FloatValue.class);
- helperValueType("LongValue", LongValue.class);
- helperValueType("BooleanValue", BooleanValue.class);
- helperValueType("ListValue", ListValue.class);
- helperValueType("MapValue", MapValue.class);
- helperValueType("NullValue", NullValue.class);
- }
-
- private static void helperValueType(String str, Class<?> clazz) {
- TypeInformation<?> ti = TypeInfoParser.parse(str);
- Assert.assertTrue(ti instanceof ValueTypeInfo);
- ValueTypeInfo<?> vti = (ValueTypeInfo<?>) ti;
- Assert.assertEquals(clazz, vti.getTypeClass());
- }
-
- @Test
- public void testBasicArrays() {
- Assert.assertEquals(BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, TypeInfoParser.parse("Integer[]"));
- Assert.assertEquals(BasicArrayTypeInfo.DOUBLE_ARRAY_TYPE_INFO, TypeInfoParser.parse("Double[]"));
- Assert.assertEquals(BasicArrayTypeInfo.BYTE_ARRAY_TYPE_INFO, TypeInfoParser.parse("Byte[]"));
- Assert.assertEquals(BasicArrayTypeInfo.FLOAT_ARRAY_TYPE_INFO, TypeInfoParser.parse("Float[]"));
- Assert.assertEquals(BasicArrayTypeInfo.SHORT_ARRAY_TYPE_INFO, TypeInfoParser.parse("Short[]"));
- Assert.assertEquals(BasicArrayTypeInfo.LONG_ARRAY_TYPE_INFO, TypeInfoParser.parse("Long[]"));
- Assert.assertEquals(BasicArrayTypeInfo.CHAR_ARRAY_TYPE_INFO, TypeInfoParser.parse("Character[]"));
- Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, TypeInfoParser.parse("String[]"));
- Assert.assertEquals(BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO, TypeInfoParser.parse("Boolean[]"));
-
- Assert.assertEquals(BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Integer[]"));
- Assert.assertEquals(BasicArrayTypeInfo.DOUBLE_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Double[]"));
- Assert.assertEquals(BasicArrayTypeInfo.BYTE_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Byte[]"));
- Assert.assertEquals(BasicArrayTypeInfo.FLOAT_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Float[]"));
- Assert.assertEquals(BasicArrayTypeInfo.SHORT_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Short[]"));
- Assert.assertEquals(BasicArrayTypeInfo.LONG_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Long[]"));
- Assert.assertEquals(BasicArrayTypeInfo.CHAR_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Character[]"));
- Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.String[]"));
- Assert.assertEquals(BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Boolean[]"));
-
- Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("int[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("double[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("byte[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("float[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("short[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("long[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("char[]"));
- Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("boolean[]"));
- }
-
- @Test
- public void testTuples() {
- TypeInformation<?> ti = TypeInfoParser.parse("Tuple2<Integer, Long>");
- Assert.assertEquals(2, ti.getArity());
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>)ti).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>)ti).getTypeAt(1));
-
- ti = TypeInfoParser.parse("Tuple0");
- Assert.assertEquals(0, ti.getArity());
- Assert.assertEquals("Java Tuple0", ti.toString());
-
- ti = TypeInfoParser.parse("org.apache.flink.api.java.tuple.Tuple0");
- Assert.assertEquals(0, ti.getArity());
- Assert.assertEquals("Java Tuple0", ti.toString());
-
- ti = TypeInfoParser.parse("Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>");
- Assert.assertEquals("Java Tuple3<Java Tuple1<String>, Java Tuple1<Integer>, Java Tuple2<Long, Long>>", ti.toString());
- }
-
- @Test
- public void testGenericType() {
- TypeInformation<?> ti = TypeInfoParser.parse("java.lang.Class");
- Assert.assertTrue(ti instanceof GenericTypeInfo);
- Assert.assertEquals(Class.class, ((GenericTypeInfo<?>) ti).getTypeClass());
- }
-
- public static class MyPojo {
- public Integer basic;
- public Tuple2<String, Integer> tuple;
- public MyWritable hadoopCitizen;
- public String[] array;
- }
-
- @Test
- public void testPojoType() {
- TypeInformation<?> ti = TypeInfoParser.parse(
- "org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<"
- + "basic=Integer,"
- + "tuple=Tuple2<String, Integer>,"
- + "hadoopCitizen=Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>,"
- + "array=String[]"
- + ">");
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
- Assert.assertEquals("array", pti.getPojoFieldAt(0).getField().getName());
- Assert.assertTrue(pti.getPojoFieldAt(0).getTypeInformation() instanceof BasicArrayTypeInfo);
- Assert.assertEquals("basic", pti.getPojoFieldAt(1).getField().getName());
- Assert.assertTrue(pti.getPojoFieldAt(1).getTypeInformation() instanceof BasicTypeInfo);
- Assert.assertEquals("hadoopCitizen", pti.getPojoFieldAt(2).getField().getName());
- Assert.assertTrue(pti.getPojoFieldAt(2).getTypeInformation() instanceof WritableTypeInfo);
- Assert.assertEquals("tuple", pti.getPojoFieldAt(3).getField().getName());
- Assert.assertTrue(pti.getPojoFieldAt(3).getTypeInformation() instanceof TupleTypeInfo);
- }
-
- @Test
- public void testPojoType2() {
- TypeInformation<?> ti = TypeInfoParser.parse("Tuple2<String,Tuple2<Integer,org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<basic=String>>>");
- Assert.assertTrue(ti instanceof TupleTypeInfo);
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertTrue(tti.getTypeAt(0) instanceof BasicTypeInfo);
- Assert.assertTrue(tti.getTypeAt(1) instanceof TupleTypeInfo);
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>)(Object)tti.getTypeAt(1);
- Assert.assertTrue(tti2.getTypeAt(0) instanceof BasicTypeInfo);
- Assert.assertTrue(tti2.getTypeAt(1) instanceof PojoTypeInfo);
- PojoTypeInfo<?> pti = (PojoTypeInfo<?>) tti2.getTypeAt(1);
- Assert.assertEquals("basic", pti.getPojoFieldAt(0).getField().getName());
- Assert.assertTrue(pti.getPojoFieldAt(0).getTypeInformation() instanceof BasicTypeInfo);
- }
-
- public static class MyWritable implements Writable {
-
- @Override
- public void write(DataOutput out) throws IOException {
-
- }
-
- @Override
- public void readFields(DataInput in) throws IOException {
-
- }
-
- }
-
- @Test
- public void testWritableType() {
- TypeInformation<?> ti = TypeInfoParser.parse("Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>");
- Assert.assertTrue(ti instanceof WritableTypeInfo<?>);
- Assert.assertEquals(MyWritable.class, ((WritableTypeInfo<?>) ti).getTypeClass());
- }
-
- @Test
- public void testObjectArrays() {
- TypeInformation<?> ti = TypeInfoParser.parse("java.lang.Class[]");
-
- Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
- Assert.assertEquals(Class.class, ((ObjectArrayTypeInfo<?, ?>) ti).getComponentInfo().getTypeClass());
-
- TypeInformation<?> ti2 = TypeInfoParser.parse("Tuple2<Integer,Double>[]");
-
- Assert.assertTrue(ti2 instanceof ObjectArrayTypeInfo<?, ?>);
- Assert.assertTrue(((ObjectArrayTypeInfo<?, ?>) ti2).getComponentInfo() instanceof TupleTypeInfo);
-
- TypeInformation<?> ti3 = TypeInfoParser.parse("Tuple2<Integer[],Double>[]");
- Assert.assertEquals("ObjectArrayTypeInfo<Java Tuple2<BasicArrayTypeInfo<Integer>, Double>>", ti3.toString());
- }
-
- @Test
- public void testLargeMixedTuple() {
- TypeInformation<?> ti = TypeInfoParser.parse("org.apache.flink.api.java.tuple.Tuple4<Double,java.lang.Class[],StringValue,Tuple1<int>>[]");
- Assert.assertEquals("ObjectArrayTypeInfo<Java Tuple4<Double, ObjectArrayTypeInfo<GenericType<java.lang.Class>>, ValueType<StringValue>, Java Tuple1<Integer>>>", ti.toString());
- }
-
- public static enum MyEnum {
- ONE, TWO, THREE
- }
-
- @Test
- public void testEnumType() {
- TypeInformation<?> ti = TypeInfoParser.parse("Enum<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>");
- Assert.assertEquals("EnumTypeInfo<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>", ti.toString());
-
- TypeInformation<?> ti2 = TypeInfoParser.parse("java.lang.Enum<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>");
- Assert.assertEquals("EnumTypeInfo<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>", ti2.toString());
- }
-
- @Test
- public void testException() {
- try {
- TypeInfoParser.parse("THIS_CLASS_DOES_NOT_EXIST");
- Assert.fail("exception expected");
- } catch (IllegalArgumentException e) {
- // right
- }
-
- try {
- TypeInfoParser.parse("Tuple2<Integer>");
- Assert.fail("exception expected");
- } catch (IllegalArgumentException e) {
- // right
- }
-
- try {
- TypeInfoParser.parse("Tuple3<Integer,,>");
- Assert.fail("exception expected");
- } catch (IllegalArgumentException e) {
- // right
- }
-
- try {
- TypeInfoParser.parse("Tuple1<Integer,Double>");
- Assert.fail("exception expected");
- } catch (IllegalArgumentException e) {
- // right
- }
- }
-
- @Test
- public void testMultiDimensionalArray() {
- // tuple
- TypeInformation<?> ti = TypeInfoParser.parse("Tuple2<Integer, Double>[][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<Java Tuple2<Integer, Double>>>", ti.toString());
-
- // pojos
- ti = TypeInfoParser.parse("org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<basic=String>[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
- + "PojoType<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo, fields = [basic: String]>"
- + ">>>", ti.toString());
-
- // basic types
- ti = TypeInfoParser.parse("Float[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<BasicArrayTypeInfo<Float>>>", ti.toString());
- ti = TypeInfoParser.parse("String[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<BasicArrayTypeInfo<String>>>", ti.toString());
- ti = TypeInfoParser.parse("Date[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<Date>>>", ti.toString());
-
- // primitive types
- ti = TypeInfoParser.parse("int[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<int[]>>", ti.toString());
- ti = TypeInfoParser.parse("boolean[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<boolean[]>>", ti.toString());
-
- // value types
- ti = TypeInfoParser.parse("IntValue[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<ValueType<IntValue>>>>", ti.toString());
-
- // writable types
- ti = TypeInfoParser.parse("Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
- + "WritableType<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>"
- + ">>>", ti.toString());
-
- // enum types
- ti = TypeInfoParser.parse("Enum<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>[][][]");
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
- + "EnumTypeInfo<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>"
- + ">>>", ti.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java
deleted file mode 100644
index 4a579c8..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java
+++ /dev/null
@@ -1,87 +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.java.typeutils;
-
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.types.Record;
-import org.apache.flink.types.Value;
-import org.apache.flink.util.TestLogger;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-
-import static org.junit.Assert.*;
-
-public class ValueTypeInfoTest extends TestLogger {
-
- public static class TestClass implements Value {
- private static final long serialVersionUID = -492760806806568285L;
-
- @Override
- public void write(DataOutputView out) throws IOException {
-
- }
-
- @Override
- public void read(DataInputView in) throws IOException {
-
- }
- }
-
- public static class AlternativeClass implements Value {
-
- private static final long serialVersionUID = -163437084575260172L;
-
- @Override
- public void write(DataOutputView out) throws IOException {
-
- }
-
- @Override
- public void read(DataInputView in) throws IOException {
-
- }
- }
-
- @Test
- public void testValueTypeInfoEquality() {
- ValueTypeInfo<TestClass> tpeInfo1 = new ValueTypeInfo<>(TestClass.class);
- ValueTypeInfo<TestClass> tpeInfo2 = new ValueTypeInfo<>(TestClass.class);
-
- assertEquals(tpeInfo1, tpeInfo2);
- assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
- }
-
- @Test
- public void testValueTyepInfoInequality() {
- ValueTypeInfo<TestClass> tpeInfo1 = new ValueTypeInfo<>(TestClass.class);
- ValueTypeInfo<AlternativeClass> tpeInfo2 = new ValueTypeInfo<>(AlternativeClass.class);
-
- assertNotEquals(tpeInfo1, tpeInfo2);
- }
-
- @Test
- public void testValueTypeEqualsWithNull() throws Exception {
- ValueTypeInfo<Record> tpeInfo = new ValueTypeInfo<>(Record.class);
-
- Assert.assertFalse(tpeInfo.equals(null));
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java
deleted file mode 100644
index 2ab0021..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java
+++ /dev/null
@@ -1,74 +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.java.typeutils;
-
-import org.apache.flink.util.TestLogger;
-import org.apache.hadoop.io.Writable;
-import org.junit.Test;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import static org.junit.Assert.*;
-
-public class WritableTypeInfoTest extends TestLogger {
-
- public static class TestClass implements Writable {
- @Override
- public void write(DataOutput dataOutput) throws IOException {
-
- }
-
- @Override
- public void readFields(DataInput dataInput) throws IOException {
-
- }
- }
-
- public static class AlternateClass implements Writable {
- @Override
- public void write(DataOutput dataOutput) throws IOException {
-
- }
-
- @Override
- public void readFields(DataInput dataInput) throws IOException {
-
- }
- }
-
-
- @Test
- public void testWritableTypeInfoEquality() {
- WritableTypeInfo<TestClass> tpeInfo1 = new WritableTypeInfo<>(TestClass.class);
- WritableTypeInfo<TestClass> tpeInfo2 = new WritableTypeInfo<>(TestClass.class);
-
- assertEquals(tpeInfo1, tpeInfo2);
- assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
- }
-
- @Test
- public void testWritableTypeInfoInequality() {
- WritableTypeInfo<TestClass> tpeInfo1 = new WritableTypeInfo<>(TestClass.class);
- WritableTypeInfo<AlternateClass> tpeInfo2 = new WritableTypeInfo<>(AlternateClass.class);
-
- assertNotEquals(tpeInfo1, tpeInfo2);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java
deleted file mode 100644
index 307a3d2..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java
+++ /dev/null
@@ -1,187 +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.java.typeutils.runtime;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Random;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.GenericArraySerializer;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.Book;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.BookAuthor;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject1;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject2;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.SimpleTypes;
-import org.apache.flink.util.StringUtils;
-
-public abstract class AbstractGenericArraySerializerTest {
-
- private final Random rnd = new Random(349712539451944123L);
-
-
- @Test
- public void testString() {
- String[] arr1 = new String[] {"abc", "",
- StringUtils.getRandomString(new Random(289347567856686223L), 10, 100),
- StringUtils.getRandomString(new Random(289347567856686223L), 15, 50),
- StringUtils.getRandomString(new Random(289347567856686223L), 30, 170),
- StringUtils.getRandomString(new Random(289347567856686223L), 14, 15),
- ""};
-
- String[] arr2 = new String[] {"foo", "",
- StringUtils.getRandomString(new Random(289347567856686223L), 10, 100),
- StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000),
- StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000),
- StringUtils.getRandomString(new Random(289347567856686223L), 100*1024, 105*1024),
- "bar"};
-
- // run tests with the string serializer as the component serializer
- runTests(String.class, new StringSerializer(), arr1, arr2);
-
- // run the tests with the generic serializer as the component serializer
- runTests(arr1, arr2);
- }
-
- @Test
- public void testSimpleTypesObjects() {
- SimpleTypes a = new SimpleTypes();
- SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
-
- runTests(new SimpleTypes[] {a, b, c}, new SimpleTypes[] {d, e, f, g});
- }
-
- @Test
- public void testCompositeObject() {
- ComplexNestedObject1 o1 = new ComplexNestedObject1(5626435);
- ComplexNestedObject1 o2 = new ComplexNestedObject1(76923);
- ComplexNestedObject1 o3 = new ComplexNestedObject1(-1100);
- ComplexNestedObject1 o4 = new ComplexNestedObject1(0);
- ComplexNestedObject1 o5 = new ComplexNestedObject1(44);
-
- runTests(new ComplexNestedObject1[] {o1, o2}, new ComplexNestedObject1[] {o3}, new ComplexNestedObject1[] {o4, o5});
- }
-
- @Test
- public void testNestedObjects() {
- ComplexNestedObject2 o1 = new ComplexNestedObject2(rnd);
- ComplexNestedObject2 o2 = new ComplexNestedObject2();
- ComplexNestedObject2 o3 = new ComplexNestedObject2(rnd);
- ComplexNestedObject2 o4 = new ComplexNestedObject2(rnd);
-
- runTests( new ComplexNestedObject2[] {o1, o2, o3},
- new ComplexNestedObject2[] {},
- new ComplexNestedObject2[] {},
- new ComplexNestedObject2[] {o4},
- new ComplexNestedObject2[] {});
- }
-
- @Test
- public void testBeanStyleObjects() {
- {
- Book b1 = new Book(976243875L, "The Serialization Odysse", 42);
- Book b2 = new Book(0L, "Debugging byte streams", 1337);
- Book b3 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
- Book b4 = new Book(Long.MAX_VALUE, "The joy of bits and bytes", 0xDEADBEEF);
- Book b5 = new Book(Long.MIN_VALUE, "Winnign a prize for creative test strings", 0xBADF00);
- Book b6 = new Book(-2L, "Distributed Systems", 0xABCDEF0123456789L);
-
- runTests( new Book[] {b1, b2},
- new Book[] {},
- new Book[] {},
- new Book[] {},
- new Book[] {},
- new Book[] {b3, b4, b5, b6});
- }
-
- // object with collection
- {
- ArrayList<String> list = new ArrayList<String>();
- list.add("A");
- list.add("B");
- list.add("C");
- list.add("D");
- list.add("E");
-
- BookAuthor b1 = new BookAuthor(976243875L, list, "Arno Nym");
-
- ArrayList<String> list2 = new ArrayList<String>();
- BookAuthor b2 = new BookAuthor(987654321L, list2, "The Saurus");
-
- runTests(new BookAuthor[] {b1, b2});
- }
- }
-
- @SafeVarargs
- private final <T> void runTests(T[]... instances) {
- try {
- @SuppressWarnings("unchecked")
- Class<T> type = (Class<T>) instances[0][0].getClass();
- TypeSerializer<T> serializer = createComponentSerializer(type);
- runTests(type, serializer, instances);
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
-
- @SafeVarargs
- private final <T> void runTests(Class<T> type, TypeSerializer<T> componentSerializer, T[]... instances) {
- try {
- if (type == null || componentSerializer == null || instances == null || instances.length == 0) {
- throw new IllegalArgumentException();
- }
-
- @SuppressWarnings("unchecked")
- Class<T[]> arrayClass = (Class<T[]>) (Class<?>) Array.newInstance(type, 0).getClass();
-
- GenericArraySerializer<T> serializer = createSerializer(type, componentSerializer);
- SerializerTestInstance<T[]> test = new SerializerTestInstance<T[]>(serializer, arrayClass, -1, instances);
- test.testAll();
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
-
- private <T> GenericArraySerializer<T> createSerializer(Class<T> type, TypeSerializer<T> componentSerializer) {
- return new GenericArraySerializer<T>(type, componentSerializer);
- }
-
- abstract protected <T> TypeSerializer<T> createComponentSerializer(Class<T> type);
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java
deleted file mode 100644
index ef168d8..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java
+++ /dev/null
@@ -1,376 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-abstract public class AbstractGenericTypeComparatorTest {
-
- @Test
- public void testString() {
- runTests(new String[]{
- "",
- "Lorem Ipsum Dolor Omit Longer",
- "aaaa",
- "abcd",
- "abce",
- "abdd",
- "accd",
- "bbcd"
- });
- }
-
- @Test
- public void testSimpleTypesObjects() {
- runTests(
- new SimpleTypes(0, 1, (byte) 2, "", (short) 3, 4.0),
- new SimpleTypes(1, 1, (byte) 2, "", (short) 3, 4.0),
- new SimpleTypes(1, 2, (byte) 2, "", (short) 3, 4.0),
- new SimpleTypes(1, 2, (byte) 3, "", (short) 3, 4.0),
- new SimpleTypes(1, 2, (byte) 3, "a", (short) 3, 4.0),
- new SimpleTypes(1, 2, (byte) 3, "b", (short) 3, 4.0),
- new SimpleTypes(1, 2, (byte) 3, "b", (short) 4, 4.0),
- new SimpleTypes(1, 2, (byte) 3, "b", (short) 4, 6.0)
- );
- }
-
- @Test
- public void testCompositeObject() {
- ComplexNestedObject1 o1 = new ComplexNestedObject1(-1100);
- ComplexNestedObject1 o2 = new ComplexNestedObject1(0);
- ComplexNestedObject1 o3 = new ComplexNestedObject1(44);
- ComplexNestedObject1 o4 = new ComplexNestedObject1(76923, "A");
- ComplexNestedObject1 o5 = new ComplexNestedObject1(5626435, "A somewhat random collection");
-
- runTests(o1, o2, o3, o4, o5);
- }
-
- @Test
- public void testBeanStyleObjects() {
- {
- Book b111 = new Book(-1L, "A Low level interfaces", 0xC);
- Book b122 = new Book(-1L, "Low level interfaces", 0xC);
- Book b123 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
-
- Book b2 = new Book(0L, "Debugging byte streams", 1337);
- Book b3 = new Book(976243875L, "The Serialization Odysse", 42);
-
- runTests(b111, b122, b123, b2, b3);
- }
-
- {
- BookAuthor b1 = new BookAuthor(976243875L, new ArrayList<String>(), "Arno Nym");
-
- ArrayList<String> list = new ArrayList<String>();
- list.add("A");
- list.add("B");
- list.add("C");
- list.add("D");
- list.add("E");
-
- BookAuthor b2 = new BookAuthor(976243875L, list, "The Saurus");
-
- runTests(b1, b2);
- }
- }
-
- // ------------------------------------------------------------------------
-
- private <T> void runTests(T... sortedTestData) {
- ComparatorTestInstance<T> testBase = new ComparatorTestInstance<T>(sortedTestData);
- testBase.testAll();
- }
-
- abstract protected <T> TypeSerializer<T> createSerializer(Class<T> type);
-
- // ------------------------------------------------------------------------
- // test instance
- // ------------------------------------------------------------------------
-
- private class ComparatorTestInstance<T> extends ComparatorTestBase<T> {
-
- private final T[] testData;
-
- private final Class<T> type;
-
- @SuppressWarnings("unchecked")
- public ComparatorTestInstance(T[] testData) {
- if (testData == null || testData.length == 0) {
- throw new IllegalArgumentException();
- }
-
- this.testData = testData;
- this.type = (Class<T>) testData[0].getClass();
- }
-
- @Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
- protected TypeComparator<T> createComparator(boolean ascending) {
- return new GenericTypeComparator(ascending, AbstractGenericTypeComparatorTest.this.createSerializer(this
- .type), this.type);
- }
-
- @Override
- protected TypeSerializer<T> createSerializer() {
- return AbstractGenericTypeComparatorTest.this.createSerializer(this.type);
- }
-
- @Override
- protected T[] getSortedTestData() {
- return this.testData;
- }
-
- public void testAll() {
- testDuplicate();
- testEquality();
- testEqualityWithReference();
- testInequality();
- testInequalityWithReference();
- testNormalizedKeysEqualsFullLength();
- testNormalizedKeysEqualsHalfLength();
- testNormalizedKeysGreatSmallFullLength();
- testNormalizedKeysGreatSmallAscDescHalfLength();
- testNormalizedKeyReadWriter();
- }
- }
-
- // ------------------------------------------------------------------------
- // test objects
- // ------------------------------------------------------------------------
-
- public static final class SimpleTypes implements Comparable<SimpleTypes> {
-
- private final int iVal;
- private final long lVal;
- private final byte bVal;
- private final String sVal;
- private final short rVal;
- private final double dVal;
-
- public SimpleTypes() {
- this(0, 0, (byte) 0, "", (short) 0, 0);
- }
-
- public SimpleTypes(int iVal, long lVal, byte bVal, String sVal, short rVal, double dVal) {
- this.iVal = iVal;
- this.lVal = lVal;
- this.bVal = bVal;
- this.sVal = sVal;
- this.rVal = rVal;
- this.dVal = dVal;
- }
-
- @Override
- public String toString() {
- return String.format("(%d, %d, %d, %s, %d, %f)", iVal, lVal, bVal, sVal, rVal, dVal);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == SimpleTypes.class) {
- SimpleTypes other = (SimpleTypes) obj;
-
- return other.iVal == this.iVal &&
- other.lVal == this.lVal &&
- other.bVal == this.bVal &&
- other.sVal.equals(this.sVal) &&
- other.rVal == this.rVal &&
- other.dVal == this.dVal;
- } else {
- return false;
- }
- }
-
- @Override
- public int compareTo(SimpleTypes o) {
- int cmp = (this.iVal < o.iVal ? -1 : (this.iVal == o.iVal ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- cmp = (this.lVal < o.lVal ? -1 : (this.lVal == o.lVal ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- cmp = (this.bVal < o.bVal ? -1 : (this.bVal == o.bVal ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- cmp = this.sVal.compareTo(o.sVal);
- if (cmp != 0) {
- return cmp;
- }
-
- cmp = (this.rVal < o.rVal ? -1 : (this.rVal == o.rVal ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- return (this.dVal < o.dVal ? -1 : (this.dVal == o.dVal ? 0 : 1));
- }
- }
-
- public static class ComplexNestedObject1 implements Comparable<ComplexNestedObject1> {
-
- private double doubleValue;
-
- private List<String> stringList;
-
- public ComplexNestedObject1() {
- }
-
- public ComplexNestedObject1(double value, String... listElements) {
- this.doubleValue = value;
-
- this.stringList = new ArrayList<String>();
- for (String str : listElements) {
- this.stringList.add(str);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == ComplexNestedObject1.class) {
- ComplexNestedObject1 other = (ComplexNestedObject1) obj;
- return other.doubleValue == this.doubleValue && this.stringList.equals(other.stringList);
- } else {
- return false;
- }
- }
-
- @Override
- public int compareTo(ComplexNestedObject1 o) {
- int cmp = (this.doubleValue < o.doubleValue ? -1 : (this.doubleValue == o.doubleValue ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- int size = this.stringList.size();
- int otherSize = o.stringList.size();
-
- cmp = (size < otherSize ? -1 : (size == otherSize ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- for (int i = 0; i < size; i++) {
- cmp = this.stringList.get(i).compareTo(o.stringList.get(i));
- if (cmp != 0) {
- return cmp;
- }
- }
-
- return 0;
- }
- }
-
- public static class Book implements Comparable<Book> {
-
- private long bookId;
- private String title;
- private long authorId;
-
- public Book() {
- }
-
- public Book(long bookId, String title, long authorId) {
- this.bookId = bookId;
- this.title = title;
- this.authorId = authorId;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == Book.class) {
- Book other = (Book) obj;
- return other.bookId == this.bookId && other.authorId == this.authorId && this.title.equals(other.title);
- } else {
- return false;
- }
- }
-
- @Override
- public int compareTo(Book o) {
- int cmp = (this.bookId < o.bookId ? -1 : (this.bookId == o.bookId ? 0 : 1));
- if (cmp != 0) {
- return cmp;
- }
-
- cmp = title.compareTo(o.title);
- if (cmp != 0) {
- return cmp;
- }
-
- return (this.authorId < o.authorId ? -1 : (this.authorId == o.authorId ? 0 : 1));
- }
- }
-
- public static class BookAuthor implements Comparable<BookAuthor> {
-
- private long authorId;
- private List<String> bookTitles;
- private String authorName;
-
- public BookAuthor() {
- }
-
- public BookAuthor(long authorId, List<String> bookTitles, String authorName) {
- this.authorId = authorId;
- this.bookTitles = bookTitles;
- this.authorName = authorName;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == BookAuthor.class) {
- BookAuthor other = (BookAuthor) obj;
- return other.authorName.equals(this.authorName) && other.authorId == this.authorId &&
- other.bookTitles.equals(this.bookTitles);
- } else {
- return false;
- }
- }
-
- @Override
- public int compareTo(BookAuthor o) {
- int cmp = (this.authorId < o.authorId ? -1 : (this.authorId == o.authorId ? 0 : 1));
- if (cmp != 0) return cmp;
-
- int size = this.bookTitles.size();
- int oSize = o.bookTitles.size();
- cmp = (size < oSize ? -1 : (size == oSize ? 0 : 1));
- if (cmp != 0) return cmp;
-
- for (int i = 0; i < size; i++) {
- cmp = this.bookTitles.get(i).compareTo(o.bookTitles.get(i));
- if (cmp != 0) return cmp;
- }
-
- return this.authorName.compareTo(o.authorName);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java
deleted file mode 100644
index 059c78d..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java
+++ /dev/null
@@ -1,364 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.util.StringUtils;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-/**
- * A test for the {@link AvroSerializer}.
- */
-abstract public class AbstractGenericTypeSerializerTest {
-
- private final Random rnd = new Random(349712539451944123L);
-
- @Test
- public void testString() {
- runTests("abc", "",
- StringUtils.getRandomString(new Random(289347567856686223L), 10, 100),
- StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000),
- StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000),
- StringUtils.getRandomString(new Random(289347567856686223L), 100 * 1024, 105 * 1024));
- }
-
- @Test
- public void testSimpleTypesObjects() {
- SimpleTypes a = new SimpleTypes();
- SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
-
- runTests(a, b, c, d, e, f, g);
- }
-
- @Test
- public void testCompositeObject() {
- ComplexNestedObject1 o1 = new ComplexNestedObject1(5626435);
- ComplexNestedObject1 o2 = new ComplexNestedObject1(76923);
- ComplexNestedObject1 o3 = new ComplexNestedObject1(-1100);
- ComplexNestedObject1 o4 = new ComplexNestedObject1(0);
- ComplexNestedObject1 o5 = new ComplexNestedObject1(44);
-
- runTests(o1, o2, o3, o4, o5);
- }
-
- @Test
- public void testNestedObjects() {
- ComplexNestedObject2 o1 = new ComplexNestedObject2(rnd);
- ComplexNestedObject2 o2 = new ComplexNestedObject2();
- ComplexNestedObject2 o3 = new ComplexNestedObject2(rnd);
- ComplexNestedObject2 o4 = new ComplexNestedObject2(rnd);
-
- runTests(o1, o2, o3, o4);
- }
-
- @Test
- public void testBeanStyleObjects() {
- {
- Book b1 = new Book(976243875L, "The Serialization Odysse", 42);
- Book b2 = new Book(0L, "Debugging byte streams", 1337);
- Book b3 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
-
- runTests(b1, b2, b3);
- }
-
- // object with collection
- {
- ArrayList<String> list = new ArrayList<String>();
- list.add("A");
- list.add("B");
- list.add("C");
- list.add("D");
- list.add("E");
-
- BookAuthor b1 = new BookAuthor(976243875L, list, "Arno Nym");
-
- ArrayList<String> list2 = new ArrayList<String>();
- BookAuthor b2 = new BookAuthor(987654321L, list2, "The Saurus");
-
- runTests(b1, b2);
- }
- }
-
- @Test
- public void testNestedInterfaces() {
- {
-
- SimpleWithNestedInterfaces s1 = new SimpleWithNestedInterfaces("Hello", 1);
- SimpleWithNestedInterfaces s2 = new SimpleWithNestedInterfaces("Ciao", 2);
- SimpleWithNestedInterfaces s3 = new SimpleWithNestedInterfaces("Foo", 3);
-
- runTests(s1, s2, s3);
- }
-
- // object with collection
- {
- ArrayList<String> list = new ArrayList<String>();
- list.add("A");
- list.add("B");
- list.add("C");
- list.add("D");
- list.add("E");
-
- BookAuthor b1 = new BookAuthor(976243875L, list, "Arno Nym");
-
- ArrayList<String> list2 = new ArrayList<String>();
- BookAuthor b2 = new BookAuthor(987654321L, list2, "The Saurus");
-
- runTests(b1, b2);
- }
- }
-
- protected final <T> void runTests(T... instances) {
- if (instances == null || instances.length == 0) {
- throw new IllegalArgumentException();
- }
-
- @SuppressWarnings("unchecked")
- Class<T> clazz = (Class<T>) instances[0].getClass();
-
- TypeSerializer<T> serializer = createSerializer(clazz);
- SerializerTestInstance<T> test = new SerializerTestInstance<T>(serializer, clazz, -1, instances);
- test.testAll();
- }
-
- abstract protected <T> TypeSerializer<T> createSerializer(Class<T> type);
-
-
- // --------------------------------------------------------------------------------------------
- // Test Objects
- // --------------------------------------------------------------------------------------------
-
- public static final class SimpleWithNestedInterfaces {
- Map<String, Integer> map1;
- List<String> list;
-
- public SimpleWithNestedInterfaces() {
- map1 = new HashMap<String, Integer>();
- list = new ArrayList<String>();
- }
-
-
- public SimpleWithNestedInterfaces(String str, Integer i) {
- map1 = new HashMap<String, Integer>();
- map1.put(str, i);
- list = new ArrayList<String>();
- list.add(str);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) { return true; }
- if (o == null || getClass() != o.getClass()) { return false; }
-
- SimpleWithNestedInterfaces that = (SimpleWithNestedInterfaces) o;
-
- if (!list.equals(that.list)) { return false; }
- if (!map1.equals(that.map1)) { return false; }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = map1.hashCode();
- result = 31 * result + list.hashCode();
- return result;
- }
- }
-
- public static final class SimpleTypes {
-
- private final int iVal;
- private final long lVal;
- private final byte bVal;
- private final String sVal;
- private final short rVal;
- private final double dVal;
-
-
- public SimpleTypes() {
- this(0, 0, (byte) 0, "", (short) 0, 0);
- }
-
- public SimpleTypes(int iVal, long lVal, byte bVal, String sVal, short rVal, double dVal) {
- this.iVal = iVal;
- this.lVal = lVal;
- this.bVal = bVal;
- this.sVal = sVal;
- this.rVal = rVal;
- this.dVal = dVal;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == SimpleTypes.class) {
- SimpleTypes other = (SimpleTypes) obj;
-
- return other.iVal == this.iVal &&
- other.lVal == this.lVal &&
- other.bVal == this.bVal &&
- other.sVal.equals(this.sVal) &&
- other.rVal == this.rVal &&
- other.dVal == this.dVal;
-
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return String.format("(%d, %d, %d, %s, %d, %f)", iVal, lVal, bVal, sVal, rVal, dVal);
- }
- }
-
- public static class ComplexNestedObject1 {
-
- private double doubleValue;
-
- private List<String> stringList;
-
- public ComplexNestedObject1() {
- }
-
- public ComplexNestedObject1(int offInit) {
- this.doubleValue = 6293485.6723 + offInit;
-
- this.stringList = new ArrayList<String>();
- this.stringList.add("A" + offInit);
- this.stringList.add("somewhat" + offInit);
- this.stringList.add("random" + offInit);
- this.stringList.add("collection" + offInit);
- this.stringList.add("of" + offInit);
- this.stringList.add("strings" + offInit);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == ComplexNestedObject1.class) {
- ComplexNestedObject1 other = (ComplexNestedObject1) obj;
- return other.doubleValue == this.doubleValue && this.stringList.equals(other.stringList);
- } else {
- return false;
- }
- }
- }
-
- public static class ComplexNestedObject2 {
-
- private long longValue;
-
- private Map<String, ComplexNestedObject1> theMap = new HashMap<String, ComplexNestedObject1>();
-
- public ComplexNestedObject2() {
- }
-
- public ComplexNestedObject2(Random rnd) {
- this.longValue = rnd.nextLong();
-
- this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
- this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
- this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
- this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
- this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
- this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == ComplexNestedObject2.class) {
- ComplexNestedObject2 other = (ComplexNestedObject2) obj;
- return other.longValue == this.longValue && this.theMap.equals(other.theMap);
- } else {
- return false;
- }
- }
- }
-
- public static class Book {
-
- private long bookId;
- private String title;
- private long authorId;
-
- public Book() {
- }
-
- public Book(long bookId, String title, long authorId) {
- this.bookId = bookId;
- this.title = title;
- this.authorId = authorId;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == Book.class) {
- Book other = (Book) obj;
- return other.bookId == this.bookId && other.authorId == this.authorId && this.title.equals(other.title);
- } else {
- return false;
- }
- }
- }
-
- public static class BookAuthor {
-
- private long authorId;
- private List<String> bookTitles;
- private String authorName;
-
- public BookAuthor() {
- }
-
- public BookAuthor(long authorId, List<String> bookTitles, String authorName) {
- this.authorId = authorId;
- this.bookTitles = bookTitles;
- this.authorName = authorName;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj.getClass() == BookAuthor.class) {
- BookAuthor other = (BookAuthor) obj;
- return other.authorName.equals(this.authorName) && other.authorId == this.authorId &&
- other.bookTitles.equals(this.bookTitles);
- } else {
- return false;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java
deleted file mode 100644
index 5b08e52..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java
+++ /dev/null
@@ -1,28 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-public class AvroGenericArraySerializerTest extends AbstractGenericArraySerializerTest {
- @Override
- protected <T> TypeSerializer<T> createComponentSerializer(Class<T> type) {
- return new AvroSerializer<T>(type);
- }
-}
[14/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java
new file mode 100644
index 0000000..8c61a19
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java
@@ -0,0 +1,196 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import com.google.common.base.Objects;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.SerializerTestBase;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.junit.Test;
+
+import java.util.Random;
+
+/**
+ * A test for the {@link PojoSerializer}.
+ */
+public class PojoSubclassSerializerTest extends SerializerTestBase<PojoSubclassSerializerTest.TestUserClassBase> {
+ private TypeInformation<TestUserClassBase> type = TypeExtractor.getForClass(TestUserClassBase.class);
+
+ @Override
+ protected TypeSerializer<TestUserClassBase> createSerializer() {
+ // only register one of the three child classes, the third child class is NO POJO
+ ExecutionConfig conf = new ExecutionConfig();
+ conf.registerPojoType(TestUserClass1.class);
+ TypeSerializer<TestUserClassBase> serializer = type.createSerializer(conf);
+ assert(serializer instanceof PojoSerializer);
+ return serializer;
+ }
+
+ @Override
+ protected int getLength() {
+ return -1;
+ }
+
+ @Override
+ protected Class<TestUserClassBase> getTypeClass() {
+ return TestUserClassBase.class;
+ }
+
+ @Override
+ protected TestUserClassBase[] getTestData() {
+ Random rnd = new Random(874597969123412341L);
+
+ return new TestUserClassBase[]{
+ new TestUserClass1(rnd.nextInt(), "foo", rnd.nextLong()),
+ new TestUserClass2(rnd.nextInt(), "bar", rnd.nextFloat()),
+ new TestUserClass3(rnd.nextInt(), "bar", rnd.nextFloat())
+ };
+
+ }
+
+ @Override
+ @Test
+ public void testInstantiate() {
+ // don't do anything, since the PojoSerializer with subclass will return null
+ }
+
+ // User code class for testing the serializer
+ public static abstract class TestUserClassBase {
+ public int dumm1;
+ public String dumm2;
+
+
+ public TestUserClassBase() {
+ }
+
+ public TestUserClassBase(int dumm1, String dumm2) {
+ this.dumm1 = dumm1;
+ this.dumm2 = dumm2;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(dumm1, dumm2);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClassBase)) {
+ return false;
+ }
+ TestUserClassBase otherTUC = (TestUserClassBase) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public static class TestUserClass1 extends TestUserClassBase {
+ public long dumm3;
+
+ public TestUserClass1() {
+ }
+
+ public TestUserClass1(int dumm1, String dumm2, long dumm3) {
+ super(dumm1, dumm2);
+ this.dumm3 = dumm3;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClass1)) {
+ return false;
+ }
+ TestUserClass1 otherTUC = (TestUserClass1) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ if (dumm3 != otherTUC.dumm3) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public static class TestUserClass2 extends TestUserClassBase {
+ public float dumm4;
+
+ public TestUserClass2() {
+ }
+
+ public TestUserClass2(int dumm1, String dumm2, float dumm4) {
+ super(dumm1, dumm2);
+ this.dumm4 = dumm4;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClass2)) {
+ return false;
+ }
+ TestUserClass2 otherTUC = (TestUserClass2) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ if (dumm4 != otherTUC.dumm4) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public static class TestUserClass3 extends TestUserClassBase {
+ public float dumm4;
+
+ public TestUserClass3(int dumm1, String dumm2, float dumm4) {
+ super(dumm1, dumm2);
+ this.dumm4 = dumm4;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClass3)) {
+ return false;
+ }
+ TestUserClass3 otherTUC = (TestUserClass3) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ if (dumm4 != otherTUC.dumm4) {
+ return false;
+ }
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java
new file mode 100644
index 0000000..7c608f2
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java
@@ -0,0 +1,83 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.Writable;
+
+public class StringArrayWritable implements Writable, Comparable<StringArrayWritable> {
+
+ private String[] array = new String[0];
+
+ public StringArrayWritable() {
+ super();
+ }
+
+ public StringArrayWritable(String[] array) {
+ this.array = array;
+ }
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+ out.writeInt(this.array.length);
+
+ for(String str : this.array) {
+ byte[] b = str.getBytes();
+ out.writeInt(b.length);
+ out.write(b);
+ }
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+ this.array = new String[in.readInt()];
+
+ for(int i = 0; i < this.array.length; i++) {
+ byte[] b = new byte[in.readInt()];
+ in.readFully(b);
+ this.array[i] = new String(b);
+ }
+ }
+
+ @Override
+ public int compareTo(StringArrayWritable o) {
+ if(this.array.length != o.array.length) {
+ return this.array.length - o.array.length;
+ }
+
+ for(int i = 0; i < this.array.length; i++) {
+ int comp = this.array[i].compareTo(o.array[i]);
+ if(comp != 0) {
+ return comp;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(!(obj instanceof StringArrayWritable)) {
+ return false;
+ }
+ return this.compareTo((StringArrayWritable) obj) == 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java
new file mode 100644
index 0000000..b797090
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import com.google.common.base.Objects;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.SerializerTestBase;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
+import org.junit.Test;
+
+import java.util.Random;
+
+/**
+ * Testing the serialization of classes which are subclasses of a class that implements an interface.
+ */
+public class SubclassFromInterfaceSerializerTest extends SerializerTestBase<SubclassFromInterfaceSerializerTest.TestUserInterface> {
+ private TypeInformation<TestUserInterface> type = TypeExtractor.getForClass(TestUserInterface.class);
+
+ @Override
+ protected TypeSerializer<TestUserInterface> createSerializer() {
+ // only register one of the two child classes
+ ExecutionConfig conf = new ExecutionConfig();
+ conf.registerPojoType(TestUserClass2.class);
+ TypeSerializer<TestUserInterface> serializer = type.createSerializer(conf);
+ assert(serializer instanceof KryoSerializer);
+ return serializer;
+ }
+
+ @Override
+ protected int getLength() {
+ return -1;
+ }
+
+ @Override
+ protected Class<TestUserInterface> getTypeClass() {
+ return TestUserInterface.class;
+ }
+
+ @Override
+ protected TestUserInterface[] getTestData() {
+ Random rnd = new Random(874597969123412341L);
+
+ return new TestUserInterface[]{
+ new TestUserClass1(rnd.nextInt(), "foo", rnd.nextLong()),
+ new TestUserClass2(rnd.nextInt(), "bar", rnd.nextFloat())
+ };
+
+ }
+
+ @Override
+ @Test
+ public void testInstantiate() {
+ // don't do anything, since the PojoSerializer with subclass will return null
+ }
+
+ public interface TestUserInterface {}
+
+ // User code class for testing the serializer
+ public static class TestUserClassBase implements TestUserInterface {
+ public int dumm1;
+ public String dumm2;
+
+
+ public TestUserClassBase() {
+ }
+
+ public TestUserClassBase(int dumm1, String dumm2) {
+ this.dumm1 = dumm1;
+ this.dumm2 = dumm2;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(dumm1, dumm2);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClassBase)) {
+ return false;
+ }
+ TestUserClassBase otherTUC = (TestUserClassBase) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public static class TestUserClass1 extends TestUserClassBase {
+ public long dumm3;
+
+ public TestUserClass1() {
+ }
+
+ public TestUserClass1(int dumm1, String dumm2, long dumm3) {
+ super(dumm1, dumm2);
+ this.dumm3 = dumm3;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClass1)) {
+ return false;
+ }
+ TestUserClass1 otherTUC = (TestUserClass1) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ if (dumm3 != otherTUC.dumm3) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public static class TestUserClass2 extends TestUserClassBase {
+ public float dumm4;
+
+ public TestUserClass2() {
+ }
+
+ public TestUserClass2(int dumm1, String dumm2, float dumm4) {
+ super(dumm1, dumm2);
+ this.dumm4 = dumm4;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClass2)) {
+ return false;
+ }
+ TestUserClass2 otherTUC = (TestUserClass2) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ if (dumm4 != otherTUC.dumm4) {
+ return false;
+ }
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java
new file mode 100644
index 0000000..87be6db
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java
@@ -0,0 +1,308 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.UTFDataFormatException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.MemoryUtils;
+
+public final class TestDataOutputSerializer implements DataOutputView {
+
+ private byte[] buffer;
+
+ private int position;
+
+ private ByteBuffer wrapper;
+
+ private final int maxSize;
+
+
+ public TestDataOutputSerializer(int startSize) {
+ this(startSize, Integer.MAX_VALUE);
+ }
+
+ public TestDataOutputSerializer(int startSize, int maxSize) {
+ if (startSize < 1 || startSize > maxSize) {
+ throw new IllegalArgumentException();
+ }
+
+ this.buffer = new byte[startSize];
+ this.wrapper = ByteBuffer.wrap(buffer);
+ this.maxSize = maxSize;
+ }
+
+ public ByteBuffer wrapAsByteBuffer() {
+ this.wrapper.position(0);
+ this.wrapper.limit(this.position);
+ return this.wrapper;
+ }
+
+ public byte[] copyByteBuffer() {
+ byte[] target = new byte[position];
+ System.arraycopy(buffer, 0, target, 0, position);
+
+ return target;
+ }
+
+ public void clear() {
+ this.position = 0;
+ }
+
+ public int length() {
+ return this.position;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[pos=%d cap=%d]", this.position, this.buffer.length);
+ }
+
+ // ----------------------------------------------------------------------------------------
+ // Data Output
+ // ----------------------------------------------------------------------------------------
+
+ @Override
+ public void write(int b) throws IOException {
+ if (this.position >= this.buffer.length) {
+ resize(1);
+ }
+ this.buffer[this.position++] = (byte) (b & 0xff);
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ write(b, 0, b.length);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (len < 0 || off > b.length - len) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ if (this.position > this.buffer.length - len) {
+ resize(len);
+ }
+ System.arraycopy(b, off, this.buffer, this.position, len);
+ this.position += len;
+ }
+
+ @Override
+ public void writeBoolean(boolean v) throws IOException {
+ write(v ? 1 : 0);
+ }
+
+ @Override
+ public void writeByte(int v) throws IOException {
+ write(v);
+ }
+
+ @Override
+ public void writeBytes(String s) throws IOException {
+ final int sLen = s.length();
+ if (this.position >= this.buffer.length - sLen) {
+ resize(sLen);
+ }
+
+ for (int i = 0; i < sLen; i++) {
+ writeByte(s.charAt(i));
+ }
+ this.position += sLen;
+ }
+
+ @Override
+ public void writeChar(int v) throws IOException {
+ if (this.position >= this.buffer.length - 1) {
+ resize(2);
+ }
+ this.buffer[this.position++] = (byte) (v >> 8);
+ this.buffer[this.position++] = (byte) v;
+ }
+
+ @Override
+ public void writeChars(String s) throws IOException {
+ final int sLen = s.length();
+ if (this.position >= this.buffer.length - 2*sLen) {
+ resize(2*sLen);
+ }
+ for (int i = 0; i < sLen; i++) {
+ writeChar(s.charAt(i));
+ }
+ }
+
+ @Override
+ public void writeDouble(double v) throws IOException {
+ writeLong(Double.doubleToLongBits(v));
+ }
+
+ @Override
+ public void writeFloat(float v) throws IOException {
+ writeInt(Float.floatToIntBits(v));
+ }
+
+ @SuppressWarnings("restriction")
+ @Override
+ public void writeInt(int v) throws IOException {
+ if (this.position >= this.buffer.length - 3) {
+ resize(4);
+ }
+ if (LITTLE_ENDIAN) {
+ v = Integer.reverseBytes(v);
+ }
+ UNSAFE.putInt(this.buffer, BASE_OFFSET + this.position, v);
+ this.position += 4;
+ }
+
+ @SuppressWarnings("restriction")
+ @Override
+ public void writeLong(long v) throws IOException {
+ if (this.position >= this.buffer.length - 7) {
+ resize(8);
+ }
+ if (LITTLE_ENDIAN) {
+ v = Long.reverseBytes(v);
+ }
+ UNSAFE.putLong(this.buffer, BASE_OFFSET + this.position, v);
+ this.position += 8;
+ }
+
+ @Override
+ public void writeShort(int v) throws IOException {
+ if (this.position >= this.buffer.length - 1) {
+ resize(2);
+ }
+ this.buffer[this.position++] = (byte) ((v >>> 8) & 0xff);
+ this.buffer[this.position++] = (byte) ((v >>> 0) & 0xff);
+ }
+
+ @Override
+ public void writeUTF(String str) throws IOException {
+ int strlen = str.length();
+ int utflen = 0;
+ int c;
+
+ /* use charAt instead of copying String to char array */
+ for (int i = 0; i < strlen; i++) {
+ c = str.charAt(i);
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ utflen++;
+ } else if (c > 0x07FF) {
+ utflen += 3;
+ } else {
+ utflen += 2;
+ }
+ }
+
+ if (utflen > 65535) {
+ throw new UTFDataFormatException("Encoded string is too long: " + utflen);
+ }
+ else if (this.position > this.buffer.length - utflen - 2) {
+ resize(utflen + 2);
+ }
+
+ byte[] bytearr = this.buffer;
+ int count = this.position;
+
+ bytearr[count++] = (byte) ((utflen >>> 8) & 0xFF);
+ bytearr[count++] = (byte) ((utflen >>> 0) & 0xFF);
+
+ int i = 0;
+ for (i = 0; i < strlen; i++) {
+ c = str.charAt(i);
+ if (!((c >= 0x0001) && (c <= 0x007F))) {
+ break;
+ }
+ bytearr[count++] = (byte) c;
+ }
+
+ for (; i < strlen; i++) {
+ c = str.charAt(i);
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ bytearr[count++] = (byte) c;
+
+ } else if (c > 0x07FF) {
+ bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ } else {
+ bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+ bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ }
+ }
+
+ this.position = count;
+ }
+
+
+ private void resize(int minCapacityAdd) throws IOException {
+ try {
+ int newLen = Math.max(this.buffer.length * 2, this.buffer.length + minCapacityAdd);
+
+ if (newLen > maxSize) {
+
+ if (this.buffer.length + minCapacityAdd > maxSize) {
+ throw new EOFException("Exceeded maximum capacity");
+ }
+
+ newLen = maxSize;
+ }
+
+ final byte[] nb = new byte[newLen];
+ System.arraycopy(this.buffer, 0, nb, 0, this.position);
+ this.buffer = nb;
+ this.wrapper = ByteBuffer.wrap(this.buffer);
+ }
+ catch (NegativeArraySizeException nasex) {
+ throw new IOException("Serialization failed because the record length would exceed 2GB (max addressable array size in Java).");
+ }
+ }
+
+ @SuppressWarnings("restriction")
+ private static final sun.misc.Unsafe UNSAFE = MemoryUtils.UNSAFE;
+
+ @SuppressWarnings("restriction")
+ private static final long BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
+
+ private static final boolean LITTLE_ENDIAN = (MemoryUtils.NATIVE_BYTE_ORDER == ByteOrder.LITTLE_ENDIAN);
+
+ @Override
+ public void skipBytesToWrite(int numBytes) throws IOException {
+ if(buffer.length - this.position < numBytes){
+ throw new EOFException("Could not skip " + numBytes + " bytes.");
+ }
+
+ this.position += numBytes;
+ }
+
+ @Override
+ public void write(DataInputView source, int numBytes) throws IOException {
+ if(buffer.length - this.position < numBytes){
+ throw new EOFException("Could not write " + numBytes + " bytes. Buffer overflow.");
+ }
+
+ source.read(this.buffer, this.position, numBytes);
+ this.position += numBytes;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java
new file mode 100644
index 0000000..cfc4914
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java
@@ -0,0 +1,73 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorILD2Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, Long, Double>(4, 14L, 20.0),
+ new Tuple3<Integer, Long, Double>(4, 15L, 23.2),
+ new Tuple3<Integer, Long, Double>(5, 15L, 20.0),
+ new Tuple3<Integer, Long, Double>(5, 20L, 20.0),
+ new Tuple3<Integer, Long, Double>(6, 20L, 23.2),
+ new Tuple3<Integer, Long, Double>(6, 29L, 20.0),
+ new Tuple3<Integer, Long, Double>(7, 29L, 20.0),
+ new Tuple3<Integer, Long, Double>(7, 34L, 23.2)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, Long, Double>>(
+ new int[]{0, 1},
+ new TypeComparator[]{
+ new IntComparator(ascending),
+ new LongComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, Long, Double>>(
+ (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new LongSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java
new file mode 100644
index 0000000..e5a0e6c
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java
@@ -0,0 +1,75 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorILD3Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 20.0),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 23.2),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(9), 20.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(4), 20.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(4), 23.2),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(9), 20.0),
+ new Tuple3<Integer, Long, Double>(6, Long.valueOf(4), 20.0),
+ new Tuple3<Integer, Long, Double>(6, Long.valueOf(4), 23.2)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, Long, Double>>(
+ new int[]{0, 1, 2},
+ new TypeComparator[]{
+ new IntComparator(ascending),
+ new LongComparator(ascending),
+ new DoubleComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, Long, Double>>(
+ (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new LongSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java
new file mode 100644
index 0000000..a1e6c40
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java
@@ -0,0 +1,75 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorILDC3Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 20.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(1), 20.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(2), 20.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(10), 23.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(19), 24.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(20), 24.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(24), 25.0),
+ new Tuple3<Integer, Long, Double>(5, Long.valueOf(25), 25.0)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, Long, Double>>(
+ new int[]{2, 0, 1},
+ new TypeComparator[]{
+ new DoubleComparator(ascending),
+ new IntComparator(ascending),
+ new LongComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, Long, Double>>(
+ (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new LongSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java
new file mode 100644
index 0000000..b5c0c1f
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java
@@ -0,0 +1,71 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorILDX1Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 20.0),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(5), 23.2),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(9), 20.0),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(10), 24.0),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(19), 23.2),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(20), 24.0),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(24), 20.0),
+ new Tuple3<Integer, Long, Double>(4, Long.valueOf(25), 23.2)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, Long, Double>>(
+ new int[]{1},
+ new TypeComparator[]{
+ new LongComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, Long, Double>>(
+ (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new LongSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java
new file mode 100644
index 0000000..793a2f4
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java
@@ -0,0 +1,73 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorILDXC2Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, Long, Double>(4, 4L, 20.0),
+ new Tuple3<Integer, Long, Double>(4, 5L, 20.0),
+ new Tuple3<Integer, Long, Double>(4, 3L, 23.0),
+ new Tuple3<Integer, Long, Double>(4, 19L, 23.0),
+ new Tuple3<Integer, Long, Double>(4, 17L, 24.0),
+ new Tuple3<Integer, Long, Double>(4, 18L, 24.0),
+ new Tuple3<Integer, Long, Double>(4, 24L, 25.0),
+ new Tuple3<Integer, Long, Double>(4, 25L, 25.0)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, Long, Double>>(
+ new int[]{2, 1},
+ new TypeComparator[]{
+ new DoubleComparator(ascending),
+ new LongComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, DoubleSerializer.INSTANCE, LongSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, Long, Double>>(
+ (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new LongSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java
new file mode 100644
index 0000000..8cdee9b
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java
@@ -0,0 +1,69 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorISD1Test extends TupleComparatorTestBase<Tuple3<Integer, String, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, String, Double>(4, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(5, "hello", 23.2),
+ new Tuple3<Integer, String, Double>(6, "world", 20.0),
+ new Tuple3<Integer, String, Double>(7, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(8, "hello", 23.2),
+ new Tuple3<Integer, String, Double>(9, "world", 20.0),
+ new Tuple3<Integer, String, Double>(10, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(11, "hello", 23.2)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, String, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, String, Double>>(
+ new int[]{0},
+ new TypeComparator[]{ new IntComparator(ascending) },
+ new TypeSerializer[]{ IntSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, String, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, String, Double>>(
+ (Class<Tuple3<Integer, String, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new StringSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, String, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java
new file mode 100644
index 0000000..06c292f
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java
@@ -0,0 +1,73 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.StringComparator;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorISD2Test extends TupleComparatorTestBase<Tuple3<Integer, String, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, String, Double>(4, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(4, "world", 23.2),
+ new Tuple3<Integer, String, Double>(5, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(5, "world", 20.0),
+ new Tuple3<Integer, String, Double>(6, "hello", 23.2),
+ new Tuple3<Integer, String, Double>(6, "world", 20.0),
+ new Tuple3<Integer, String, Double>(7, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(7, "world", 23.2)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, String, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, String, Double>>(
+ new int[]{0, 1},
+ new TypeComparator[]{
+ new IntComparator(ascending),
+ new StringComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, StringSerializer.INSTANCE, DoubleSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, String, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, String, Double>>(
+ (Class<Tuple3<Integer, String, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new StringSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, String, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java
new file mode 100644
index 0000000..d823a29
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java
@@ -0,0 +1,75 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.StringComparator;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.tuple.Tuple3;
+
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorISD3Test extends TupleComparatorTestBase<Tuple3<Integer, String, Double>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, String, Double>(4, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(4, "hello", 23.2),
+ new Tuple3<Integer, String, Double>(4, "world", 20.0),
+ new Tuple3<Integer, String, Double>(5, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(5, "hello", 23.2),
+ new Tuple3<Integer, String, Double>(5, "world", 20.0),
+ new Tuple3<Integer, String, Double>(6, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(6, "hello", 23.2)
+ };
+
+ @Override
+ protected TupleComparator<Tuple3<Integer, String, Double>> createComparator(boolean ascending) {
+ return new TupleComparator<Tuple3<Integer, String, Double>>(
+ new int[]{0, 1, 2},
+ new TypeComparator[]{
+ new IntComparator(ascending),
+ new StringComparator(ascending),
+ new DoubleComparator(ascending)
+ },
+ new TypeSerializer[]{ IntSerializer.INSTANCE, StringSerializer.INSTANCE, DoubleSerializer.INSTANCE });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Integer, String, Double>> createSerializer() {
+ return new TupleSerializer<Tuple3<Integer, String, Double>>(
+ (Class<Tuple3<Integer, String, Double>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new IntSerializer(),
+ new StringSerializer(),
+ new DoubleSerializer()});
+ }
+
+ @Override
+ protected Tuple3<Integer, String, Double>[] getSortedTestData() {
+ return dataISD;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java
new file mode 100644
index 0000000..cf73be2
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java
@@ -0,0 +1,139 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.junit.Assert.assertEquals;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.common.typeutils.base.StringComparator;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorTTT1Test extends TupleComparatorTestBase<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] dataISD = new Tuple3[]{
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 1.0), new Tuple2<Long, Long>(1L, 1L), new Tuple2<Integer, Long>(4, -10L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 2.0), new Tuple2<Long, Long>(1L, 2L), new Tuple2<Integer, Long>(4, -5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.0), new Tuple2<Long, Long>(1L, 3L), new Tuple2<Integer, Long>(4, 0L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.5), new Tuple2<Long, Long>(1L, 4L), new Tuple2<Integer, Long>(4, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 4325.12), new Tuple2<Long, Long>(1L, 5L), new Tuple2<Integer, Long>(4, 15L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 1.0), new Tuple2<Long, Long>(2L, 4L), new Tuple2<Integer, Long>(45, -5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 2.0), new Tuple2<Long, Long>(2L, 6L), new Tuple2<Integer, Long>(45, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.0), new Tuple2<Long, Long>(2L, 8L), new Tuple2<Integer, Long>(323, 2L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.5), new Tuple2<Long, Long>(2L, 9L), new Tuple2<Integer, Long>(323, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 4325.12), new Tuple2<Long, Long>(2L, 123L), new Tuple2<Integer, Long>(555, 1L))
+
+ };
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator(
+ boolean ascending) {
+ return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
+ new int[] { 0 },
+ new TypeComparator[] {
+ new TupleComparator<Tuple2<String, Double>>(
+ new int[] { 0, 1 },
+ new TypeComparator[] {
+ new StringComparator(ascending),
+ new DoubleComparator(ascending) },
+ new TypeSerializer[] {
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE }) },
+ new TypeSerializer[] {
+ new TupleSerializer<Tuple2<String, Double>>(
+ (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE }),
+ new TupleSerializer<Tuple2<Long, Long>>(
+ (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE }),
+ new TupleSerializer<Tuple2<Integer, Long>>(
+ (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE }) });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() {
+ return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
+ (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new TupleSerializer<Tuple2<String, Double>> (
+ (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE
+ }),
+ new TupleSerializer<Tuple2<Long, Long>> (
+ (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE
+ }),
+ new TupleSerializer<Tuple2<Integer, Long>> (
+ (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE
+ })
+ });
+ }
+
+ @Override
+ protected Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] getSortedTestData() {
+ return this.dataISD;
+ }
+
+ @Override
+ protected void deepEquals(
+ String message,
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> should,
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> is) {
+
+ for (int x = 0; x < should.getArity(); x++) {
+ // Check whether field is of type Tuple2 because assertEquals must be called on the non Tuple2 fields.
+ if(should.getField(x) instanceof Tuple2) {
+ this.deepEquals(message, (Tuple2<?,?>) should.getField(x), (Tuple2<?,?>)is.getField(x));
+ }
+ else {
+ assertEquals(message, should.getField(x), is.getField(x));
+ }
+ }// For
+ }
+
+ protected void deepEquals(String message, Tuple2<?,?> should, Tuple2<?,?> is) {
+ for (int x = 0; x < should.getArity(); x++) {
+ assertEquals(message, should.getField(x), is.getField(x));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java
new file mode 100644
index 0000000..4b07c61
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java
@@ -0,0 +1,145 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.common.typeutils.base.StringComparator;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorTTT2Test extends TupleComparatorTestBase<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> {
+
+ @SuppressWarnings("unchecked")
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] dataISD = new Tuple3[]{
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 1.0), new Tuple2<Long, Long>(1L, 1L), new Tuple2<Integer, Long>(4, -10L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 2.0), new Tuple2<Long, Long>(1L, 2L), new Tuple2<Integer, Long>(4, -5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.0), new Tuple2<Long, Long>(1L, 3L), new Tuple2<Integer, Long>(4, 0L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.5), new Tuple2<Long, Long>(1L, 4L), new Tuple2<Integer, Long>(4, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 4325.12), new Tuple2<Long, Long>(1L, 5L), new Tuple2<Integer, Long>(4, 15L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 1.0), new Tuple2<Long, Long>(2L, 4L), new Tuple2<Integer, Long>(45, -5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 2.0), new Tuple2<Long, Long>(2L, 6L), new Tuple2<Integer, Long>(45, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.0), new Tuple2<Long, Long>(2L, 8L), new Tuple2<Integer, Long>(323, 2L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.5), new Tuple2<Long, Long>(2L, 9L), new Tuple2<Integer, Long>(323, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 4325.12), new Tuple2<Long, Long>(2L, 123L), new Tuple2<Integer, Long>(555, 1L))
+
+ };
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator(
+ boolean ascending) {
+ return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
+ new int[] { 0, 2 },
+ new TypeComparator[] {
+ new TupleComparator<Tuple2<String, Double>>(
+ new int[] { 0, 1 },
+ new TypeComparator[] {
+ new StringComparator(ascending),
+ new DoubleComparator(ascending) },
+ new TypeSerializer[] {
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE }),
+ new TupleComparator<Tuple2<Integer, Long>>(
+ new int[] { 0, 1 },
+ new TypeComparator[] {
+ new IntComparator(ascending),
+ new LongComparator(ascending) },
+ new TypeSerializer[] {
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE }) },
+ new TypeSerializer[] {
+ new TupleSerializer<Tuple2<String, Double>>(
+ (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE }),
+ new TupleSerializer<Tuple2<Long, Long>>(
+ (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE }),
+ new TupleSerializer<Tuple2<Integer, Long>>(
+ (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE }) });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() {
+ return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
+ (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new TupleSerializer<Tuple2<String, Double>> (
+ (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE}),
+ new TupleSerializer<Tuple2<Long, Long>> (
+ (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE}),
+ new TupleSerializer<Tuple2<Integer, Long>> (
+ (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE})
+ });
+ }
+
+ @Override
+ protected Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] getSortedTestData() {
+ return this.dataISD;
+ }
+
+ @Override
+ protected void deepEquals(
+ String message,
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> should,
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> is) {
+
+ for (int x = 0; x < should.getArity(); x++) {
+ // Check whether field is of type Tuple2 because assertEquals must be called on the non Tuple2 fields.
+ if(should.getField(x) instanceof Tuple2) {
+ this.deepEquals(message, (Tuple2<?,?>) should.getField(x), (Tuple2<?,?>)is.getField(x));
+ }
+ else {
+ assertEquals(message, should.getField(x), is.getField(x));
+ }
+ }// For
+ }
+
+ protected void deepEquals(String message, Tuple2<?,?> should, Tuple2<?,?> is) {
+ for (int x = 0; x < should.getArity(); x++) {
+ assertEquals(message, should.getField(x), is.getField(x));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java
new file mode 100644
index 0000000..0dfc094
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java
@@ -0,0 +1,154 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.junit.Assert.assertEquals;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.common.typeutils.base.LongComparator;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.apache.flink.api.common.typeutils.base.StringComparator;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
+
+public class TupleComparatorTTT3Test extends TupleComparatorTestBase<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>{
+ @SuppressWarnings("unchecked")
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] dataISD = new Tuple3[]{
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 1.0), new Tuple2<Long, Long>(1L, 1L), new Tuple2<Integer, Long>(4, -10L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 2.0), new Tuple2<Long, Long>(1L, 2L), new Tuple2<Integer, Long>(4, -5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.0), new Tuple2<Long, Long>(1L, 3L), new Tuple2<Integer, Long>(4, 0L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.5), new Tuple2<Long, Long>(1L, 4L), new Tuple2<Integer, Long>(4, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 4325.12), new Tuple2<Long, Long>(1L, 5L), new Tuple2<Integer, Long>(4, 15L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 1.0), new Tuple2<Long, Long>(2L, 4L), new Tuple2<Integer, Long>(45, -5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 2.0), new Tuple2<Long, Long>(2L, 6L), new Tuple2<Integer, Long>(45, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.0), new Tuple2<Long, Long>(2L, 8L), new Tuple2<Integer, Long>(323, 2L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.5), new Tuple2<Long, Long>(2L, 9L), new Tuple2<Integer, Long>(323, 5L)),
+ new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 4325.12), new Tuple2<Long, Long>(2L, 123L), new Tuple2<Integer, Long>(555, 1L))
+
+ };
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator(
+ boolean ascending) {
+ return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
+ new int[] { 0, 1, 2 },
+ new TypeComparator[] {
+ new TupleComparator<Tuple2<String, Double>>(
+ new int[] { 0, 1 },
+ new TypeComparator[] {
+ new StringComparator(ascending),
+ new DoubleComparator(ascending) },
+ new TypeSerializer[] {
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE }),
+ new TupleComparator<Tuple2<Long, Long>>(
+ new int[] { 0, 1 },
+ new TypeComparator[] {
+ new LongComparator(ascending),
+ new LongComparator(ascending) },
+ new TypeSerializer[] {
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE }),
+ new TupleComparator<Tuple2<Integer, Long>>(
+ new int[] { 0, 1 },
+ new TypeComparator[] {
+ new IntComparator(ascending),
+ new LongComparator(ascending) },
+ new TypeSerializer[] {
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE }) },
+ new TypeSerializer[] {
+ new TupleSerializer<Tuple2<String, Double>>(
+ (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE }),
+ new TupleSerializer<Tuple2<Long, Long>>(
+ (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE }),
+ new TupleSerializer<Tuple2<Integer, Long>>(
+ (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[] {
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE }) });
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() {
+ return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
+ (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class,
+ new TypeSerializer[]{
+ new TupleSerializer<Tuple2<String, Double>> (
+ (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ StringSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE
+ }),
+ new TupleSerializer<Tuple2<Long, Long>> (
+ (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ LongSerializer.INSTANCE,
+ LongSerializer.INSTANCE
+ }),
+ new TupleSerializer<Tuple2<Integer, Long>> (
+ (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
+ new TypeSerializer[]{
+ IntSerializer.INSTANCE,
+ LongSerializer.INSTANCE
+ })
+ });
+ }
+
+ @Override
+ protected Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] getSortedTestData() {
+ return this.dataISD;
+ }
+
+ @Override
+ protected void deepEquals(
+ String message,
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> should,
+ Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> is) {
+
+ for (int x = 0; x < should.getArity(); x++) {
+ // Check whether field is of type Tuple2 because assertEquals must be called on the non Tuple2 fields.
+ if(should.getField(x) instanceof Tuple2) {
+ this.deepEquals(message, (Tuple2<?,?>) should.getField(x), (Tuple2<?,?>)is.getField(x));
+ }
+ else {
+ assertEquals(message, should.getField(x), is.getField(x));
+ }
+ }// For
+ }
+
+ protected void deepEquals(String message, Tuple2<?,?> should, Tuple2<?,?> is) {
+ for (int x = 0; x < should.getArity(); x++) {
+ assertEquals(message, should.getField(x), is.getField(x));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java
new file mode 100644
index 0000000..017eb44
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java
@@ -0,0 +1,238 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.api.java.tuple.Tuple0;
+import org.apache.flink.api.java.tuple.Tuple1;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple5;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.Book;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.BookAuthor;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject1;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject2;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.SimpleTypes;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.util.StringUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TupleSerializerTest {
+
+ @Test
+ public void testTuple0() {
+ Tuple0[] testTuples = new Tuple0[] { Tuple0.INSTANCE, Tuple0.INSTANCE, Tuple0.INSTANCE };
+
+ runTests(testTuples);
+ }
+
+ @Test
+ public void testTuple1Int() {
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ Tuple1<Integer>[] testTuples = new Tuple1[] {
+ new Tuple1<Integer>(42), new Tuple1<Integer>(1), new Tuple1<Integer>(0), new Tuple1<Integer>(-1),
+ new Tuple1<Integer>(Integer.MAX_VALUE), new Tuple1<Integer>(Integer.MIN_VALUE)
+ };
+
+ runTests(testTuples);
+ }
+
+ @Test
+ public void testTuple1String() {
+ Random rnd = new Random(68761564135413L);
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ Tuple1<String>[] testTuples = new Tuple1[] {
+ new Tuple1<String>(StringUtils.getRandomString(rnd, 10, 100)),
+ new Tuple1<String>("abc"),
+ new Tuple1<String>(""),
+ new Tuple1<String>(StringUtils.getRandomString(rnd, 30, 170)),
+ new Tuple1<String>(StringUtils.getRandomString(rnd, 15, 50)),
+ new Tuple1<String>("")
+ };
+
+ runTests(testTuples);
+ }
+
+ @Test
+ public void testTuple1StringArray() {
+ Random rnd = new Random(289347567856686223L);
+
+ String[] arr1 = new String[] {"abc", "",
+ StringUtils.getRandomString(rnd, 10, 100),
+ StringUtils.getRandomString(rnd, 15, 50),
+ StringUtils.getRandomString(rnd, 30, 170),
+ StringUtils.getRandomString(rnd, 14, 15),
+ ""};
+
+ String[] arr2 = new String[] {"foo", "",
+ StringUtils.getRandomString(rnd, 10, 100),
+ StringUtils.getRandomString(rnd, 1000, 5000),
+ StringUtils.getRandomString(rnd, 30000, 35000),
+ StringUtils.getRandomString(rnd, 100*1024, 105*1024),
+ "bar"};
+
+ @SuppressWarnings("unchecked")
+ Tuple1<String[]>[] testTuples = new Tuple1[] {
+ new Tuple1<String[]>(arr1),
+ new Tuple1<String[]>(arr2)
+ };
+
+ runTests(testTuples);
+ }
+
+ @Test
+ public void testTuple2StringDouble() {
+ Random rnd = new Random(807346528946L);
+
+ @SuppressWarnings("unchecked")
+ Tuple2<String, Double>[] testTuples = new Tuple2[] {
+ new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
+ new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
+ new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
+ new Tuple2<String, Double>("", rnd.nextDouble()),
+ new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
+ new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble())
+ };
+
+ runTests(testTuples);
+ }
+
+ @Test
+ public void testTuple2StringStringArray() {
+ Random rnd = new Random(289347567856686223L);
+
+ String[] arr1 = new String[] {"abc", "",
+ StringUtils.getRandomString(rnd, 10, 100),
+ StringUtils.getRandomString(rnd, 15, 50),
+ StringUtils.getRandomString(rnd, 30, 170),
+ StringUtils.getRandomString(rnd, 14, 15),
+ ""};
+
+ String[] arr2 = new String[] {"foo", "",
+ StringUtils.getRandomString(rnd, 10, 100),
+ StringUtils.getRandomString(rnd, 1000, 5000),
+ StringUtils.getRandomString(rnd, 30000, 35000),
+ StringUtils.getRandomString(rnd, 100*1024, 105*1024),
+ "bar"};
+
+ @SuppressWarnings("unchecked")
+ Tuple2<String, String[]>[] testTuples = new Tuple2[] {
+ new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr1),
+ new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2),
+ new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr1),
+ new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2),
+ new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2)
+ };
+
+ runTests(testTuples);
+ }
+
+
+ @Test
+ public void testTuple5CustomObjects() {
+ Random rnd = new Random(807346528946L);
+
+ SimpleTypes a = new SimpleTypes();
+ SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+
+ ComplexNestedObject1 o1 = new ComplexNestedObject1(5626435);
+ ComplexNestedObject1 o2 = new ComplexNestedObject1(76923);
+ ComplexNestedObject1 o3 = new ComplexNestedObject1(-1100);
+ ComplexNestedObject1 o4 = new ComplexNestedObject1(0);
+ ComplexNestedObject1 o5 = new ComplexNestedObject1(44);
+
+ ComplexNestedObject2 co1 = new ComplexNestedObject2(rnd);
+ ComplexNestedObject2 co2 = new ComplexNestedObject2();
+ ComplexNestedObject2 co3 = new ComplexNestedObject2(rnd);
+ ComplexNestedObject2 co4 = new ComplexNestedObject2(rnd);
+
+ Book b1 = new Book(976243875L, "The Serialization Odysse", 42);
+ Book b2 = new Book(0L, "Debugging byte streams", 1337);
+ Book b3 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
+ Book b4 = new Book(Long.MAX_VALUE, "The joy of bits and bytes", 0xDEADBEEF);
+ Book b5 = new Book(Long.MIN_VALUE, "Winnign a prize for creative test strings", 0xBADF00);
+ Book b6 = new Book(-2L, "Distributed Systems", 0xABCDEF0123456789L);
+
+ ArrayList<String> list = new ArrayList<String>();
+ list.add("A");
+ list.add("B");
+ list.add("C");
+ list.add("D");
+ list.add("E");
+
+ BookAuthor ba1 = new BookAuthor(976243875L, list, "Arno Nym");
+
+ ArrayList<String> list2 = new ArrayList<String>();
+ BookAuthor ba2 = new BookAuthor(987654321L, list2, "The Saurus");
+
+
+ @SuppressWarnings("unchecked")
+ Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>[] testTuples = new Tuple5[] {
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(a, b1, o1, ba1, co1),
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(b, b2, o2, ba2, co2),
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(c, b3, o3, ba1, co3),
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(d, b2, o4, ba1, co4),
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(e, b4, o5, ba2, co4),
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(f, b5, o1, ba2, co4),
+ new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(g, b6, o4, ba1, co2)
+ };
+
+ runTests(testTuples);
+ }
+
+ private <T extends Tuple> void runTests(T... instances) {
+ try {
+ TupleTypeInfo<T> tupleTypeInfo = (TupleTypeInfo<T>) TypeExtractor.getForObject(instances[0]);
+ TypeSerializer<T> serializer = tupleTypeInfo.createSerializer(new ExecutionConfig());
+
+ Class<T> tupleClass = tupleTypeInfo.getTypeClass();
+
+ int length = -1;
+ if(tupleClass == Tuple0.class) {
+ length = 1;
+ }
+ TupleSerializerTestInstance<T> test = new TupleSerializerTestInstance<T>(serializer, tupleClass, length, instances);
+ test.testAll();
+ }
+ catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+}
[21/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java
new file mode 100644
index 0000000..30710e5
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfo.java
@@ -0,0 +1,248 @@
+/*
+ * 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.java.typeutils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+import com.google.common.base.Preconditions;
+import com.google.common.primitives.Ints;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+//CHECKSTYLE.OFF: AvoidStarImport - Needed for TupleGenerator
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.*;
+import org.apache.flink.api.java.typeutils.runtime.Tuple0Serializer;
+//CHECKSTYLE.ON: AvoidStarImport
+import org.apache.flink.api.java.typeutils.runtime.TupleComparator;
+import org.apache.flink.api.java.typeutils.runtime.TupleSerializer;
+import org.apache.flink.types.Value;
+
+/**
+ * A {@link TypeInformation} for the tuple types of the Java API.
+ *
+ * @param <T> The type of the tuple.
+ */
+public final class TupleTypeInfo<T extends Tuple> extends TupleTypeInfoBase<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final String[] fieldNames;
+
+ @SuppressWarnings("unchecked")
+ public TupleTypeInfo(TypeInformation<?>... types) {
+ this((Class<T>) Tuple.getTupleClass(types.length), types);
+ }
+
+ public TupleTypeInfo(Class<T> tupleType, TypeInformation<?>... types) {
+ super(tupleType, types);
+
+ Preconditions.checkArgument(
+ types.length <= Tuple.MAX_ARITY,
+ "The tuple type exceeds the maximum supported arity.");
+
+ this.fieldNames = new String[types.length];
+
+ for (int i = 0; i < types.length; i++) {
+ fieldNames[i] = "f" + i;
+ }
+ }
+
+ @Override
+ public String[] getFieldNames() {
+ return fieldNames;
+ }
+
+ @Override
+ public int getFieldIndex(String fieldName) {
+ int fieldIndex = Integer.parseInt(fieldName.substring(1));
+ if (fieldIndex >= getArity()) {
+ return -1;
+ }
+ return fieldIndex;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public TupleSerializer<T> createSerializer(ExecutionConfig executionConfig) {
+ if (getTypeClass() == Tuple0.class) {
+ return (TupleSerializer<T>) Tuple0Serializer.INSTANCE;
+ }
+
+ TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[getArity()];
+ for (int i = 0; i < types.length; i++) {
+ fieldSerializers[i] = types[i].createSerializer(executionConfig);
+ }
+
+ Class<T> tupleClass = getTypeClass();
+
+ return new TupleSerializer<T>(tupleClass, fieldSerializers);
+ }
+
+ @Override
+ protected TypeComparatorBuilder<T> createTypeComparatorBuilder() {
+ return new TupleTypeComparatorBuilder();
+ }
+
+ private class TupleTypeComparatorBuilder implements TypeComparatorBuilder<T> {
+
+ private final ArrayList<TypeComparator> fieldComparators = new ArrayList<TypeComparator>();
+ private final ArrayList<Integer> logicalKeyFields = new ArrayList<Integer>();
+
+ @Override
+ public void initializeTypeComparatorBuilder(int size) {
+ fieldComparators.ensureCapacity(size);
+ logicalKeyFields.ensureCapacity(size);
+ }
+
+ @Override
+ public void addComparatorField(int fieldId, TypeComparator<?> comparator) {
+ fieldComparators.add(comparator);
+ logicalKeyFields.add(fieldId);
+ }
+
+ @Override
+ public TypeComparator<T> createTypeComparator(ExecutionConfig config) {
+ Preconditions.checkState(
+ fieldComparators.size() > 0,
+ "No field comparators were defined for the TupleTypeComparatorBuilder."
+ );
+
+ Preconditions.checkState(
+ logicalKeyFields.size() > 0,
+ "No key fields were defined for the TupleTypeComparatorBuilder."
+ );
+
+ Preconditions.checkState(
+ fieldComparators.size() == logicalKeyFields.size(),
+ "The number of field comparators and key fields is not equal."
+ );
+
+ final int maxKey = Collections.max(logicalKeyFields);
+
+ Preconditions.checkState(
+ maxKey >= 0,
+ "The maximum key field must be greater or equal than 0."
+ );
+
+ TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[maxKey + 1];
+
+ for (int i = 0; i <= maxKey; i++) {
+ fieldSerializers[i] = types[i].createSerializer(config);
+ }
+
+ return new TupleComparator<T>(
+ Ints.toArray(logicalKeyFields),
+ fieldComparators.toArray(new TypeComparator[fieldComparators.size()]),
+ fieldSerializers
+ );
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TupleTypeInfo) {
+ @SuppressWarnings("unchecked")
+ TupleTypeInfo<T> other = (TupleTypeInfo<T>) obj;
+ return other.canEqual(this) &&
+ super.equals(other) &&
+ Arrays.equals(fieldNames, other.fieldNames);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof TupleTypeInfo;
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * super.hashCode() + Arrays.hashCode(fieldNames);
+ }
+
+ @Override
+ public String toString() {
+ return "Java " + super.toString();
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static <X extends Tuple> TupleTypeInfo<X> getBasicTupleTypeInfo(Class<?>... basicTypes) {
+ if (basicTypes == null || basicTypes.length == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length];
+ for (int i = 0; i < infos.length; i++) {
+ Class<?> type = basicTypes[i];
+ if (type == null) {
+ throw new IllegalArgumentException("Type at position " + i + " is null.");
+ }
+
+ TypeInformation<?> info = BasicTypeInfo.getInfoFor(type);
+ if (info == null) {
+ throw new IllegalArgumentException("Type at position " + i + " is not a basic type.");
+ }
+ infos[i] = info;
+ }
+
+ @SuppressWarnings("unchecked")
+ TupleTypeInfo<X> tupleInfo = (TupleTypeInfo<X>) new TupleTypeInfo<Tuple>(infos);
+ return tupleInfo;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <X extends Tuple> TupleTypeInfo<X> getBasicAndBasicValueTupleTypeInfo(Class<?>... basicTypes) {
+ if (basicTypes == null || basicTypes.length == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ TypeInformation<?>[] infos = new TypeInformation<?>[basicTypes.length];
+ for (int i = 0; i < infos.length; i++) {
+ Class<?> type = basicTypes[i];
+ if (type == null) {
+ throw new IllegalArgumentException("Type at position " + i + " is null.");
+ }
+
+ TypeInformation<?> info = BasicTypeInfo.getInfoFor(type);
+ if (info == null) {
+ try {
+ info = ValueTypeInfo.getValueTypeInfo((Class<Value>) type);
+ if (!((ValueTypeInfo<?>) info).isBasicValueType()) {
+ throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type.");
+ }
+ } catch (ClassCastException | InvalidTypesException e) {
+ throw new IllegalArgumentException("Type at position " + i + " is not a basic or value type.", e);
+ }
+ }
+ infos[i] = info;
+ }
+
+
+ return (TupleTypeInfo<X>) new TupleTypeInfo<>(infos);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java
new file mode 100644
index 0000000..753eb66
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TupleTypeInfoBase.java
@@ -0,0 +1,252 @@
+/*
+ * 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.java.typeutils;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType;
+
+public abstract class TupleTypeInfoBase<T> extends CompositeType<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final static String REGEX_FIELD = "(f?)([0-9]+)";
+ private final static String REGEX_NESTED_FIELDS = "("+REGEX_FIELD+")(\\.(.+))?";
+ private final static String REGEX_NESTED_FIELDS_WILDCARD = REGEX_NESTED_FIELDS
+ +"|\\"+ ExpressionKeys.SELECT_ALL_CHAR
+ +"|\\"+ExpressionKeys.SELECT_ALL_CHAR_SCALA;
+
+ private static final Pattern PATTERN_FIELD = Pattern.compile(REGEX_FIELD);
+ private static final Pattern PATTERN_NESTED_FIELDS = Pattern.compile(REGEX_NESTED_FIELDS);
+ private static final Pattern PATTERN_NESTED_FIELDS_WILDCARD = Pattern.compile(REGEX_NESTED_FIELDS_WILDCARD);
+
+ // --------------------------------------------------------------------------------------------
+
+ protected final TypeInformation<?>[] types;
+
+ private final int totalFields;
+
+ public TupleTypeInfoBase(Class<T> tupleType, TypeInformation<?>... types) {
+ super(tupleType);
+
+ this.types = Preconditions.checkNotNull(types);
+
+ int fieldCounter = 0;
+
+ for(TypeInformation<?> type : types) {
+ fieldCounter += type.getTotalFields();
+ }
+
+ totalFields = fieldCounter;
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return true;
+ }
+
+ public boolean isCaseClass() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return types.length;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return totalFields;
+ }
+
+ @Override
+ public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) {
+
+ Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression);
+ if (!matcher.matches()) {
+ throw new InvalidFieldReferenceException("Invalid tuple field reference \""+fieldExpression+"\".");
+ }
+
+ String field = matcher.group(0);
+ if (field.equals(ExpressionKeys.SELECT_ALL_CHAR) || field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
+ // handle select all
+ int keyPosition = 0;
+ for (TypeInformation<?> type : types) {
+ if (type instanceof CompositeType) {
+ CompositeType<?> cType = (CompositeType<?>) type;
+ cType.getFlatFields(String.valueOf(ExpressionKeys.SELECT_ALL_CHAR), offset + keyPosition, result);
+ keyPosition += cType.getTotalFields() - 1;
+ } else {
+ result.add(new FlatFieldDescriptor(offset + keyPosition, type));
+ }
+ keyPosition++;
+ }
+ } else {
+ String fieldStr = matcher.group(1);
+ Matcher fieldMatcher = PATTERN_FIELD.matcher(fieldStr);
+
+ if (!fieldMatcher.matches()) {
+ throw new RuntimeException("Invalid matcher pattern");
+ }
+
+ field = fieldMatcher.group(2);
+ int fieldPos = Integer.valueOf(field);
+
+ if (fieldPos >= this.getArity()) {
+ throw new InvalidFieldReferenceException("Tuple field expression \"" + fieldStr + "\" out of bounds of " + this.toString() + ".");
+ }
+ TypeInformation<?> fieldType = this.getTypeAt(fieldPos);
+ String tail = matcher.group(5);
+ if (tail == null) {
+ if (fieldType instanceof CompositeType) {
+ // forward offsets
+ for (int i = 0; i < fieldPos; i++) {
+ offset += this.getTypeAt(i).getTotalFields();
+ }
+ // add all fields of composite type
+ ((CompositeType<?>) fieldType).getFlatFields("*", offset, result);
+ } else {
+ // we found the field to add
+ // compute flat field position by adding skipped fields
+ int flatFieldPos = offset;
+ for (int i = 0; i < fieldPos; i++) {
+ flatFieldPos += this.getTypeAt(i).getTotalFields();
+ }
+ result.add(new FlatFieldDescriptor(flatFieldPos, fieldType));
+ }
+ } else {
+ if (fieldType instanceof CompositeType<?>) {
+ // forward offset
+ for (int i = 0; i < fieldPos; i++) {
+ offset += this.getTypeAt(i).getTotalFields();
+ }
+ ((CompositeType<?>) fieldType).getFlatFields(tail, offset, result);
+ } else {
+ throw new InvalidFieldReferenceException("Nested field expression \"" + tail + "\" not possible on atomic type " + fieldType + ".");
+ }
+ }
+ }
+ }
+
+ @Override
+ public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
+
+ Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
+ if(!matcher.matches()) {
+ if (fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR) || fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
+ throw new InvalidFieldReferenceException("Wildcard expressions are not allowed here.");
+ } else {
+ throw new InvalidFieldReferenceException("Invalid format of tuple field expression \""+fieldExpression+"\".");
+ }
+ }
+
+ String fieldStr = matcher.group(1);
+ Matcher fieldMatcher = PATTERN_FIELD.matcher(fieldStr);
+ if(!fieldMatcher.matches()) {
+ throw new RuntimeException("Invalid matcher pattern");
+ }
+ String field = fieldMatcher.group(2);
+ int fieldPos = Integer.valueOf(field);
+
+ if(fieldPos >= this.getArity()) {
+ throw new InvalidFieldReferenceException("Tuple field expression \""+fieldStr+"\" out of bounds of "+this.toString()+".");
+ }
+ TypeInformation<X> fieldType = this.getTypeAt(fieldPos);
+ String tail = matcher.group(5);
+ if(tail == null) {
+ // we found the type
+ return fieldType;
+ } else {
+ if(fieldType instanceof CompositeType<?>) {
+ return ((CompositeType<?>) fieldType).getTypeAt(tail);
+ } else {
+ throw new InvalidFieldReferenceException("Nested field expression \""+tail+"\" not possible on atomic type "+fieldType+".");
+ }
+ }
+ }
+
+ @Override
+ public <X> TypeInformation<X> getTypeAt(int pos) {
+ if (pos < 0 || pos >= this.types.length) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ @SuppressWarnings("unchecked")
+ TypeInformation<X> typed = (TypeInformation<X>) this.types[pos];
+ return typed;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TupleTypeInfoBase) {
+ @SuppressWarnings("unchecked")
+ TupleTypeInfoBase<T> other = (TupleTypeInfoBase<T>) obj;
+
+ return other.canEqual(this) &&
+ super.equals(other) &&
+ Arrays.equals(types, other.types) &&
+ totalFields == other.totalFields;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof TupleTypeInfoBase;
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * (31 * super.hashCode() + Arrays.hashCode(types)) + totalFields;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder bld = new StringBuilder("Tuple");
+ bld.append(types.length);
+ if (types.length > 0) {
+ bld.append('<').append(types[0]);
+
+ for (int i = 1; i < types.length; i++) {
+ bld.append(", ").append(types[i]);
+ }
+
+ bld.append('>');
+ }
+ return bld.toString();
+ }
+
+ @Override
+ public boolean hasDeterministicFieldOrder() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
new file mode 100644
index 0000000..d4ea24c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
@@ -0,0 +1,1692 @@
+/*
+ * 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.java.typeutils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.avro.specific.SpecificRecordBase;
+
+import org.apache.commons.lang3.ClassUtils;
+
+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.FlatMapFunction;
+import org.apache.flink.api.common.functions.FoldFunction;
+import org.apache.flink.api.common.functions.Function;
+import org.apache.flink.api.common.functions.GroupCombineFunction;
+import org.apache.flink.api.common.functions.GroupReduceFunction;
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.api.common.functions.JoinFunction;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.functions.MapPartitionFunction;
+import org.apache.flink.api.common.functions.Partitioner;
+import org.apache.flink.api.common.functions.util.FunctionUtils;
+import org.apache.flink.api.common.io.InputFormat;
+import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.java.functions.KeySelector;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.api.java.tuple.Tuple0;
+import org.apache.flink.types.Either;
+import org.apache.flink.types.Value;
+import org.apache.flink.util.Collector;
+
+import org.apache.hadoop.io.Writable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * A utility for reflection analysis on classes, to determine the return type of implementations of transformation
+ * functions.
+ */
+public class TypeExtractor {
+
+ /*
+ * NOTE: Most methods of the TypeExtractor work with a so-called "typeHierarchy".
+ * The type hierarchy describes all types (Classes, ParameterizedTypes, TypeVariables etc. ) and intermediate
+ * types from a given type of a function or type (e.g. MyMapper, Tuple2) until a current type
+ * (depends on the method, e.g. MyPojoFieldType).
+ *
+ * Thus, it fully qualifies types until tuple/POJO field level.
+ *
+ * A typical typeHierarchy could look like:
+ *
+ * UDF: MyMapFunction.class
+ * top-level UDF: MyMapFunctionBase.class
+ * RichMapFunction: RichMapFunction.class
+ * MapFunction: MapFunction.class
+ * Function's OUT: Tuple1<MyPojo>
+ * user-defined POJO: MyPojo.class
+ * user-defined top-level POJO: MyPojoBase.class
+ * POJO field: Tuple1<String>
+ * Field type: String.class
+ *
+ */
+
+ private static final Logger LOG = LoggerFactory.getLogger(TypeExtractor.class);
+
+ protected TypeExtractor() {
+ // only create instances for special use cases
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Function specific methods
+ // --------------------------------------------------------------------------------------------
+
+ public static <IN, OUT> TypeInformation<OUT> getMapReturnTypes(MapFunction<IN, OUT> mapInterface, TypeInformation<IN> inType) {
+ return getMapReturnTypes(mapInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getMapReturnTypes(MapFunction<IN, OUT> mapInterface, TypeInformation<IN> inType,
+ String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) mapInterface, MapFunction.class, false, false, inType, functionName, allowMissing);
+ }
+
+
+ public static <IN, OUT> TypeInformation<OUT> getFlatMapReturnTypes(FlatMapFunction<IN, OUT> flatMapInterface, TypeInformation<IN> inType) {
+ return getFlatMapReturnTypes(flatMapInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getFlatMapReturnTypes(FlatMapFunction<IN, OUT> flatMapInterface, TypeInformation<IN> inType,
+ String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) flatMapInterface, FlatMapFunction.class, false, true, inType, functionName, allowMissing);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getFoldReturnTypes(FoldFunction<IN, OUT> foldInterface, TypeInformation<IN> inType)
+ {
+ return getFoldReturnTypes(foldInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getFoldReturnTypes(FoldFunction<IN, OUT> foldInterface, TypeInformation<IN> inType, String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) foldInterface, FoldFunction.class, false, false, inType, functionName, allowMissing);
+ }
+
+
+ public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType) {
+ return getMapPartitionReturnTypes(mapPartitionInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType,
+ String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) mapPartitionInterface, MapPartitionFunction.class, true, true, inType, functionName, allowMissing);
+ }
+
+
+ public static <IN, OUT> TypeInformation<OUT> getGroupReduceReturnTypes(GroupReduceFunction<IN, OUT> groupReduceInterface, TypeInformation<IN> inType) {
+ return getGroupReduceReturnTypes(groupReduceInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getGroupReduceReturnTypes(GroupReduceFunction<IN, OUT> groupReduceInterface, TypeInformation<IN> inType,
+ String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) groupReduceInterface, GroupReduceFunction.class, true, true, inType, functionName, allowMissing);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getGroupCombineReturnTypes(GroupCombineFunction<IN, OUT> combineInterface, TypeInformation<IN> inType) {
+ return getGroupCombineReturnTypes(combineInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getGroupCombineReturnTypes(GroupCombineFunction<IN, OUT> combineInterface, TypeInformation<IN> inType,
+ String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) combineInterface, GroupCombineFunction.class, true, true, inType, functionName, allowMissing);
+ }
+
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getFlatJoinReturnTypes(FlatJoinFunction<IN1, IN2, OUT> joinInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
+ {
+ return getFlatJoinReturnTypes(joinInterface, in1Type, in2Type, null, false);
+ }
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getFlatJoinReturnTypes(FlatJoinFunction<IN1, IN2, OUT> joinInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
+ {
+ return getBinaryOperatorReturnType((Function) joinInterface, FlatJoinFunction.class, false, true,
+ in1Type, in2Type, functionName, allowMissing);
+ }
+
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getJoinReturnTypes(JoinFunction<IN1, IN2, OUT> joinInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
+ {
+ return getJoinReturnTypes(joinInterface, in1Type, in2Type, null, false);
+ }
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getJoinReturnTypes(JoinFunction<IN1, IN2, OUT> joinInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
+ {
+ return getBinaryOperatorReturnType((Function) joinInterface, JoinFunction.class, false, false,
+ in1Type, in2Type, functionName, allowMissing);
+ }
+
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getCoGroupReturnTypes(CoGroupFunction<IN1, IN2, OUT> coGroupInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
+ {
+ return getCoGroupReturnTypes(coGroupInterface, in1Type, in2Type, null, false);
+ }
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getCoGroupReturnTypes(CoGroupFunction<IN1, IN2, OUT> coGroupInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
+ {
+ return getBinaryOperatorReturnType((Function) coGroupInterface, CoGroupFunction.class, true, true,
+ in1Type, in2Type, functionName, allowMissing);
+ }
+
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getCrossReturnTypes(CrossFunction<IN1, IN2, OUT> crossInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
+ {
+ return getCrossReturnTypes(crossInterface, in1Type, in2Type, null, false);
+ }
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getCrossReturnTypes(CrossFunction<IN1, IN2, OUT> crossInterface,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
+ {
+ return getBinaryOperatorReturnType((Function) crossInterface, CrossFunction.class, false, false,
+ in1Type, in2Type, functionName, allowMissing);
+ }
+
+
+ public static <IN, OUT> TypeInformation<OUT> getKeySelectorTypes(KeySelector<IN, OUT> selectorInterface, TypeInformation<IN> inType) {
+ return getKeySelectorTypes(selectorInterface, inType, null, false);
+ }
+
+ public static <IN, OUT> TypeInformation<OUT> getKeySelectorTypes(KeySelector<IN, OUT> selectorInterface,
+ TypeInformation<IN> inType, String functionName, boolean allowMissing)
+ {
+ return getUnaryOperatorReturnType((Function) selectorInterface, KeySelector.class, false, false, inType, functionName, allowMissing);
+ }
+
+
+ public static <T> TypeInformation<T> getPartitionerTypes(Partitioner<T> partitioner) {
+ return getPartitionerTypes(partitioner, null, false);
+ }
+
+ public static <T> TypeInformation<T> getPartitionerTypes(Partitioner<T> partitioner, String functionName, boolean allowMissing) {
+ return new TypeExtractor().privateCreateTypeInfo(Partitioner.class, partitioner.getClass(), 0, null, null);
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <IN> TypeInformation<IN> getInputFormatTypes(InputFormat<IN, ?> inputFormatInterface) {
+ if (inputFormatInterface instanceof ResultTypeQueryable) {
+ return ((ResultTypeQueryable<IN>) inputFormatInterface).getProducedType();
+ }
+ return new TypeExtractor().privateCreateTypeInfo(InputFormat.class, inputFormatInterface.getClass(), 0, null, null);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Generic extraction methods
+ // --------------------------------------------------------------------------------------------
+
+ @SuppressWarnings("unchecked")
+ public static <IN, OUT> TypeInformation<OUT> getUnaryOperatorReturnType(Function function, Class<?> baseClass,
+ boolean hasIterable, boolean hasCollector, TypeInformation<IN> inType,
+ String functionName, boolean allowMissing)
+ {
+ try {
+ final Method m = FunctionUtils.checkAndExtractLambdaMethod(function);
+ if (m != null) {
+ // check for lambda type erasure
+ validateLambdaGenericParameters(m);
+
+ // parameters must be accessed from behind, since JVM can add additional parameters e.g. when using local variables inside lambda function
+ final int paramLen = m.getGenericParameterTypes().length - 1;
+ final Type input = (hasCollector)? m.getGenericParameterTypes()[paramLen - 1] : m.getGenericParameterTypes()[paramLen];
+ validateInputType((hasIterable)?removeGenericWrapper(input) : input, inType);
+ if(function instanceof ResultTypeQueryable) {
+ return ((ResultTypeQueryable<OUT>) function).getProducedType();
+ }
+ return new TypeExtractor().privateCreateTypeInfo((hasCollector)? removeGenericWrapper(m.getGenericParameterTypes()[paramLen]) : m.getGenericReturnType(), inType, null);
+ }
+ else {
+ validateInputType(baseClass, function.getClass(), 0, inType);
+ if(function instanceof ResultTypeQueryable) {
+ return ((ResultTypeQueryable<OUT>) function).getProducedType();
+ }
+ return new TypeExtractor().privateCreateTypeInfo(baseClass, function.getClass(), 1, inType, null);
+ }
+ }
+ catch (InvalidTypesException e) {
+ if (allowMissing) {
+ return (TypeInformation<OUT>) new MissingTypeInfo(functionName != null ? functionName : function.toString(), e);
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <IN1, IN2, OUT> TypeInformation<OUT> getBinaryOperatorReturnType(Function function, Class<?> baseClass,
+ boolean hasIterables, boolean hasCollector, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type,
+ String functionName, boolean allowMissing)
+ {
+ try {
+ final Method m = FunctionUtils.checkAndExtractLambdaMethod(function);
+ if (m != null) {
+ // check for lambda type erasure
+ validateLambdaGenericParameters(m);
+
+ // parameters must be accessed from behind, since JVM can add additional parameters e.g. when using local variables inside lambda function
+ final int paramLen = m.getGenericParameterTypes().length - 1;
+ final Type input1 = (hasCollector)? m.getGenericParameterTypes()[paramLen - 2] : m.getGenericParameterTypes()[paramLen - 1];
+ final Type input2 = (hasCollector)? m.getGenericParameterTypes()[paramLen - 1] : m.getGenericParameterTypes()[paramLen];
+ validateInputType((hasIterables)? removeGenericWrapper(input1) : input1, in1Type);
+ validateInputType((hasIterables)? removeGenericWrapper(input2) : input2, in2Type);
+ if(function instanceof ResultTypeQueryable) {
+ return ((ResultTypeQueryable<OUT>) function).getProducedType();
+ }
+ return new TypeExtractor().privateCreateTypeInfo((hasCollector)? removeGenericWrapper(m.getGenericParameterTypes()[paramLen]) : m.getGenericReturnType(), in1Type, in2Type);
+ }
+ else {
+ validateInputType(baseClass, function.getClass(), 0, in1Type);
+ validateInputType(baseClass, function.getClass(), 1, in2Type);
+ if(function instanceof ResultTypeQueryable) {
+ return ((ResultTypeQueryable<OUT>) function).getProducedType();
+ }
+ return new TypeExtractor().privateCreateTypeInfo(baseClass, function.getClass(), 2, in1Type, in2Type);
+ }
+ }
+ catch (InvalidTypesException e) {
+ if (allowMissing) {
+ return (TypeInformation<OUT>) new MissingTypeInfo(functionName != null ? functionName : function.toString(), e);
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Create type information
+ // --------------------------------------------------------------------------------------------
+
+ @SuppressWarnings("unchecked")
+ public static <T> TypeInformation<T> createTypeInfo(Class<T> type) {
+ return (TypeInformation<T>) createTypeInfo((Type) type);
+ }
+
+ public static TypeInformation<?> createTypeInfo(Type t) {
+ TypeInformation<?> ti = new TypeExtractor().privateCreateTypeInfo(t);
+ if (ti == null) {
+ throw new InvalidTypesException("Could not extract type information.");
+ }
+ return ti;
+ }
+
+ /**
+ * Creates a {@link TypeInformation} from the given parameters.
+ *
+ * If the given {@code instance} implements {@link ResultTypeQueryable}, its information
+ * is used to determine the type information. Otherwise, the type information is derived
+ * based on the given class information.
+ *
+ * @param instance instance to determine type information for
+ * @param baseClass base class of {@code instance}
+ * @param clazz class of {@code instance}
+ * @param returnParamPos index of the return type in the type arguments of {@code clazz}
+ * @param <OUT> output type
+ * @return type information
+ */
+ @SuppressWarnings("unchecked")
+ public static <OUT> TypeInformation<OUT> createTypeInfo(Object instance, Class<?> baseClass, Class<?> clazz, int returnParamPos) {
+ if (instance instanceof ResultTypeQueryable) {
+ return ((ResultTypeQueryable<OUT>) instance).getProducedType();
+ } else {
+ return createTypeInfo(baseClass, clazz, returnParamPos, null, null);
+ }
+ }
+
+ public static <IN1, IN2, OUT> TypeInformation<OUT> createTypeInfo(Class<?> baseClass, Class<?> clazz, int returnParamPos,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+ TypeInformation<OUT> ti = new TypeExtractor().privateCreateTypeInfo(baseClass, clazz, returnParamPos, in1Type, in2Type);
+ if (ti == null) {
+ throw new InvalidTypesException("Could not extract type information.");
+ }
+ return ti;
+ }
+
+ // ----------------------------------- private methods ----------------------------------------
+
+ private TypeInformation<?> privateCreateTypeInfo(Type t) {
+ ArrayList<Type> typeHierarchy = new ArrayList<Type>();
+ typeHierarchy.add(t);
+ return createTypeInfoWithTypeHierarchy(typeHierarchy, t, null, null);
+ }
+
+ // for (Rich)Functions
+ @SuppressWarnings("unchecked")
+ private <IN1, IN2, OUT> TypeInformation<OUT> privateCreateTypeInfo(Class<?> baseClass, Class<?> clazz, int returnParamPos,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+ ArrayList<Type> typeHierarchy = new ArrayList<Type>();
+ Type returnType = getParameterType(baseClass, typeHierarchy, clazz, returnParamPos);
+
+ TypeInformation<OUT> typeInfo;
+
+ // return type is a variable -> try to get the type info from the input directly
+ if (returnType instanceof TypeVariable<?>) {
+ typeInfo = (TypeInformation<OUT>) createTypeInfoFromInputs((TypeVariable<?>) returnType, typeHierarchy, in1Type, in2Type);
+
+ if (typeInfo != null) {
+ return typeInfo;
+ }
+ }
+
+ // get info from hierarchy
+ return (TypeInformation<OUT>) createTypeInfoWithTypeHierarchy(typeHierarchy, returnType, in1Type, in2Type);
+ }
+
+ // for LambdaFunctions
+ @SuppressWarnings("unchecked")
+ private <IN1, IN2, OUT> TypeInformation<OUT> privateCreateTypeInfo(Type returnType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+ ArrayList<Type> typeHierarchy = new ArrayList<Type>();
+
+ // get info from hierarchy
+ return (TypeInformation<OUT>) createTypeInfoWithTypeHierarchy(typeHierarchy, returnType, in1Type, in2Type);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private <IN1, IN2, OUT> TypeInformation<OUT> createTypeInfoWithTypeHierarchy(ArrayList<Type> typeHierarchy, Type t,
+ TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+
+ // check if type is a subclass of tuple
+ if (isClassType(t) && Tuple.class.isAssignableFrom(typeToClass(t))) {
+ Type curT = t;
+
+ // do not allow usage of Tuple as type
+ if (typeToClass(t).equals(Tuple.class)) {
+ throw new InvalidTypesException(
+ "Usage of class Tuple as a type is not allowed. Use a concrete subclass (e.g. Tuple1, Tuple2, etc.) instead.");
+ }
+
+ // go up the hierarchy until we reach immediate child of Tuple (with or without generics)
+ // collect the types while moving up for a later top-down
+ while (!(isClassType(curT) && typeToClass(curT).getSuperclass().equals(Tuple.class))) {
+ typeHierarchy.add(curT);
+ curT = typeToClass(curT).getGenericSuperclass();
+ }
+
+ if(curT == Tuple0.class) {
+ return new TupleTypeInfo(Tuple0.class, new TypeInformation<?>[0]);
+ }
+
+ // check if immediate child of Tuple has generics
+ if (curT instanceof Class<?>) {
+ throw new InvalidTypesException("Tuple needs to be parameterized by using generics.");
+ }
+
+ typeHierarchy.add(curT);
+
+ // create the type information for the subtypes
+ TypeInformation<?>[] subTypesInfo = createSubTypesInfo(t, (ParameterizedType) curT, typeHierarchy, in1Type, in2Type);
+ // type needs to be treated a pojo due to additional fields
+ if (subTypesInfo == null) {
+ if (t instanceof ParameterizedType) {
+ return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), (ParameterizedType) t, in1Type, in2Type);
+ }
+ else {
+ return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), null, in1Type, in2Type);
+ }
+ }
+ // return tuple info
+ return new TupleTypeInfo(typeToClass(t), subTypesInfo);
+
+ }
+ // check if type is a subclass of Either
+ else if (isClassType(t) && Either.class.isAssignableFrom(typeToClass(t))) {
+ Type curT = t;
+
+ // go up the hierarchy until we reach Either (with or without generics)
+ // collect the types while moving up for a later top-down
+ while (!(isClassType(curT) && typeToClass(curT).equals(Either.class))) {
+ typeHierarchy.add(curT);
+ curT = typeToClass(curT).getGenericSuperclass();
+ }
+
+ // check if Either has generics
+ if (curT instanceof Class<?>) {
+ throw new InvalidTypesException("Either needs to be parameterized by using generics.");
+ }
+
+ typeHierarchy.add(curT);
+
+ // create the type information for the subtypes
+ TypeInformation<?>[] subTypesInfo = createSubTypesInfo(t, (ParameterizedType) curT, typeHierarchy, in1Type, in2Type);
+ // type needs to be treated a pojo due to additional fields
+ if (subTypesInfo == null) {
+ if (t instanceof ParameterizedType) {
+ return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), (ParameterizedType) t, in1Type, in2Type);
+ }
+ else {
+ return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), null, in1Type, in2Type);
+ }
+ }
+ // return either info
+ return (TypeInformation<OUT>) new EitherTypeInfo(subTypesInfo[0], subTypesInfo[1]);
+ }
+ // type depends on another type
+ // e.g. class MyMapper<E> extends MapFunction<String, E>
+ else if (t instanceof TypeVariable) {
+ Type typeVar = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) t);
+
+ if (!(typeVar instanceof TypeVariable)) {
+ return createTypeInfoWithTypeHierarchy(typeHierarchy, typeVar, in1Type, in2Type);
+ }
+ // try to derive the type info of the TypeVariable from the immediate base child input as a last attempt
+ else {
+ TypeInformation<OUT> typeInfo = (TypeInformation<OUT>) createTypeInfoFromInputs((TypeVariable<?>) t, typeHierarchy, in1Type, in2Type);
+ if (typeInfo != null) {
+ return typeInfo;
+ } else {
+ throw new InvalidTypesException("Type of TypeVariable '" + ((TypeVariable<?>) t).getName() + "' in '"
+ + ((TypeVariable<?>) t).getGenericDeclaration() + "' could not be determined. This is most likely a type erasure problem. "
+ + "The type extraction currently supports types with generic variables only in cases where "
+ + "all variables in the return type can be deduced from the input type(s).");
+ }
+ }
+ }
+ // arrays with generics
+ else if (t instanceof GenericArrayType) {
+ GenericArrayType genericArray = (GenericArrayType) t;
+
+ Type componentType = genericArray.getGenericComponentType();
+
+ // due to a Java 6 bug, it is possible that the JVM classifies e.g. String[] or int[] as GenericArrayType instead of Class
+ if (componentType instanceof Class) {
+
+ Class<?> componentClass = (Class<?>) componentType;
+ String className;
+ // for int[], double[] etc.
+ if(componentClass.isPrimitive()) {
+ className = encodePrimitiveClass(componentClass);
+ }
+ // for String[], Integer[] etc.
+ else {
+ className = "L" + componentClass.getName() + ";";
+ }
+
+ Class<OUT> classArray;
+ try {
+ classArray = (Class<OUT>) Class.forName("[" + className);
+ } catch (ClassNotFoundException e) {
+ throw new InvalidTypesException("Could not convert GenericArrayType to Class.");
+ }
+
+ return getForClass(classArray);
+ } else {
+ TypeInformation<?> componentInfo = createTypeInfoWithTypeHierarchy(
+ typeHierarchy,
+ genericArray.getGenericComponentType(),
+ in1Type,
+ in2Type);
+
+ Class<OUT> classArray;
+
+ try {
+ String componentClassName = componentInfo.getTypeClass().getName();
+ String resultingClassName;
+
+ if (componentClassName.startsWith("[")) {
+ resultingClassName = "[" + componentClassName;
+ } else {
+ resultingClassName = "[L" + componentClassName + ";";
+ }
+ classArray = (Class<OUT>) Class.forName(resultingClassName);
+ } catch (ClassNotFoundException e) {
+ throw new InvalidTypesException("Could not convert GenericArrayType to Class.");
+ }
+
+ return ObjectArrayTypeInfo.getInfoFor(classArray, componentInfo);
+ }
+ }
+ // objects with generics are treated as Class first
+ else if (t instanceof ParameterizedType) {
+ return (TypeInformation<OUT>) privateGetForClass(typeToClass(t), typeHierarchy, (ParameterizedType) t, in1Type, in2Type);
+ }
+ // no tuple, no TypeVariable, no generic type
+ else if (t instanceof Class) {
+ return privateGetForClass((Class<OUT>) t, typeHierarchy);
+ }
+
+ throw new InvalidTypesException("Type Information could not be created.");
+ }
+
+ private <IN1, IN2> TypeInformation<?> createTypeInfoFromInputs(TypeVariable<?> returnTypeVar, ArrayList<Type> returnTypeHierarchy,
+ TypeInformation<IN1> in1TypeInfo, TypeInformation<IN2> in2TypeInfo) {
+
+ Type matReturnTypeVar = materializeTypeVariable(returnTypeHierarchy, returnTypeVar);
+
+ // variable could be resolved
+ if (!(matReturnTypeVar instanceof TypeVariable)) {
+ return createTypeInfoWithTypeHierarchy(returnTypeHierarchy, matReturnTypeVar, in1TypeInfo, in2TypeInfo);
+ }
+ else {
+ returnTypeVar = (TypeVariable<?>) matReturnTypeVar;
+ }
+
+ // no input information exists
+ if (in1TypeInfo == null && in2TypeInfo == null) {
+ return null;
+ }
+
+ // create a new type hierarchy for the input
+ ArrayList<Type> inputTypeHierarchy = new ArrayList<Type>();
+ // copy the function part of the type hierarchy
+ for (Type t : returnTypeHierarchy) {
+ if (isClassType(t) && Function.class.isAssignableFrom(typeToClass(t)) && typeToClass(t) != Function.class) {
+ inputTypeHierarchy.add(t);
+ }
+ else {
+ break;
+ }
+ }
+ ParameterizedType baseClass = (ParameterizedType) inputTypeHierarchy.get(inputTypeHierarchy.size() - 1);
+
+ TypeInformation<?> info = null;
+ if (in1TypeInfo != null) {
+ // find the deepest type variable that describes the type of input 1
+ Type in1Type = baseClass.getActualTypeArguments()[0];
+
+ info = createTypeInfoFromInput(returnTypeVar, new ArrayList<Type>(inputTypeHierarchy), in1Type, in1TypeInfo);
+ }
+
+ if (info == null && in2TypeInfo != null) {
+ // find the deepest type variable that describes the type of input 2
+ Type in2Type = baseClass.getActualTypeArguments()[1];
+
+ info = createTypeInfoFromInput(returnTypeVar, new ArrayList<Type>(inputTypeHierarchy), in2Type, in2TypeInfo);
+ }
+
+ if (info != null) {
+ return info;
+ }
+
+ return null;
+ }
+
+ private <IN1> TypeInformation<?> createTypeInfoFromInput(TypeVariable<?> returnTypeVar, ArrayList<Type> inputTypeHierarchy, Type inType, TypeInformation<IN1> inTypeInfo) {
+ TypeInformation<?> info = null;
+
+ // the input is a type variable
+ if (inType instanceof TypeVariable) {
+ inType = materializeTypeVariable(inputTypeHierarchy, (TypeVariable<?>) inType);
+ info = findCorrespondingInfo(returnTypeVar, inType, inTypeInfo, inputTypeHierarchy);
+ }
+ // input is an array
+ else if (inType instanceof GenericArrayType) {
+ TypeInformation<?> componentInfo = null;
+ if (inTypeInfo instanceof BasicArrayTypeInfo) {
+ componentInfo = ((BasicArrayTypeInfo<?,?>) inTypeInfo).getComponentInfo();
+ }
+ else if (inTypeInfo instanceof PrimitiveArrayTypeInfo) {
+ componentInfo = BasicTypeInfo.getInfoFor(inTypeInfo.getTypeClass().getComponentType());
+ }
+ else if (inTypeInfo instanceof ObjectArrayTypeInfo) {
+ componentInfo = ((ObjectArrayTypeInfo<?,?>) inTypeInfo).getComponentInfo();
+ }
+ info = createTypeInfoFromInput(returnTypeVar, inputTypeHierarchy, ((GenericArrayType) inType).getGenericComponentType(), componentInfo);
+ }
+ // the input is a tuple
+ else if (inTypeInfo instanceof TupleTypeInfo && isClassType(inType)
+ && Tuple.class.isAssignableFrom(typeToClass(inType))) {
+ ParameterizedType tupleBaseClass;
+
+ // get tuple from possible tuple subclass
+ while (!(isClassType(inType) && typeToClass(inType).getSuperclass().equals(Tuple.class))) {
+ inputTypeHierarchy.add(inType);
+ inType = typeToClass(inType).getGenericSuperclass();
+ }
+ inputTypeHierarchy.add(inType);
+
+ // we can assume to be parameterized since we
+ // already did input validation
+ tupleBaseClass = (ParameterizedType) inType;
+
+ Type[] tupleElements = tupleBaseClass.getActualTypeArguments();
+ // go thru all tuple elements and search for type variables
+ for (int i = 0; i < tupleElements.length; i++) {
+ info = createTypeInfoFromInput(returnTypeVar, inputTypeHierarchy, tupleElements[i], ((TupleTypeInfo<?>) inTypeInfo).getTypeAt(i));
+ if(info != null) {
+ break;
+ }
+ }
+ }
+ // the input is a pojo
+ else if (inTypeInfo instanceof PojoTypeInfo) {
+ // build the entire type hierarchy for the pojo
+ getTypeHierarchy(inputTypeHierarchy, inType, Object.class);
+ info = findCorrespondingInfo(returnTypeVar, inType, inTypeInfo, inputTypeHierarchy);
+ }
+ return info;
+ }
+
+ /**
+ * Creates the TypeInformation for all elements of a type that expects a certain number of
+ * subtypes (e.g. TupleXX or Either).
+ *
+ * @param originalType most concrete subclass
+ * @param definingType type that defines the number of subtypes (e.g. Tuple2 -> 2 subtypes)
+ * @param typeHierarchy necessary for type inference
+ * @param in1Type necessary for type inference
+ * @param in2Type necessary for type inference
+ * @return array containing TypeInformation of sub types or null if definingType contains
+ * more subtypes (fields) that defined
+ */
+ private <IN1, IN2> TypeInformation<?>[] createSubTypesInfo(Type originalType, ParameterizedType definingType,
+ ArrayList<Type> typeHierarchy, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+ Type[] subtypes = new Type[definingType.getActualTypeArguments().length];
+
+ // materialize possible type variables
+ for (int i = 0; i < subtypes.length; i++) {
+ // materialize immediate TypeVariables
+ if (definingType.getActualTypeArguments()[i] instanceof TypeVariable<?>) {
+ subtypes[i] = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) definingType.getActualTypeArguments()[i]);
+ }
+ // class or parameterized type
+ else {
+ subtypes[i] = definingType.getActualTypeArguments()[i];
+ }
+ }
+
+ TypeInformation<?>[] subTypesInfo = new TypeInformation<?>[subtypes.length];
+ for (int i = 0; i < subtypes.length; i++) {
+ ArrayList<Type> subTypeHierarchy = new ArrayList<Type>(typeHierarchy);
+ subTypeHierarchy.add(subtypes[i]);
+ // sub type could not be determined with materializing
+ // try to derive the type info of the TypeVariable from the immediate base child input as a last attempt
+ if (subtypes[i] instanceof TypeVariable<?>) {
+ subTypesInfo[i] = createTypeInfoFromInputs((TypeVariable<?>) subtypes[i], subTypeHierarchy, in1Type, in2Type);
+
+ // variable could not be determined
+ if (subTypesInfo[i] == null) {
+ throw new InvalidTypesException("Type of TypeVariable '" + ((TypeVariable<?>) subtypes[i]).getName() + "' in '"
+ + ((TypeVariable<?>) subtypes[i]).getGenericDeclaration()
+ + "' could not be determined. This is most likely a type erasure problem. "
+ + "The type extraction currently supports types with generic variables only in cases where "
+ + "all variables in the return type can be deduced from the input type(s).");
+ }
+ } else {
+ subTypesInfo[i] = createTypeInfoWithTypeHierarchy(subTypeHierarchy, subtypes[i], in1Type, in2Type);
+ }
+ }
+
+ Class<?> originalTypeAsClass = null;
+ if (isClassType(originalType)) {
+ originalTypeAsClass = typeToClass(originalType);
+ }
+ Preconditions.checkNotNull(originalTypeAsClass, "originalType has an unexpected type");
+ // check if the class we assumed to conform to the defining type so far is actually a pojo because the
+ // original type contains additional fields.
+ // check for additional fields.
+ int fieldCount = countFieldsInClass(originalTypeAsClass);
+ if(fieldCount > subTypesInfo.length) {
+ return null;
+ }
+ return subTypesInfo;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Extract type parameters
+ // --------------------------------------------------------------------------------------------
+
+ public static Type getParameterType(Class<?> baseClass, Class<?> clazz, int pos) {
+ return getParameterType(baseClass, null, clazz, pos);
+ }
+
+ private static Type getParameterType(Class<?> baseClass, ArrayList<Type> typeHierarchy, Class<?> clazz, int pos) {
+ if (typeHierarchy != null) {
+ typeHierarchy.add(clazz);
+ }
+ Type[] interfaceTypes = clazz.getGenericInterfaces();
+
+ // search in interfaces for base class
+ for (Type t : interfaceTypes) {
+ Type parameter = getParameterTypeFromGenericType(baseClass, typeHierarchy, t, pos);
+ if (parameter != null) {
+ return parameter;
+ }
+ }
+
+ // search in superclass for base class
+ Type t = clazz.getGenericSuperclass();
+ Type parameter = getParameterTypeFromGenericType(baseClass, typeHierarchy, t, pos);
+ if (parameter != null) {
+ return parameter;
+ }
+
+ throw new InvalidTypesException("The types of the interface " + baseClass.getName() + " could not be inferred. " +
+ "Support for synthetic interfaces, lambdas, and generic or raw types is limited at this point");
+ }
+
+ private static Type getParameterTypeFromGenericType(Class<?> baseClass, ArrayList<Type> typeHierarchy, Type t, int pos) {
+ // base class
+ if (t instanceof ParameterizedType && baseClass.equals(((ParameterizedType) t).getRawType())) {
+ if (typeHierarchy != null) {
+ typeHierarchy.add(t);
+ }
+ ParameterizedType baseClassChild = (ParameterizedType) t;
+ return baseClassChild.getActualTypeArguments()[pos];
+ }
+ // interface that extended base class as class or parameterized type
+ else if (t instanceof ParameterizedType && baseClass.isAssignableFrom((Class<?>) ((ParameterizedType) t).getRawType())) {
+ if (typeHierarchy != null) {
+ typeHierarchy.add(t);
+ }
+ return getParameterType(baseClass, typeHierarchy, (Class<?>) ((ParameterizedType) t).getRawType(), pos);
+ }
+ else if (t instanceof Class<?> && baseClass.isAssignableFrom((Class<?>) t)) {
+ if (typeHierarchy != null) {
+ typeHierarchy.add(t);
+ }
+ return getParameterType(baseClass, typeHierarchy, (Class<?>) t, pos);
+ }
+ return null;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Validate input
+ // --------------------------------------------------------------------------------------------
+
+ private static void validateInputType(Type t, TypeInformation<?> inType) {
+ ArrayList<Type> typeHierarchy = new ArrayList<Type>();
+ try {
+ validateInfo(typeHierarchy, t, inType);
+ }
+ catch(InvalidTypesException e) {
+ throw new InvalidTypesException("Input mismatch: " + e.getMessage(), e);
+ }
+ }
+
+ private static void validateInputType(Class<?> baseClass, Class<?> clazz, int inputParamPos, TypeInformation<?> inTypeInfo) {
+ ArrayList<Type> typeHierarchy = new ArrayList<Type>();
+
+ // try to get generic parameter
+ Type inType;
+ try {
+ inType = getParameterType(baseClass, typeHierarchy, clazz, inputParamPos);
+ }
+ catch (InvalidTypesException e) {
+ return; // skip input validation e.g. for raw types
+ }
+
+ try {
+ validateInfo(typeHierarchy, inType, inTypeInfo);
+ }
+ catch(InvalidTypesException e) {
+ throw new InvalidTypesException("Input mismatch: " + e.getMessage(), e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void validateInfo(ArrayList<Type> typeHierarchy, Type type, TypeInformation<?> typeInfo) {
+ if (type == null) {
+ throw new InvalidTypesException("Unknown Error. Type is null.");
+ }
+
+ if (typeInfo == null) {
+ throw new InvalidTypesException("Unknown Error. TypeInformation is null.");
+ }
+
+ if (!(type instanceof TypeVariable<?>)) {
+ // check for basic type
+ if (typeInfo.isBasicType()) {
+
+ TypeInformation<?> actual;
+ // check if basic type at all
+ if (!(type instanceof Class<?>) || (actual = BasicTypeInfo.getInfoFor((Class<?>) type)) == null) {
+ throw new InvalidTypesException("Basic type expected.");
+ }
+ // check if correct basic type
+ if (!typeInfo.equals(actual)) {
+ throw new InvalidTypesException("Basic type '" + typeInfo + "' expected but was '" + actual + "'.");
+ }
+
+ }
+ // check for tuple
+ else if (typeInfo.isTupleType()) {
+ // check if tuple at all
+ if (!(isClassType(type) && Tuple.class.isAssignableFrom(typeToClass(type)))) {
+ throw new InvalidTypesException("Tuple type expected.");
+ }
+
+ // do not allow usage of Tuple as type
+ if (isClassType(type) && typeToClass(type).equals(Tuple.class)) {
+ throw new InvalidTypesException("Concrete subclass of Tuple expected.");
+ }
+
+ // go up the hierarchy until we reach immediate child of Tuple (with or without generics)
+ while (!(isClassType(type) && typeToClass(type).getSuperclass().equals(Tuple.class))) {
+ typeHierarchy.add(type);
+ type = typeToClass(type).getGenericSuperclass();
+ }
+
+ if(type == Tuple0.class) {
+ return;
+ }
+
+ // check if immediate child of Tuple has generics
+ if (type instanceof Class<?>) {
+ throw new InvalidTypesException("Parameterized Tuple type expected.");
+ }
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) typeInfo;
+
+ Type[] subTypes = ((ParameterizedType) type).getActualTypeArguments();
+
+ if (subTypes.length != tti.getArity()) {
+ throw new InvalidTypesException("Tuple arity '" + tti.getArity() + "' expected but was '"
+ + subTypes.length + "'.");
+ }
+
+ for (int i = 0; i < subTypes.length; i++) {
+ validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[i], tti.getTypeAt(i));
+ }
+ }
+ // check for Either
+ else if (typeInfo instanceof EitherTypeInfo) {
+ // check if Either at all
+ if (!(isClassType(type) && Either.class.isAssignableFrom(typeToClass(type)))) {
+ throw new InvalidTypesException("Either type expected.");
+ }
+
+ // go up the hierarchy until we reach Either (with or without generics)
+ while (!(isClassType(type) && typeToClass(type).equals(Either.class))) {
+ typeHierarchy.add(type);
+ type = typeToClass(type).getGenericSuperclass();
+ }
+
+ // check if Either has generics
+ if (type instanceof Class<?>) {
+ throw new InvalidTypesException("Parameterized Either type expected.");
+ }
+
+ EitherTypeInfo<?, ?> eti = (EitherTypeInfo<?, ?>) typeInfo;
+ Type[] subTypes = ((ParameterizedType) type).getActualTypeArguments();
+ validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[0], eti.getLeftType());
+ validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[1], eti.getRightType());
+ }
+ // check for Writable
+ else if (typeInfo instanceof WritableTypeInfo<?>) {
+ // check if writable at all
+ if (!(type instanceof Class<?> && Writable.class.isAssignableFrom((Class<?>) type))) {
+ throw new InvalidTypesException("Writable type expected.");
+ }
+
+ // check writable type contents
+ Class<?> clazz;
+ if (((WritableTypeInfo<?>) typeInfo).getTypeClass() != (clazz = (Class<?>) type)) {
+ throw new InvalidTypesException("Writable type '"
+ + ((WritableTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '"
+ + clazz.getCanonicalName() + "'.");
+ }
+ }
+ // check for primitive array
+ else if (typeInfo instanceof PrimitiveArrayTypeInfo) {
+ Type component;
+ // check if array at all
+ if (!(type instanceof Class<?> && ((Class<?>) type).isArray() && (component = ((Class<?>) type).getComponentType()) != null)
+ && !(type instanceof GenericArrayType && (component = ((GenericArrayType) type).getGenericComponentType()) != null)) {
+ throw new InvalidTypesException("Array type expected.");
+ }
+ if (component instanceof TypeVariable<?>) {
+ component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);
+ if (component instanceof TypeVariable) {
+ return;
+ }
+ }
+ if (!(component instanceof Class<?> && ((Class<?>)component).isPrimitive())) {
+ throw new InvalidTypesException("Primitive component expected.");
+ }
+ }
+ // check for basic array
+ else if (typeInfo instanceof BasicArrayTypeInfo<?, ?>) {
+ Type component;
+ // check if array at all
+ if (!(type instanceof Class<?> && ((Class<?>) type).isArray() && (component = ((Class<?>) type).getComponentType()) != null)
+ && !(type instanceof GenericArrayType && (component = ((GenericArrayType) type).getGenericComponentType()) != null)) {
+ throw new InvalidTypesException("Array type expected.");
+ }
+
+ if (component instanceof TypeVariable<?>) {
+ component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);
+ if (component instanceof TypeVariable) {
+ return;
+ }
+ }
+
+ validateInfo(typeHierarchy, component, ((BasicArrayTypeInfo<?, ?>) typeInfo).getComponentInfo());
+
+ }
+ // check for object array
+ else if (typeInfo instanceof ObjectArrayTypeInfo<?, ?>) {
+ // check if array at all
+ if (!(type instanceof Class<?> && ((Class<?>) type).isArray()) && !(type instanceof GenericArrayType)) {
+ throw new InvalidTypesException("Object array type expected.");
+ }
+
+ // check component
+ Type component;
+ if (type instanceof Class<?>) {
+ component = ((Class<?>) type).getComponentType();
+ } else {
+ component = ((GenericArrayType) type).getGenericComponentType();
+ }
+
+ if (component instanceof TypeVariable<?>) {
+ component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);
+ if (component instanceof TypeVariable) {
+ return;
+ }
+ }
+
+ validateInfo(typeHierarchy, component, ((ObjectArrayTypeInfo<?, ?>) typeInfo).getComponentInfo());
+ }
+ // check for value
+ else if (typeInfo instanceof ValueTypeInfo<?>) {
+ // check if value at all
+ if (!(type instanceof Class<?> && Value.class.isAssignableFrom((Class<?>) type))) {
+ throw new InvalidTypesException("Value type expected.");
+ }
+
+ TypeInformation<?> actual;
+ // check value type contents
+ if (!((ValueTypeInfo<?>) typeInfo).equals(actual = ValueTypeInfo.getValueTypeInfo((Class<? extends Value>) type))) {
+ throw new InvalidTypesException("Value type '" + typeInfo + "' expected but was '" + actual + "'.");
+ }
+ }
+ // check for POJO
+ else if (typeInfo instanceof PojoTypeInfo) {
+ Class<?> clazz = null;
+ if (!(isClassType(type) && ((PojoTypeInfo<?>) typeInfo).getTypeClass() == (clazz = typeToClass(type)))) {
+ throw new InvalidTypesException("POJO type '"
+ + ((PojoTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '"
+ + clazz.getCanonicalName() + "'.");
+ }
+ }
+ // check for Enum
+ else if (typeInfo instanceof EnumTypeInfo) {
+ if (!(type instanceof Class<?> && Enum.class.isAssignableFrom((Class<?>) type))) {
+ throw new InvalidTypesException("Enum type expected.");
+ }
+ // check enum type contents
+ if (!(typeInfo.getTypeClass() == type)) {
+ throw new InvalidTypesException("Enum type '" + typeInfo.getTypeClass().getCanonicalName() + "' expected but was '"
+ + typeToClass(type).getCanonicalName() + "'.");
+ }
+ }
+ // check for generic object
+ else if (typeInfo instanceof GenericTypeInfo<?>) {
+ Class<?> clazz = null;
+ if (!(isClassType(type) && ((GenericTypeInfo<?>) typeInfo).getTypeClass() == (clazz = typeToClass(type)))) {
+ throw new InvalidTypesException("Generic object type '"
+ + ((GenericTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '"
+ + clazz.getCanonicalName() + "'.");
+ }
+ }
+ } else {
+ type = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) type);
+ if (!(type instanceof TypeVariable)) {
+ validateInfo(typeHierarchy, type, typeInfo);
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Utility methods
+ // --------------------------------------------------------------------------------------------
+
+ /**
+ * @return number of items with equal type or same raw type
+ */
+ private static int countTypeInHierarchy(ArrayList<Type> typeHierarchy, Type type) {
+ int count = 0;
+ for (Type t : typeHierarchy) {
+ if (t == type || (isClassType(type) && t == typeToClass(type))) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * @param curT : start type
+ * @return Type The immediate child of the top class
+ */
+ private static Type getTypeHierarchy(ArrayList<Type> typeHierarchy, Type curT, Class<?> stopAtClass) {
+ // skip first one
+ if (typeHierarchy.size() > 0 && typeHierarchy.get(0) == curT && isClassType(curT)) {
+ curT = typeToClass(curT).getGenericSuperclass();
+ }
+ while (!(isClassType(curT) && typeToClass(curT).equals(stopAtClass))) {
+ typeHierarchy.add(curT);
+ curT = typeToClass(curT).getGenericSuperclass();
+
+ if (curT == null) {
+ break;
+ }
+ }
+ return curT;
+ }
+
+ private int countFieldsInClass(Class<?> clazz) {
+ int fieldCount = 0;
+ for(Field field : clazz.getFields()) { // get all fields
+ if( !Modifier.isStatic(field.getModifiers()) &&
+ !Modifier.isTransient(field.getModifiers())
+ ) {
+ fieldCount++;
+ }
+ }
+ return fieldCount;
+ }
+
+ private static Type removeGenericWrapper(Type t) {
+ if(t instanceof ParameterizedType &&
+ (Collector.class.isAssignableFrom(typeToClass(t))
+ || Iterable.class.isAssignableFrom(typeToClass(t)))) {
+ return ((ParameterizedType) t).getActualTypeArguments()[0];
+ }
+ return t;
+ }
+
+ private static void validateLambdaGenericParameters(Method m) {
+ // check the arguments
+ for (Type t : m.getGenericParameterTypes()) {
+ validateLambdaGenericParameter(t);
+ }
+
+ // check the return type
+ validateLambdaGenericParameter(m.getGenericReturnType());
+ }
+
+ private static void validateLambdaGenericParameter(Type t) {
+ if(!(t instanceof Class)) {
+ return;
+ }
+ final Class<?> clazz = (Class<?>) t;
+
+ if(clazz.getTypeParameters().length > 0) {
+ throw new InvalidTypesException("The generic type parameters of '" + clazz.getSimpleName() + "' are missing. \n"
+ + "It seems that your compiler has not stored them into the .class file. \n"
+ + "Currently, only the Eclipse JDT compiler preserves the type information necessary to use the lambdas feature type-safely. \n"
+ + "See the documentation for more information about how to compile jobs containing lambda expressions.");
+ }
+ }
+
+ private static String encodePrimitiveClass(Class<?> primitiveClass) {
+ if (primitiveClass == boolean.class) {
+ return "Z";
+ }
+ else if (primitiveClass == byte.class) {
+ return "B";
+ }
+ else if (primitiveClass == char.class) {
+ return "C";
+ }
+ else if (primitiveClass == double.class) {
+ return "D";
+ }
+ else if (primitiveClass == float.class) {
+ return "F";
+ }
+ else if (primitiveClass == int.class) {
+ return "I";
+ }
+ else if (primitiveClass == long.class) {
+ return "J";
+ }
+ else if (primitiveClass == short.class) {
+ return "S";
+ }
+ throw new InvalidTypesException();
+ }
+
+ private static TypeInformation<?> findCorrespondingInfo(TypeVariable<?> typeVar, Type type, TypeInformation<?> corrInfo, ArrayList<Type> typeHierarchy) {
+ if (sameTypeVars(type, typeVar)) {
+ return corrInfo;
+ }
+ else if (type instanceof TypeVariable && sameTypeVars(materializeTypeVariable(typeHierarchy, (TypeVariable<?>) type), typeVar)) {
+ return corrInfo;
+ }
+ else if (type instanceof GenericArrayType) {
+ TypeInformation<?> componentInfo = null;
+ if (corrInfo instanceof BasicArrayTypeInfo) {
+ componentInfo = ((BasicArrayTypeInfo<?,?>) corrInfo).getComponentInfo();
+ }
+ else if (corrInfo instanceof PrimitiveArrayTypeInfo) {
+ componentInfo = BasicTypeInfo.getInfoFor(corrInfo.getTypeClass().getComponentType());
+ }
+ else if (corrInfo instanceof ObjectArrayTypeInfo) {
+ componentInfo = ((ObjectArrayTypeInfo<?,?>) corrInfo).getComponentInfo();
+ }
+ TypeInformation<?> info = findCorrespondingInfo(typeVar, ((GenericArrayType) type).getGenericComponentType(), componentInfo, typeHierarchy);
+ if (info != null) {
+ return info;
+ }
+ }
+ else if (corrInfo instanceof TupleTypeInfo
+ && type instanceof ParameterizedType
+ && Tuple.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())) {
+ ParameterizedType tuple = (ParameterizedType) type;
+ Type[] args = tuple.getActualTypeArguments();
+
+ for (int i = 0; i < args.length; i++) {
+ TypeInformation<?> info = findCorrespondingInfo(typeVar, args[i], ((TupleTypeInfo<?>) corrInfo).getTypeAt(i), typeHierarchy);
+ if (info != null) {
+ return info;
+ }
+ }
+ }
+ else if (corrInfo instanceof PojoTypeInfo && isClassType(type)) {
+ // determine a field containing the type variable
+ List<Field> fields = getAllDeclaredFields(typeToClass(type));
+ for (Field field : fields) {
+ Type fieldType = field.getGenericType();
+ if (fieldType instanceof TypeVariable
+ && sameTypeVars(typeVar, materializeTypeVariable(typeHierarchy, (TypeVariable<?>) fieldType))) {
+ return getTypeOfPojoField(corrInfo, field);
+ }
+ else if (fieldType instanceof ParameterizedType
+ || fieldType instanceof GenericArrayType) {
+ ArrayList<Type> typeHierarchyWithFieldType = new ArrayList<Type>(typeHierarchy);
+ typeHierarchyWithFieldType.add(fieldType);
+ TypeInformation<?> info = findCorrespondingInfo(typeVar, fieldType, getTypeOfPojoField(corrInfo, field), typeHierarchyWithFieldType);
+ if (info != null) {
+ return info;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Tries to find a concrete value (Class, ParameterizedType etc. ) for a TypeVariable by traversing the type hierarchy downwards.
+ * If a value could not be found it will return the most bottom type variable in the hierarchy.
+ */
+ private static Type materializeTypeVariable(ArrayList<Type> typeHierarchy, TypeVariable<?> typeVar) {
+ TypeVariable<?> inTypeTypeVar = typeVar;
+ // iterate thru hierarchy from top to bottom until type variable gets a class assigned
+ for (int i = typeHierarchy.size() - 1; i >= 0; i--) {
+ Type curT = typeHierarchy.get(i);
+
+ // parameterized type
+ if (curT instanceof ParameterizedType) {
+ Class<?> rawType = ((Class<?>) ((ParameterizedType) curT).getRawType());
+
+ for (int paramIndex = 0; paramIndex < rawType.getTypeParameters().length; paramIndex++) {
+
+ TypeVariable<?> curVarOfCurT = rawType.getTypeParameters()[paramIndex];
+
+ // check if variable names match
+ if (sameTypeVars(curVarOfCurT, inTypeTypeVar)) {
+ Type curVarType = ((ParameterizedType) curT).getActualTypeArguments()[paramIndex];
+
+ // another type variable level
+ if (curVarType instanceof TypeVariable<?>) {
+ inTypeTypeVar = (TypeVariable<?>) curVarType;
+ }
+ // class
+ else {
+ return curVarType;
+ }
+ }
+ }
+ }
+ }
+ // can not be materialized, most likely due to type erasure
+ // return the type variable of the deepest level
+ return inTypeTypeVar;
+ }
+
+ /**
+ * Creates type information from a given Class such as Integer, String[] or POJOs.
+ *
+ * This method does not support ParameterizedTypes such as Tuples or complex type hierarchies.
+ * In most cases {@link TypeExtractor#createTypeInfo(Type)} is the recommended method for type extraction
+ * (a Class is a child of Type).
+ *
+ * @param clazz a Class to create TypeInformation for
+ * @return TypeInformation that describes the passed Class
+ */
+ public static <X> TypeInformation<X> getForClass(Class<X> clazz) {
+ return new TypeExtractor().privateGetForClass(clazz, new ArrayList<Type>());
+ }
+
+ private <X> TypeInformation<X> privateGetForClass(Class<X> clazz, ArrayList<Type> typeHierarchy) {
+ return privateGetForClass(clazz, typeHierarchy, null, null, null);
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private <OUT,IN1,IN2> TypeInformation<OUT> privateGetForClass(Class<OUT> clazz, ArrayList<Type> typeHierarchy,
+ ParameterizedType parameterizedType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+ Preconditions.checkNotNull(clazz);
+
+ if (clazz.equals(Object.class)) {
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ // check for arrays
+ if (clazz.isArray()) {
+
+ // primitive arrays: int[], byte[], ...
+ PrimitiveArrayTypeInfo<OUT> primitiveArrayInfo = PrimitiveArrayTypeInfo.getInfoFor(clazz);
+ if (primitiveArrayInfo != null) {
+ return primitiveArrayInfo;
+ }
+
+ // basic type arrays: String[], Integer[], Double[]
+ BasicArrayTypeInfo<OUT, ?> basicArrayInfo = BasicArrayTypeInfo.getInfoFor(clazz);
+ if (basicArrayInfo != null) {
+ return basicArrayInfo;
+ }
+
+ // object arrays
+ else {
+ TypeInformation<?> componentTypeInfo = createTypeInfoWithTypeHierarchy(
+ typeHierarchy,
+ clazz.getComponentType(),
+ in1Type,
+ in2Type);
+
+ return ObjectArrayTypeInfo.getInfoFor(clazz, componentTypeInfo);
+ }
+ }
+
+ // check for writable types
+ if(Writable.class.isAssignableFrom(clazz) && !Writable.class.equals(clazz)) {
+ return (TypeInformation<OUT>) WritableTypeInfo.getWritableTypeInfo((Class<? extends Writable>) clazz);
+ }
+
+ // check for basic types
+ TypeInformation<OUT> basicTypeInfo = BasicTypeInfo.getInfoFor(clazz);
+ if (basicTypeInfo != null) {
+ return basicTypeInfo;
+ }
+
+ // check for subclasses of Value
+ if (Value.class.isAssignableFrom(clazz)) {
+ Class<? extends Value> valueClass = clazz.asSubclass(Value.class);
+ return (TypeInformation<OUT>) ValueTypeInfo.getValueTypeInfo(valueClass);
+ }
+
+ // check for subclasses of Tuple
+ if (Tuple.class.isAssignableFrom(clazz)) {
+ if(clazz == Tuple0.class) {
+ return new TupleTypeInfo(Tuple0.class);
+ }
+ throw new InvalidTypesException("Type information extraction for tuples (except Tuple0) cannot be done based on the class.");
+ }
+
+ // check for subclasses of Either
+ if (Either.class.isAssignableFrom(clazz)) {
+ throw new InvalidTypesException("Type information extraction for Either cannot be done based on the class.");
+ }
+
+ // check for Enums
+ if(Enum.class.isAssignableFrom(clazz)) {
+ return new EnumTypeInfo(clazz);
+ }
+
+ // special case for POJOs generated by Avro.
+ if(SpecificRecordBase.class.isAssignableFrom(clazz)) {
+ return new AvroTypeInfo(clazz);
+ }
+
+ if (countTypeInHierarchy(typeHierarchy, clazz) > 1) {
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ if (Modifier.isInterface(clazz.getModifiers())) {
+ // Interface has no members and is therefore not handled as POJO
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ if (clazz.equals(Class.class)) {
+ // special case handling for Class, this should not be handled by the POJO logic
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ try {
+ TypeInformation<OUT> pojoType = analyzePojo(clazz, new ArrayList<Type>(typeHierarchy), parameterizedType, in1Type, in2Type);
+ if (pojoType != null) {
+ return pojoType;
+ }
+ } catch (InvalidTypesException e) {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Unable to handle type "+clazz+" as POJO. Message: "+e.getMessage(), e);
+ }
+ // ignore and create generic type info
+ }
+
+ // return a generic type
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ /**
+ * Checks if the given field is a valid pojo field:
+ * - it is public
+ * OR
+ * - there are getter and setter methods for the field.
+ *
+ * @param f field to check
+ * @param clazz class of field
+ * @param typeHierarchy type hierarchy for materializing generic types
+ */
+ private boolean isValidPojoField(Field f, Class<?> clazz, ArrayList<Type> typeHierarchy) {
+ if(Modifier.isPublic(f.getModifiers())) {
+ return true;
+ } else {
+ boolean hasGetter = false, hasSetter = false;
+ final String fieldNameLow = f.getName().toLowerCase().replaceAll("_", "");
+
+ Type fieldType = f.getGenericType();
+ Class<?> fieldTypeWrapper = ClassUtils.primitiveToWrapper(f.getType());
+
+ TypeVariable<?> fieldTypeGeneric = null;
+ if(fieldType instanceof TypeVariable) {
+ fieldTypeGeneric = (TypeVariable<?>) fieldType;
+ fieldType = materializeTypeVariable(typeHierarchy, (TypeVariable<?>)fieldType);
+ }
+ for(Method m : clazz.getMethods()) {
+ final String methodNameLow = m.getName().endsWith("_$eq") ?
+ m.getName().toLowerCase().replaceAll("_", "").replaceFirst("\\$eq$", "_\\$eq") :
+ m.getName().toLowerCase().replaceAll("_", "");
+
+ // check for getter
+ if( // The name should be "get<FieldName>" or "<fieldName>" (for scala) or "is<fieldName>" for boolean fields.
+ (methodNameLow.equals("get"+fieldNameLow) || methodNameLow.equals("is"+fieldNameLow) || methodNameLow.equals(fieldNameLow)) &&
+ // no arguments for the getter
+ m.getParameterTypes().length == 0 &&
+ // return type is same as field type (or the generic variant of it)
+ (m.getGenericReturnType().equals( fieldType ) || (fieldTypeWrapper != null && m.getReturnType().equals( fieldTypeWrapper )) || (fieldTypeGeneric != null && m.getGenericReturnType().equals(fieldTypeGeneric)) )
+ ) {
+ if(hasGetter) {
+ throw new IllegalStateException("Detected more than one getter");
+ }
+ hasGetter = true;
+ }
+ // check for setters (<FieldName>_$eq for scala)
+ if((methodNameLow.equals("set"+fieldNameLow) || methodNameLow.equals(fieldNameLow+"_$eq")) &&
+ m.getParameterTypes().length == 1 && // one parameter of the field's type
+ (m.getGenericParameterTypes()[0].equals( fieldType ) || (fieldTypeWrapper != null && m.getParameterTypes()[0].equals( fieldTypeWrapper )) || (fieldTypeGeneric != null && m.getGenericParameterTypes()[0].equals(fieldTypeGeneric) ) )&&
+ // return type is void.
+ m.getReturnType().equals(Void.TYPE)
+ ) {
+ if(hasSetter) {
+ throw new IllegalStateException("Detected more than one setter");
+ }
+ hasSetter = true;
+ }
+ }
+ if(hasGetter && hasSetter) {
+ return true;
+ } else {
+ if(!hasGetter) {
+ LOG.debug(clazz+" does not contain a getter for field "+f.getName() );
+ }
+ if(!hasSetter) {
+ LOG.debug(clazz+" does not contain a setter for field "+f.getName() );
+ }
+ return false;
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <OUT, IN1, IN2> TypeInformation<OUT> analyzePojo(Class<OUT> clazz, ArrayList<Type> typeHierarchy,
+ ParameterizedType parameterizedType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+
+ if (!Modifier.isPublic(clazz.getModifiers())) {
+ LOG.info("Class " + clazz.getName() + " is not public, cannot treat it as a POJO type. Will be handled as GenericType");
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ // add the hierarchy of the POJO itself if it is generic
+ if (parameterizedType != null) {
+ getTypeHierarchy(typeHierarchy, parameterizedType, Object.class);
+ }
+ // create a type hierarchy, if the incoming only contains the most bottom one or none.
+ else if (typeHierarchy.size() <= 1) {
+ getTypeHierarchy(typeHierarchy, clazz, Object.class);
+ }
+
+ List<Field> fields = getAllDeclaredFields(clazz);
+ if (fields.size() == 0) {
+ LOG.info("No fields detected for " + clazz + ". Cannot be used as a PojoType. Will be handled as GenericType");
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
+ List<PojoField> pojoFields = new ArrayList<PojoField>();
+ for (Field field : fields) {
+ Type fieldType = field.getGenericType();
+ if(!isValidPojoField(field, clazz, typeHierarchy)) {
+ LOG.info(clazz + " is not a valid POJO type");
+ return null;
+ }
+ try {
+ ArrayList<Type> fieldTypeHierarchy = new ArrayList<Type>(typeHierarchy);
+ fieldTypeHierarchy.add(fieldType);
+ TypeInformation<?> ti = createTypeInfoWithTypeHierarchy(fieldTypeHierarchy, fieldType, in1Type, in2Type);
+ pojoFields.add(new PojoField(field, ti));
+ } catch (InvalidTypesException e) {
+ Class<?> genericClass = Object.class;
+ if(isClassType(fieldType)) {
+ genericClass = typeToClass(fieldType);
+ }
+ pojoFields.add(new PojoField(field, new GenericTypeInfo<OUT>((Class<OUT>) genericClass)));
+ }
+ }
+
+ CompositeType<OUT> pojoType = new PojoTypeInfo<OUT>(clazz, pojoFields);
+
+ //
+ // Validate the correctness of the pojo.
+ // returning "null" will result create a generic type information.
+ //
+ List<Method> methods = getAllDeclaredMethods(clazz);
+ for (Method method : methods) {
+ if (method.getName().equals("readObject") || method.getName().equals("writeObject")) {
+ LOG.info(clazz+" contains custom serialization methods we do not call.");
+ return null;
+ }
+ }
+
+ // Try retrieving the default constructor, if it does not have one
+ // we cannot use this because the serializer uses it.
+ Constructor defaultConstructor = null;
+ try {
+ defaultConstructor = clazz.getDeclaredConstructor();
+ } catch (NoSuchMethodException e) {
+ if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
+ LOG.info(clazz + " is abstract or an interface, having a concrete " +
+ "type can increase performance.");
+ } else {
+ LOG.info(clazz + " must have a default constructor to be used as a POJO.");
+ return null;
+ }
+ }
+ if(defaultConstructor != null && !Modifier.isPublic(defaultConstructor.getModifiers())) {
+ LOG.info("The default constructor of " + clazz + " should be Public to be used as a POJO.");
+ return null;
+ }
+
+ // everything is checked, we return the pojo
+ return pojoType;
+ }
+
+ /**
+ * recursively determine all declared fields
+ * This is required because class.getFields() is not returning fields defined
+ * in parent classes.
+ */
+ public static List<Field> getAllDeclaredFields(Class<?> clazz) {
+ List<Field> result = new ArrayList<Field>();
+ while (clazz != null) {
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field field : fields) {
+ if(Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) {
+ continue; // we have no use for transient or static fields
+ }
+ if(hasFieldWithSameName(field.getName(), result)) {
+ throw new RuntimeException("The field "+field+" is already contained in the hierarchy of the "+clazz+"."
+ + "Please use unique field names through your classes hierarchy");
+ }
+ result.add(field);
+ }
+ clazz = clazz.getSuperclass();
+ }
+ return result;
+ }
+
+ public static Field getDeclaredField(Class<?> clazz, String name) {
+ for (Field field : getAllDeclaredFields(clazz)) {
+ if (field.getName().equals(name)) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ private static boolean hasFieldWithSameName(String name, List<Field> fields) {
+ for(Field field : fields) {
+ if(name.equals(field.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ // recursively determine all declared methods
+ private static List<Method> getAllDeclaredMethods(Class<?> clazz) {
+ List<Method> result = new ArrayList<Method>();
+ while (clazz != null) {
+ Method[] methods = clazz.getDeclaredMethods();
+ for (Method method : methods) {
+ result.add(method);
+ }
+ clazz = clazz.getSuperclass();
+ }
+ return result;
+ }
+
+ // not public to users
+ public static Class<?> typeToClass(Type t) {
+ if (t instanceof Class) {
+ return (Class<?>)t;
+ }
+ else if (t instanceof ParameterizedType) {
+ return ((Class<?>)((ParameterizedType) t).getRawType());
+ }
+ throw new IllegalArgumentException("Cannot convert type to class");
+ }
+
+ // not public to users
+ public static boolean isClassType(Type t) {
+ return t instanceof Class<?> || t instanceof ParameterizedType;
+ }
+
+ private static boolean sameTypeVars(Type t1, Type t2) {
+ if (!(t1 instanceof TypeVariable) || !(t2 instanceof TypeVariable)) {
+ return false;
+ }
+ return ((TypeVariable<?>) t1).getName().equals(((TypeVariable<?>) t2).getName())
+ && ((TypeVariable<?>) t1).getGenericDeclaration().equals(((TypeVariable<?>) t2).getGenericDeclaration());
+ }
+
+ private static TypeInformation<?> getTypeOfPojoField(TypeInformation<?> pojoInfo, Field field) {
+ for (int j = 0; j < pojoInfo.getArity(); j++) {
+ PojoField pf = ((PojoTypeInfo<?>) pojoInfo).getPojoFieldAt(j);
+ if (pf.getField().getName().equals(field.getName())) {
+ return pf.getTypeInformation();
+ }
+ }
+ return null;
+ }
+
+
+ public static <X> TypeInformation<X> getForObject(X value) {
+ return new TypeExtractor().privateGetForObject(value);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private <X> TypeInformation<X> privateGetForObject(X value) {
+ Preconditions.checkNotNull(value);
+
+ // check if we can extract the types from tuples, otherwise work with the class
+ if (value instanceof Tuple) {
+ Tuple t = (Tuple) value;
+ int numFields = t.getArity();
+ if(numFields != countFieldsInClass(value.getClass())) {
+ // not a tuple since it has more fields.
+ return analyzePojo((Class<X>) value.getClass(), new ArrayList<Type>(), null, null, null); // we immediately call analyze Pojo here, because
+ // there is currently no other type that can handle such a class.
+ }
+
+ TypeInformation<?>[] infos = new TypeInformation[numFields];
+ for (int i = 0; i < numFields; i++) {
+ Object field = t.getField(i);
+
+ if (field == null) {
+ throw new InvalidTypesException("Automatic type extraction is not possible on candidates with null values. "
+ + "Please specify the types directly.");
+ }
+
+ infos[i] = privateGetForObject(field);
+ }
+ return new TupleTypeInfo(value.getClass(), infos);
+ }
+ // we can not extract the types from an Either object since it only contains type information
+ // of one type, but from Either classes
+ else if (value instanceof Either) {
+ try {
+ return (TypeInformation<X>) privateCreateTypeInfo(value.getClass());
+ }
+ catch (InvalidTypesException e) {
+ throw new InvalidTypesException("Automatic type extraction is not possible on an Either type "
+ + "as it does not contain information about both possible types. "
+ + "Please specify the types directly.");
+ }
+ }
+ else {
+ return privateGetForClass((Class<X>) value.getClass(), new ArrayList<Type>());
+ }
+ }
+}
[29/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java
new file mode 100644
index 0000000..901b838
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java
@@ -0,0 +1,514 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 25 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ * @param <T19> The type of field 19
+ * @param <T20> The type of field 20
+ * @param <T21> The type of field 21
+ * @param <T22> The type of field 22
+ * @param <T23> The type of field 23
+ * @param <T24> The type of field 24
+ */
+public class Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+ /** Field 19 of the tuple. */
+ public T19 f19;
+ /** Field 20 of the tuple. */
+ public T20 f20;
+ /** Field 21 of the tuple. */
+ public T21 f21;
+ /** Field 22 of the tuple. */
+ public T22 f22;
+ /** Field 23 of the tuple. */
+ public T23 f23;
+ /** Field 24 of the tuple. */
+ public T24 f24;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple25() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ * @param value22 The value for field 22
+ * @param value23 The value for field 23
+ * @param value24 The value for field 24
+ */
+ public Tuple25(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ this.f22 = value22;
+ this.f23 = value23;
+ this.f24 = value24;
+ }
+
+ @Override
+ public int getArity() { return 25; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ case 19: return (T) this.f19;
+ case 20: return (T) this.f20;
+ case 21: return (T) this.f21;
+ case 22: return (T) this.f22;
+ case 23: return (T) this.f23;
+ case 24: return (T) this.f24;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ case 19:
+ this.f19 = (T19) value;
+ break;
+ case 20:
+ this.f20 = (T20) value;
+ break;
+ case 21:
+ this.f21 = (T21) value;
+ break;
+ case 22:
+ this.f22 = (T22) value;
+ break;
+ case 23:
+ this.f23 = (T23) value;
+ break;
+ case 24:
+ this.f24 = (T24) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ * @param value22 The value for field 22
+ * @param value23 The value for field 23
+ * @param value24 The value for field 24
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ this.f22 = value22;
+ this.f23 = value23;
+ this.f24 = value24;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + "," + StringUtils.arrayAwareToString(this.f19)
+ + "," + StringUtils.arrayAwareToString(this.f20)
+ + "," + StringUtils.arrayAwareToString(this.f21)
+ + "," + StringUtils.arrayAwareToString(this.f22)
+ + "," + StringUtils.arrayAwareToString(this.f23)
+ + "," + StringUtils.arrayAwareToString(this.f24)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple25)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple25 tuple = (Tuple25) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
+ if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
+ if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
+ if (f22 != null ? !f22.equals(tuple.f22) : tuple.f22 != null) { return false; }
+ if (f23 != null ? !f23.equals(tuple.f23) : tuple.f23 != null) { return false; }
+ if (f24 != null ? !f24.equals(tuple.f24) : tuple.f24 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ result = 31 * result + (f19 != null ? f19.hashCode() : 0);
+ result = 31 * result + (f20 != null ? f20.hashCode() : 0);
+ result = 31 * result + (f21 != null ? f21.hashCode() : 0);
+ result = 31 * result + (f22 != null ? f22.hashCode() : 0);
+ result = 31 * result + (f23 != null ? f23.hashCode() : 0);
+ result = 31 * result + (f24 != null ? f24.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> copy(){
+ return new Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18,
+ this.f19,
+ this.f20,
+ this.f21,
+ this.f22,
+ this.f23,
+ this.f24);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24) {
+ return new Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23, value24);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java
new file mode 100644
index 0000000..3a46222
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 3 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ */
+public class Tuple3<T0, T1, T2> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple3() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ */
+ public Tuple3(T0 value0, T1 value1, T2 value2) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ }
+
+ @Override
+ public int getArity() { return 3; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple3)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple3 tuple = (Tuple3) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple3<T0,T1,T2> copy(){
+ return new Tuple3<T0,T1,T2>(this.f0,
+ this.f1,
+ this.f2);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2> Tuple3<T0,T1,T2> of(T0 value0, T1 value1, T2 value2) {
+ return new Tuple3<T0,T1,T2>(value0, value1, value2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java
new file mode 100644
index 0000000..0556ad4
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java
@@ -0,0 +1,199 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 4 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ */
+public class Tuple4<T0, T1, T2, T3> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple4() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ */
+ public Tuple4(T0 value0, T1 value1, T2 value2, T3 value3) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ }
+
+ @Override
+ public int getArity() { return 4; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple4)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple4 tuple = (Tuple4) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple4<T0,T1,T2,T3> copy(){
+ return new Tuple4<T0,T1,T2,T3>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3> Tuple4<T0,T1,T2,T3> of(T0 value0, T1 value1, T2 value2, T3 value3) {
+ return new Tuple4<T0,T1,T2,T3>(value0, value1, value2, value3);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java
new file mode 100644
index 0000000..15d3ea9
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java
@@ -0,0 +1,214 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 5 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ */
+public class Tuple5<T0, T1, T2, T3, T4> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple5() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ */
+ public Tuple5(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ }
+
+ @Override
+ public int getArity() { return 5; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple5)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple5 tuple = (Tuple5) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple5<T0,T1,T2,T3,T4> copy(){
+ return new Tuple5<T0,T1,T2,T3,T4>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4> Tuple5<T0,T1,T2,T3,T4> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4) {
+ return new Tuple5<T0,T1,T2,T3,T4>(value0, value1, value2, value3, value4);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java
new file mode 100644
index 0000000..1d45a26
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java
@@ -0,0 +1,229 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 6 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ */
+public class Tuple6<T0, T1, T2, T3, T4, T5> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple6() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ */
+ public Tuple6(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ }
+
+ @Override
+ public int getArity() { return 6; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple6)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple6 tuple = (Tuple6) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple6<T0,T1,T2,T3,T4,T5> copy(){
+ return new Tuple6<T0,T1,T2,T3,T4,T5>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5> Tuple6<T0,T1,T2,T3,T4,T5> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
+ return new Tuple6<T0,T1,T2,T3,T4,T5>(value0, value1, value2, value3, value4, value5);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java
new file mode 100644
index 0000000..2008117
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java
@@ -0,0 +1,244 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 7 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ */
+public class Tuple7<T0, T1, T2, T3, T4, T5, T6> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple7() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ */
+ public Tuple7(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ }
+
+ @Override
+ public int getArity() { return 7; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple7)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple7 tuple = (Tuple7) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple7<T0,T1,T2,T3,T4,T5,T6> copy(){
+ return new Tuple7<T0,T1,T2,T3,T4,T5,T6>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6> Tuple7<T0,T1,T2,T3,T4,T5,T6> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
+ return new Tuple7<T0,T1,T2,T3,T4,T5,T6>(value0, value1, value2, value3, value4, value5, value6);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java
new file mode 100644
index 0000000..7aaa265
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java
@@ -0,0 +1,259 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 8 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ */
+public class Tuple8<T0, T1, T2, T3, T4, T5, T6, T7> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple8() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ */
+ public Tuple8(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ }
+
+ @Override
+ public int getArity() { return 8; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple8)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple8 tuple = (Tuple8) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple8<T0,T1,T2,T3,T4,T5,T6,T7> copy(){
+ return new Tuple8<T0,T1,T2,T3,T4,T5,T6,T7>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7> Tuple8<T0,T1,T2,T3,T4,T5,T6,T7> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
+ return new Tuple8<T0,T1,T2,T3,T4,T5,T6,T7>(value0, value1, value2, value3, value4, value5, value6, value7);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java
new file mode 100644
index 0000000..86ea998
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 9 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ */
+public class Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple9() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ */
+ public Tuple9(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ }
+
+ @Override
+ public int getArity() { return 9; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple9)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple9 tuple = (Tuple9) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8> copy(){
+ return new Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8> Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
+ return new Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8>(value0, value1, value2, value3, value4, value5, value6, value7, value8);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java
new file mode 100644
index 0000000..5facb7e
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple0;
+
+public class Tuple0Builder {
+
+ private List<Tuple0> tuples = new ArrayList<Tuple0>();
+
+ public Tuple0Builder add() {
+ tuples.add(Tuple0.INSTANCE);
+ return this;
+ }
+
+ public Tuple0[] build() {
+ return tuples.toArray(new Tuple0[tuples.size()]);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java
new file mode 100644
index 0000000..a5aec21
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple10;
+
+public class Tuple10Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> {
+
+ private List<Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>> tuples = new ArrayList<>();
+
+ public Tuple10Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9){
+ tuples.add(new Tuple10<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>[] build(){
+ return tuples.toArray(new Tuple10[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java
new file mode 100644
index 0000000..cbbba7d
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple11;
+
+public class Tuple11Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> {
+
+ private List<Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> tuples = new ArrayList<>();
+
+ public Tuple11Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10){
+ tuples.add(new Tuple11<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>[] build(){
+ return tuples.toArray(new Tuple11[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java
new file mode 100644
index 0000000..08ee5fe
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple12;
+
+public class Tuple12Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> {
+
+ private List<Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> tuples = new ArrayList<>();
+
+ public Tuple12Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11){
+ tuples.add(new Tuple12<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>[] build(){
+ return tuples.toArray(new Tuple12[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java
new file mode 100644
index 0000000..be8d8ff
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple13;
+
+public class Tuple13Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> {
+
+ private List<Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>> tuples = new ArrayList<>();
+
+ public Tuple13Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12){
+ tuples.add(new Tuple13<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>[] build(){
+ return tuples.toArray(new Tuple13[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java
new file mode 100644
index 0000000..4f26af4
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple14;
+
+public class Tuple14Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> {
+
+ private List<Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> tuples = new ArrayList<>();
+
+ public Tuple14Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13){
+ tuples.add(new Tuple14<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>[] build(){
+ return tuples.toArray(new Tuple14[tuples.size()]);
+ }
+}
[30/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java
new file mode 100644
index 0000000..8116121
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java
@@ -0,0 +1,439 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 20 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ * @param <T19> The type of field 19
+ */
+public class Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+ /** Field 19 of the tuple. */
+ public T19 f19;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple20() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ */
+ public Tuple20(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ }
+
+ @Override
+ public int getArity() { return 20; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ case 19: return (T) this.f19;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ case 19:
+ this.f19 = (T19) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + "," + StringUtils.arrayAwareToString(this.f19)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple20)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple20 tuple = (Tuple20) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ result = 31 * result + (f19 != null ? f19.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> copy(){
+ return new Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18,
+ this.f19);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
+ return new Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java
new file mode 100644
index 0000000..6a1aeab
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java
@@ -0,0 +1,454 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 21 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ * @param <T19> The type of field 19
+ * @param <T20> The type of field 20
+ */
+public class Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+ /** Field 19 of the tuple. */
+ public T19 f19;
+ /** Field 20 of the tuple. */
+ public T20 f20;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple21() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ */
+ public Tuple21(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ }
+
+ @Override
+ public int getArity() { return 21; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ case 19: return (T) this.f19;
+ case 20: return (T) this.f20;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ case 19:
+ this.f19 = (T19) value;
+ break;
+ case 20:
+ this.f20 = (T20) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + "," + StringUtils.arrayAwareToString(this.f19)
+ + "," + StringUtils.arrayAwareToString(this.f20)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple21)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple21 tuple = (Tuple21) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
+ if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ result = 31 * result + (f19 != null ? f19.hashCode() : 0);
+ result = 31 * result + (f20 != null ? f20.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> copy(){
+ return new Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18,
+ this.f19,
+ this.f20);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
+ return new Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java
new file mode 100644
index 0000000..5f7194b
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java
@@ -0,0 +1,469 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 22 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ * @param <T19> The type of field 19
+ * @param <T20> The type of field 20
+ * @param <T21> The type of field 21
+ */
+public class Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+ /** Field 19 of the tuple. */
+ public T19 f19;
+ /** Field 20 of the tuple. */
+ public T20 f20;
+ /** Field 21 of the tuple. */
+ public T21 f21;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple22() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ */
+ public Tuple22(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ }
+
+ @Override
+ public int getArity() { return 22; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ case 19: return (T) this.f19;
+ case 20: return (T) this.f20;
+ case 21: return (T) this.f21;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ case 19:
+ this.f19 = (T19) value;
+ break;
+ case 20:
+ this.f20 = (T20) value;
+ break;
+ case 21:
+ this.f21 = (T21) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + "," + StringUtils.arrayAwareToString(this.f19)
+ + "," + StringUtils.arrayAwareToString(this.f20)
+ + "," + StringUtils.arrayAwareToString(this.f21)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple22)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple22 tuple = (Tuple22) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
+ if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
+ if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ result = 31 * result + (f19 != null ? f19.hashCode() : 0);
+ result = 31 * result + (f20 != null ? f20.hashCode() : 0);
+ result = 31 * result + (f21 != null ? f21.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> copy(){
+ return new Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18,
+ this.f19,
+ this.f20,
+ this.f21);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
+ return new Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java
new file mode 100644
index 0000000..35c71ce
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java
@@ -0,0 +1,484 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 23 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ * @param <T19> The type of field 19
+ * @param <T20> The type of field 20
+ * @param <T21> The type of field 21
+ * @param <T22> The type of field 22
+ */
+public class Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+ /** Field 19 of the tuple. */
+ public T19 f19;
+ /** Field 20 of the tuple. */
+ public T20 f20;
+ /** Field 21 of the tuple. */
+ public T21 f21;
+ /** Field 22 of the tuple. */
+ public T22 f22;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple23() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ * @param value22 The value for field 22
+ */
+ public Tuple23(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ this.f22 = value22;
+ }
+
+ @Override
+ public int getArity() { return 23; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ case 19: return (T) this.f19;
+ case 20: return (T) this.f20;
+ case 21: return (T) this.f21;
+ case 22: return (T) this.f22;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ case 19:
+ this.f19 = (T19) value;
+ break;
+ case 20:
+ this.f20 = (T20) value;
+ break;
+ case 21:
+ this.f21 = (T21) value;
+ break;
+ case 22:
+ this.f22 = (T22) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ * @param value22 The value for field 22
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ this.f22 = value22;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + "," + StringUtils.arrayAwareToString(this.f19)
+ + "," + StringUtils.arrayAwareToString(this.f20)
+ + "," + StringUtils.arrayAwareToString(this.f21)
+ + "," + StringUtils.arrayAwareToString(this.f22)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple23)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple23 tuple = (Tuple23) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
+ if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
+ if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
+ if (f22 != null ? !f22.equals(tuple.f22) : tuple.f22 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ result = 31 * result + (f19 != null ? f19.hashCode() : 0);
+ result = 31 * result + (f20 != null ? f20.hashCode() : 0);
+ result = 31 * result + (f21 != null ? f21.hashCode() : 0);
+ result = 31 * result + (f22 != null ? f22.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> copy(){
+ return new Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18,
+ this.f19,
+ this.f20,
+ this.f21,
+ this.f22);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
+ return new Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java
new file mode 100644
index 0000000..5c7f91f
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java
@@ -0,0 +1,499 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 24 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ * @param <T19> The type of field 19
+ * @param <T20> The type of field 20
+ * @param <T21> The type of field 21
+ * @param <T22> The type of field 22
+ * @param <T23> The type of field 23
+ */
+public class Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+ /** Field 19 of the tuple. */
+ public T19 f19;
+ /** Field 20 of the tuple. */
+ public T20 f20;
+ /** Field 21 of the tuple. */
+ public T21 f21;
+ /** Field 22 of the tuple. */
+ public T22 f22;
+ /** Field 23 of the tuple. */
+ public T23 f23;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple24() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ * @param value22 The value for field 22
+ * @param value23 The value for field 23
+ */
+ public Tuple24(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ this.f22 = value22;
+ this.f23 = value23;
+ }
+
+ @Override
+ public int getArity() { return 24; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ case 19: return (T) this.f19;
+ case 20: return (T) this.f20;
+ case 21: return (T) this.f21;
+ case 22: return (T) this.f22;
+ case 23: return (T) this.f23;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ case 19:
+ this.f19 = (T19) value;
+ break;
+ case 20:
+ this.f20 = (T20) value;
+ break;
+ case 21:
+ this.f21 = (T21) value;
+ break;
+ case 22:
+ this.f22 = (T22) value;
+ break;
+ case 23:
+ this.f23 = (T23) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ * @param value19 The value for field 19
+ * @param value20 The value for field 20
+ * @param value21 The value for field 21
+ * @param value22 The value for field 22
+ * @param value23 The value for field 23
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ this.f19 = value19;
+ this.f20 = value20;
+ this.f21 = value21;
+ this.f22 = value22;
+ this.f23 = value23;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + "," + StringUtils.arrayAwareToString(this.f19)
+ + "," + StringUtils.arrayAwareToString(this.f20)
+ + "," + StringUtils.arrayAwareToString(this.f21)
+ + "," + StringUtils.arrayAwareToString(this.f22)
+ + "," + StringUtils.arrayAwareToString(this.f23)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple24)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple24 tuple = (Tuple24) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
+ if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
+ if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
+ if (f22 != null ? !f22.equals(tuple.f22) : tuple.f22 != null) { return false; }
+ if (f23 != null ? !f23.equals(tuple.f23) : tuple.f23 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ result = 31 * result + (f19 != null ? f19.hashCode() : 0);
+ result = 31 * result + (f20 != null ? f20.hashCode() : 0);
+ result = 31 * result + (f21 != null ? f21.hashCode() : 0);
+ result = 31 * result + (f22 != null ? f22.hashCode() : 0);
+ result = 31 * result + (f23 != null ? f23.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> copy(){
+ return new Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18,
+ this.f19,
+ this.f20,
+ this.f21,
+ this.f22,
+ this.f23);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23) {
+ return new Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23);
+ }
+}
[12/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/JoinOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/JoinOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/JoinOperator.java
index 0c0b710..c02d365 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/JoinOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/JoinOperator.java
@@ -29,6 +29,7 @@ import org.apache.flink.api.common.functions.Partitioner;
import org.apache.flink.api.common.functions.RichFlatJoinFunction;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
import org.apache.flink.api.common.operators.DualInputSemanticProperties;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.base.JoinOperatorBase;
import org.apache.flink.api.common.operators.base.InnerJoinOperatorBase;
@@ -42,9 +43,9 @@ import org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsSec
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.functions.SemanticPropUtil;
import org.apache.flink.api.java.operators.DeltaIteration.SolutionSetPlaceHolder;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-import org.apache.flink.api.java.operators.Keys.IncompatibleKeysException;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.operators.Keys.IncompatibleKeysException;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.operators.join.JoinOperatorSetsBase;
import org.apache.flink.api.java.operators.join.JoinType;
import org.apache.flink.api.java.operators.join.JoinFunctionAssigner;
@@ -394,8 +395,8 @@ public abstract class JoinOperator<I1, I2, OUT> extends TwoInputUdfOperator<I1,
@SuppressWarnings("unchecked")
SelectorFunctionKeys<I1, K> keys1 = (SelectorFunctionKeys<I1, K>)rawKeys1;
- TypeInformation<Tuple2<K, I1>> typeInfoWithKey1 = SelectorFunctionKeys.createTypeWithKey(keys1);
- Operator<Tuple2<K, I1>> keyMapper1 = SelectorFunctionKeys.appendKeyExtractor(input1, keys1);
+ TypeInformation<Tuple2<K, I1>> typeInfoWithKey1 = KeyFunctions.createTypeWithKey(keys1);
+ Operator<Tuple2<K, I1>> keyMapper1 = KeyFunctions.appendKeyExtractor(input1, keys1);
return this.withInput1(keyMapper1, typeInfoWithKey1, rawKeys1);
}
@@ -406,8 +407,8 @@ public abstract class JoinOperator<I1, I2, OUT> extends TwoInputUdfOperator<I1,
@SuppressWarnings("unchecked")
SelectorFunctionKeys<I2, K> keys2 = (SelectorFunctionKeys<I2, K>)rawKeys2;
- TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = SelectorFunctionKeys.createTypeWithKey(keys2);
- Operator<Tuple2<K, I2>> keyMapper2 = SelectorFunctionKeys.appendKeyExtractor(input2, keys2);
+ TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = KeyFunctions.createTypeWithKey(keys2);
+ Operator<Tuple2<K, I2>> keyMapper2 = KeyFunctions.appendKeyExtractor(input2, keys2);
return withInput2(keyMapper2, typeInfoWithKey2, rawKeys2);
}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/KeyFunctions.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/KeyFunctions.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/KeyFunctions.java
new file mode 100644
index 0000000..49d598a
--- /dev/null
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/KeyFunctions.java
@@ -0,0 +1,119 @@
+/*
+ * 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.java.operators;
+
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.operators.UnaryOperatorInformation;
+import org.apache.flink.api.common.operators.base.MapOperatorBase;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.java.operators.translation.KeyExtractingMapper;
+import org.apache.flink.api.java.operators.translation.KeyRemovingMapper;
+import org.apache.flink.api.java.operators.translation.TwoKeyExtractingMapper;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+
+/**
+ * This class holds static utilities to append functions that extract and
+ * prune keys.
+ */
+public class KeyFunctions {
+
+ @SuppressWarnings("unchecked")
+ public static <T, K> org.apache.flink.api.common.operators.Operator<Tuple2<K, T>> appendKeyExtractor(
+ org.apache.flink.api.common.operators.Operator<T> input,
+ SelectorFunctionKeys<T, K> key)
+ {
+
+ TypeInformation<T> inputType = key.getInputType();
+ TypeInformation<Tuple2<K, T>> typeInfoWithKey = createTypeWithKey(key);
+ KeyExtractingMapper<T, K> extractor = new KeyExtractingMapper(key.getKeyExtractor());
+
+ MapOperatorBase<T, Tuple2<K, T>, MapFunction<T, Tuple2<K, T>>> mapper =
+ new MapOperatorBase<T, Tuple2<K, T>, MapFunction<T, Tuple2<K, T>>>(
+ extractor,
+ new UnaryOperatorInformation(inputType, typeInfoWithKey),
+ "Key Extractor"
+ );
+
+ mapper.setInput(input);
+ mapper.setParallelism(input.getParallelism());
+
+ return mapper;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T, K1, K2> org.apache.flink.api.common.operators.Operator<Tuple3<K1, K2, T>> appendKeyExtractor(
+ org.apache.flink.api.common.operators.Operator<T> input,
+ SelectorFunctionKeys<T, K1> key1,
+ SelectorFunctionKeys<T, K2> key2)
+ {
+
+ TypeInformation<T> inputType = key1.getInputType();
+ TypeInformation<Tuple3<K1, K2, T>> typeInfoWithKey = createTypeWithKey(key1, key2);
+ TwoKeyExtractingMapper<T, K1, K2> extractor =
+ new TwoKeyExtractingMapper<>(key1.getKeyExtractor(), key2.getKeyExtractor());
+
+ MapOperatorBase<T, Tuple3<K1, K2, T>, MapFunction<T, Tuple3<K1, K2, T>>> mapper =
+ new MapOperatorBase<T, Tuple3<K1, K2, T>, MapFunction<T, Tuple3<K1, K2, T>>>(
+ extractor,
+ new UnaryOperatorInformation<>(inputType, typeInfoWithKey),
+ "Key Extractor"
+ );
+
+ mapper.setInput(input);
+ mapper.setParallelism(input.getParallelism());
+
+ return mapper;
+ }
+
+ public static <T, K> org.apache.flink.api.common.operators.SingleInputOperator<?, T, ?> appendKeyRemover(
+ org.apache.flink.api.common.operators.Operator<Tuple2<K, T>> inputWithKey,
+ SelectorFunctionKeys<T, K> key)
+ {
+
+ TypeInformation<T> inputType = key.getInputType();
+ TypeInformation<Tuple2<K, T>> typeInfoWithKey = createTypeWithKey(key);
+
+ MapOperatorBase<Tuple2<K, T>, T, MapFunction<Tuple2<K, T>, T>> mapper =
+ new MapOperatorBase<Tuple2<K, T>, T, MapFunction<Tuple2<K, T>, T>>(
+ new KeyRemovingMapper<T, K>(),
+ new UnaryOperatorInformation<>(typeInfoWithKey, inputType),
+ "Key Remover"
+ );
+ mapper.setInput(inputWithKey);
+ mapper.setParallelism(inputWithKey.getParallelism());
+
+ return mapper;
+ }
+
+ public static <T, K> TypeInformation<Tuple2<K, T>> createTypeWithKey(
+ SelectorFunctionKeys<T, K> key)
+ {
+ return new TupleTypeInfo<>(key.getKeyType(), key.getInputType());
+ }
+
+ public static <T, K1, K2> TypeInformation<Tuple3<K1, K2, T>> createTypeWithKey(
+ SelectorFunctionKeys<T, K1> key1,
+ SelectorFunctionKeys<T, K2> key2)
+ {
+ return new TupleTypeInfo<>(key1.getKeyType(), key2.getKeyType(), key1.getInputType());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/Keys.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/Keys.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/Keys.java
deleted file mode 100644
index 5992f0b..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/Keys.java
+++ /dev/null
@@ -1,550 +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.java.operators;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.google.common.base.Joiner;
-
-import org.apache.flink.api.common.InvalidProgramException;
-import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.functions.Partitioner;
-import org.apache.flink.api.common.operators.Operator;
-import org.apache.flink.api.common.operators.UnaryOperatorInformation;
-import org.apache.flink.api.common.operators.base.MapOperatorBase;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
-import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.operators.translation.KeyExtractingMapper;
-import org.apache.flink.api.java.operators.translation.KeyRemovingMapper;
-import org.apache.flink.api.java.operators.translation.TwoKeyExtractingMapper;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-
-import com.google.common.base.Preconditions;
-
-public abstract class Keys<T> {
-
- public abstract int getNumberOfKeyFields();
-
- public abstract int[] computeLogicalKeyPositions();
-
- protected abstract TypeInformation<?>[] getKeyFieldTypes();
-
- public abstract <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo);
-
- public boolean isEmpty() {
- return getNumberOfKeyFields() == 0;
- }
-
- /**
- * Check if two sets of keys are compatible to each other (matching types, key counts)
- */
- public boolean areCompatible(Keys<?> other) throws IncompatibleKeysException {
-
- TypeInformation<?>[] thisKeyFieldTypes = this.getKeyFieldTypes();
- TypeInformation<?>[] otherKeyFieldTypes = other.getKeyFieldTypes();
-
- if (thisKeyFieldTypes.length != otherKeyFieldTypes.length) {
- throw new IncompatibleKeysException(IncompatibleKeysException.SIZE_MISMATCH_MESSAGE);
- } else {
- for (int i = 0; i < thisKeyFieldTypes.length; i++) {
- if (!thisKeyFieldTypes[i].equals(otherKeyFieldTypes[i])) {
- throw new IncompatibleKeysException(thisKeyFieldTypes[i], otherKeyFieldTypes[i] );
- }
- }
- }
- return true;
- }
-
- // --------------------------------------------------------------------------------------------
- // Specializations for expression-based / extractor-based grouping
- // --------------------------------------------------------------------------------------------
-
-
- public static class SelectorFunctionKeys<T, K> extends Keys<T> {
-
- private final KeySelector<T, K> keyExtractor;
- private final TypeInformation<T> inputType;
- private final TypeInformation<K> keyType;
- private final List<FlatFieldDescriptor> keyFields;
-
- public SelectorFunctionKeys(KeySelector<T, K> keyExtractor, TypeInformation<T> inputType, TypeInformation<K> keyType) {
-
- if (keyExtractor == null) {
- throw new NullPointerException("Key extractor must not be null.");
- }
- if (keyType == null) {
- throw new NullPointerException("Key type must not be null.");
- }
- if (!keyType.isKeyType()) {
- throw new InvalidProgramException("Return type "+keyType+" of KeySelector "+keyExtractor.getClass()+" is not a valid key type");
- }
-
- this.keyExtractor = keyExtractor;
- this.inputType = inputType;
- this.keyType = keyType;
-
- if (keyType instanceof CompositeType) {
- this.keyFields = ((CompositeType<T>)keyType).getFlatFields(ExpressionKeys.SELECT_ALL_CHAR);
- }
- else {
- this.keyFields = new ArrayList<>(1);
- this.keyFields.add(new FlatFieldDescriptor(0, keyType));
- }
- }
-
- public TypeInformation<K> getKeyType() {
- return keyType;
- }
-
- public TypeInformation<T> getInputType() {
- return inputType;
- }
-
- public KeySelector<T, K> getKeyExtractor() {
- return keyExtractor;
- }
-
- @Override
- public int getNumberOfKeyFields() {
- return keyFields.size();
- }
-
- @Override
- public int[] computeLogicalKeyPositions() {
- int[] logicalKeys = new int[keyFields.size()];
- for (int i = 0; i < keyFields.size(); i++) {
- logicalKeys[i] = keyFields.get(i).getPosition();
- }
- return logicalKeys;
- }
-
- @Override
- protected TypeInformation<?>[] getKeyFieldTypes() {
- TypeInformation<?>[] fieldTypes = new TypeInformation[keyFields.size()];
- for (int i = 0; i < keyFields.size(); i++) {
- fieldTypes[i] = keyFields.get(i).getType();
- }
- return fieldTypes;
- }
-
- @Override
- public <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo) {
-
- if (keyFields.size() != 1) {
- throw new InvalidProgramException("Custom partitioners can only be used with keys that have one key field.");
- }
-
- if (typeInfo == null) {
- // try to extract key type from partitioner
- try {
- typeInfo = TypeExtractor.getPartitionerTypes(partitioner);
- }
- catch (Throwable t) {
- // best effort check, so we ignore exceptions
- }
- }
-
- // only check if type is known and not a generic type
- if (typeInfo != null && !(typeInfo instanceof GenericTypeInfo)) {
- // check equality of key and partitioner type
- if (!keyType.equals(typeInfo)) {
- throw new InvalidProgramException("The partitioner is incompatible with the key type. "
- + "Partitioner type: " + typeInfo + " , key type: " + keyType);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public static <T, K> Operator<Tuple2<K, T>> appendKeyExtractor(
- Operator<T> input,
- SelectorFunctionKeys<T, K> key)
- {
-
- TypeInformation<T> inputType = key.getInputType();
- TypeInformation<Tuple2<K, T>> typeInfoWithKey = createTypeWithKey(key);
- KeyExtractingMapper<T, K> extractor = new KeyExtractingMapper(key.getKeyExtractor());
-
- MapOperatorBase<T, Tuple2<K, T>, MapFunction<T, Tuple2<K, T>>> mapper =
- new MapOperatorBase<T, Tuple2<K, T>, MapFunction<T, Tuple2<K, T>>>(
- extractor,
- new UnaryOperatorInformation(inputType, typeInfoWithKey),
- "Key Extractor"
- );
-
- mapper.setInput(input);
- mapper.setParallelism(input.getParallelism());
-
- return mapper;
- }
-
- @SuppressWarnings("unchecked")
- public static <T, K1, K2> Operator<Tuple3<K1, K2, T>> appendKeyExtractor(
- Operator<T> input,
- SelectorFunctionKeys<T, K1> key1,
- SelectorFunctionKeys<T, K2> key2)
- {
-
- TypeInformation<T> inputType = key1.getInputType();
- TypeInformation<Tuple3<K1, K2, T>> typeInfoWithKey = createTypeWithKey(key1, key2);
- TwoKeyExtractingMapper<T, K1, K2> extractor =
- new TwoKeyExtractingMapper<>(key1.getKeyExtractor(), key2.getKeyExtractor());
-
- MapOperatorBase<T, Tuple3<K1, K2, T>, MapFunction<T, Tuple3<K1, K2, T>>> mapper =
- new MapOperatorBase<T, Tuple3<K1, K2, T>, MapFunction<T, Tuple3<K1, K2, T>>>(
- extractor,
- new UnaryOperatorInformation<>(inputType, typeInfoWithKey),
- "Key Extractor"
- );
-
- mapper.setInput(input);
- mapper.setParallelism(input.getParallelism());
-
- return mapper;
- }
-
- public static <T, K> org.apache.flink.api.common.operators.SingleInputOperator<?, T, ?> appendKeyRemover(
- Operator<Tuple2<K, T>> inputWithKey,
- SelectorFunctionKeys<T, K> key)
- {
-
- TypeInformation<T> inputType = key.getInputType();
- TypeInformation<Tuple2<K, T>> typeInfoWithKey = createTypeWithKey(key);
-
- MapOperatorBase<Tuple2<K, T>, T, MapFunction<Tuple2<K, T>, T>> mapper =
- new MapOperatorBase<Tuple2<K, T>, T, MapFunction<Tuple2<K, T>, T>>(
- new KeyRemovingMapper<T, K>(),
- new UnaryOperatorInformation<>(typeInfoWithKey, inputType),
- "Key Remover"
- );
- mapper.setInput(inputWithKey);
- mapper.setParallelism(inputWithKey.getParallelism());
-
- return mapper;
- }
-
- public static <T, K> TypeInformation<Tuple2<K, T>> createTypeWithKey(
- SelectorFunctionKeys<T, K> key)
- {
- return new TupleTypeInfo<>(key.getKeyType(), key.getInputType());
- }
-
- public static <T, K1, K2> TypeInformation<Tuple3<K1, K2, T>> createTypeWithKey(
- SelectorFunctionKeys<T, K1> key1,
- SelectorFunctionKeys<T, K2> key2)
- {
- return new TupleTypeInfo<>(key1.getKeyType(), key2.getKeyType(), key1.getInputType());
- }
-
- @Override
- public String toString() {
- return "Key function (Type: " + keyType + ")";
- }
- }
-
-
- /**
- * Represents (nested) field access through string and integer-based keys
- */
- public static class ExpressionKeys<T> extends Keys<T> {
-
- public static final String SELECT_ALL_CHAR = "*";
- public static final String SELECT_ALL_CHAR_SCALA = "_";
-
- // Flattened fields representing keys fields
- private List<FlatFieldDescriptor> keyFields;
-
- /**
- * ExpressionKeys that is defined by the full data type.
- */
- public ExpressionKeys(TypeInformation<T> type) {
- this(SELECT_ALL_CHAR, type);
- }
-
- /**
- * Create int-based (non-nested) field position keys on a tuple type.
- */
- public ExpressionKeys(int keyPosition, TypeInformation<T> type) {
- this(new int[]{keyPosition}, type, false);
- }
-
- /**
- * Create int-based (non-nested) field position keys on a tuple type.
- */
- public ExpressionKeys(int[] keyPositions, TypeInformation<T> type) {
- this(keyPositions, type, false);
- }
-
- /**
- * Create int-based (non-nested) field position keys on a tuple type.
- */
- public ExpressionKeys(int[] keyPositions, TypeInformation<T> type, boolean allowEmpty) {
-
- if (!type.isTupleType() || !(type instanceof CompositeType)) {
- throw new InvalidProgramException("Specifying keys via field positions is only valid " +
- "for tuple data types. Type: " + type);
- }
- if (type.getArity() == 0) {
- throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity());
- }
- if (!allowEmpty && (keyPositions == null || keyPositions.length == 0)) {
- throw new IllegalArgumentException("The grouping fields must not be empty.");
- }
-
- this.keyFields = new ArrayList<>();
-
- if (keyPositions == null || keyPositions.length == 0) {
- // use all tuple fields as key fields
- keyPositions = createIncrIntArray(type.getArity());
- } else {
- rangeCheckFields(keyPositions, type.getArity() - 1);
- }
- Preconditions.checkArgument(keyPositions.length > 0, "Grouping fields can not be empty at this point");
-
- // extract key field types
- CompositeType<T> cType = (CompositeType<T>)type;
- this.keyFields = new ArrayList<>(type.getTotalFields());
-
- // for each key position, find all (nested) field types
- String[] fieldNames = cType.getFieldNames();
- ArrayList<FlatFieldDescriptor> tmpList = new ArrayList<>();
- for (int keyPos : keyPositions) {
- tmpList.clear();
- // get all flat fields
- cType.getFlatFields(fieldNames[keyPos], 0, tmpList);
- // check if fields are of key type
- for(FlatFieldDescriptor ffd : tmpList) {
- if(!ffd.getType().isKeyType()) {
- throw new InvalidProgramException("This type (" + ffd.getType() + ") cannot be used as key.");
- }
- }
- this.keyFields.addAll(tmpList);
- }
- }
-
- /**
- * Create String-based (nested) field expression keys on a composite type.
- */
- public ExpressionKeys(String keyExpression, TypeInformation<T> type) {
- this(new String[]{keyExpression}, type);
- }
-
- /**
- * Create String-based (nested) field expression keys on a composite type.
- */
- public ExpressionKeys(String[] keyExpressions, TypeInformation<T> type) {
- Preconditions.checkNotNull(keyExpressions, "Field expression cannot be null.");
-
- this.keyFields = new ArrayList<>(keyExpressions.length);
-
- if (type instanceof CompositeType){
- CompositeType<T> cType = (CompositeType<T>) type;
-
- // extract the keys on their flat position
- for (String keyExpr : keyExpressions) {
- if (keyExpr == null) {
- throw new InvalidProgramException("Expression key may not be null.");
- }
- // strip off whitespace
- keyExpr = keyExpr.trim();
-
- List<FlatFieldDescriptor> flatFields = cType.getFlatFields(keyExpr);
-
- if (flatFields.size() == 0) {
- throw new InvalidProgramException("Unable to extract key from expression '" + keyExpr + "' on key " + cType);
- }
- // check if all nested fields can be used as keys
- for (FlatFieldDescriptor field : flatFields) {
- if (!field.getType().isKeyType()) {
- throw new InvalidProgramException("This type (" + field.getType() + ") cannot be used as key.");
- }
- }
- // add flat fields to key fields
- keyFields.addAll(flatFields);
- }
- }
- else {
- if (!type.isKeyType()) {
- throw new InvalidProgramException("This type (" + type + ") cannot be used as key.");
- }
-
- // check that all key expressions are valid
- for (String keyExpr : keyExpressions) {
- if (keyExpr == null) {
- throw new InvalidProgramException("Expression key may not be null.");
- }
- // strip off whitespace
- keyExpr = keyExpr.trim();
- // check that full type is addressed
- if (!(SELECT_ALL_CHAR.equals(keyExpr) || SELECT_ALL_CHAR_SCALA.equals(keyExpr))) {
- throw new InvalidProgramException(
- "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for non-composite types.");
- }
- // add full type as key
- keyFields.add(new FlatFieldDescriptor(0, type));
- }
- }
- }
-
- @Override
- public int getNumberOfKeyFields() {
- if(keyFields == null) {
- return 0;
- }
- return keyFields.size();
- }
-
- @Override
- public int[] computeLogicalKeyPositions() {
- int[] logicalKeys = new int[keyFields.size()];
- for (int i = 0; i < keyFields.size(); i++) {
- logicalKeys[i] = keyFields.get(i).getPosition();
- }
- return logicalKeys;
- }
-
- @Override
- protected TypeInformation<?>[] getKeyFieldTypes() {
- TypeInformation<?>[] fieldTypes = new TypeInformation[keyFields.size()];
- for (int i = 0; i < keyFields.size(); i++) {
- fieldTypes[i] = keyFields.get(i).getType();
- }
- return fieldTypes;
- }
-
- @Override
- public <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo) {
-
- if (keyFields.size() != 1) {
- throw new InvalidProgramException("Custom partitioners can only be used with keys that have one key field.");
- }
-
- if (typeInfo == null) {
- // try to extract key type from partitioner
- try {
- typeInfo = TypeExtractor.getPartitionerTypes(partitioner);
- }
- catch (Throwable t) {
- // best effort check, so we ignore exceptions
- }
- }
-
- if (typeInfo != null && !(typeInfo instanceof GenericTypeInfo)) {
- // only check type compatibility if type is known and not a generic type
-
- TypeInformation<?> keyType = keyFields.get(0).getType();
- if (!keyType.equals(typeInfo)) {
- throw new InvalidProgramException("The partitioner is incompatible with the key type. "
- + "Partitioner type: " + typeInfo + " , key type: " + keyType);
- }
- }
- }
-
- @Override
- public String toString() {
- Joiner join = Joiner.on('.');
- return "ExpressionKeys: " + join.join(keyFields);
- }
-
- public static boolean isSortKey(int fieldPos, TypeInformation<?> type) {
-
- if (!type.isTupleType() || !(type instanceof CompositeType)) {
- throw new InvalidProgramException("Specifying keys via field positions is only valid " +
- "for tuple data types. Type: " + type);
- }
- if (type.getArity() == 0) {
- throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity());
- }
-
- if(fieldPos < 0 || fieldPos >= type.getArity()) {
- throw new IndexOutOfBoundsException("Tuple position is out of range: " + fieldPos);
- }
-
- TypeInformation<?> sortKeyType = ((CompositeType<?>)type).getTypeAt(fieldPos);
- return sortKeyType.isSortKeyType();
- }
-
- public static boolean isSortKey(String fieldExpr, TypeInformation<?> type) {
-
- TypeInformation<?> sortKeyType;
-
- fieldExpr = fieldExpr.trim();
- if (SELECT_ALL_CHAR.equals(fieldExpr) || SELECT_ALL_CHAR_SCALA.equals(fieldExpr)) {
- sortKeyType = type;
- }
- else {
- if (type instanceof CompositeType) {
- sortKeyType = ((CompositeType<?>) type).getTypeAt(fieldExpr);
- }
- else {
- throw new InvalidProgramException(
- "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for atomic types.");
- }
- }
-
- return sortKeyType.isSortKeyType();
- }
-
- }
-
- // --------------------------------------------------------------------------------------------
-
-
-
- // --------------------------------------------------------------------------------------------
- // Utilities
- // --------------------------------------------------------------------------------------------
-
-
- private static int[] createIncrIntArray(int numKeys) {
- int[] keyFields = new int[numKeys];
- for (int i = 0; i < numKeys; i++) {
- keyFields[i] = i;
- }
- return keyFields;
- }
-
- private static void rangeCheckFields(int[] fields, int maxAllowedField) {
-
- for (int f : fields) {
- if (f < 0 || f > maxAllowedField) {
- throw new IndexOutOfBoundsException("Tuple position is out of range: " + f);
- }
- }
- }
-
- public static class IncompatibleKeysException extends Exception {
- private static final long serialVersionUID = 1L;
- public static final String SIZE_MISMATCH_MESSAGE = "The number of specified keys is different.";
-
- public IncompatibleKeysException(String message) {
- super(message);
- }
-
- public IncompatibleKeysException(TypeInformation<?> typeInformation, TypeInformation<?> typeInformation2) {
- super(typeInformation+" and "+typeInformation2+" are not compatible");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/PartitionOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/PartitionOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/PartitionOperator.java
index 1384ca2..96931b0 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/PartitionOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/PartitionOperator.java
@@ -21,13 +21,14 @@ package org.apache.flink.api.java.operators;
import com.google.common.base.Preconditions;
import org.apache.flink.api.common.functions.Partitioner;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.PartitionOperatorBase;
import org.apache.flink.api.common.operators.base.PartitionOperatorBase.PartitionMethod;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.DataSet;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.tuple.Tuple2;
/**
@@ -150,9 +151,9 @@ public class PartitionOperator<T> extends SingleInputOperator<T, T, PartitionOpe
Partitioner<?> customPartitioner)
{
final SelectorFunctionKeys<T, K> keys = (SelectorFunctionKeys<T, K>) rawKeys;
- TypeInformation<Tuple2<K, T>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(keys);
+ TypeInformation<Tuple2<K, T>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
- Operator<Tuple2<K, T>> keyedInput = SelectorFunctionKeys.appendKeyExtractor(input, keys);
+ Operator<Tuple2<K, T>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
PartitionOperatorBase<Tuple2<K, T>> keyedPartitionedInput =
new PartitionOperatorBase<>(new UnaryOperatorInformation<>(typeInfoWithKey, typeInfoWithKey), pMethod, new int[]{0}, name);
@@ -160,7 +161,7 @@ public class PartitionOperator<T> extends SingleInputOperator<T, T, PartitionOpe
keyedPartitionedInput.setCustomPartitioner(customPartitioner);
keyedPartitionedInput.setParallelism(partitionDop);
- return SelectorFunctionKeys.appendKeyRemover(keyedPartitionedInput, keys);
+ return KeyFunctions.appendKeyRemover(keyedPartitionedInput, keys);
}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/ReduceOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/ReduceOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/ReduceOperator.java
index 6f8877f..a22a262 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/ReduceOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/ReduceOperator.java
@@ -19,13 +19,14 @@
package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.functions.ReduceFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.SingleInputSemanticProperties;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.ReduceOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.functions.SemanticPropUtil;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.operators.translation.PlanUnwrappingReduceOperator;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.DataSet;
@@ -161,13 +162,13 @@ public class ReduceOperator<IN> extends SingleInputUdfOperator<IN, IN, ReduceOpe
@SuppressWarnings("unchecked")
final SelectorFunctionKeys<T, K> keys = (SelectorFunctionKeys<T, K>) rawKeys;
- TypeInformation<Tuple2<K, T>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(keys);
- Operator<Tuple2<K, T>> keyedInput = SelectorFunctionKeys.appendKeyExtractor(input, keys);
+ TypeInformation<Tuple2<K, T>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
+ Operator<Tuple2<K, T>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
PlanUnwrappingReduceOperator<T, K> reducer = new PlanUnwrappingReduceOperator<>(function, keys, name, inputType, typeInfoWithKey);
reducer.setInput(keyedInput);
reducer.setParallelism(parallelism);
- return SelectorFunctionKeys.appendKeyRemover(reducer, keys);
+ return KeyFunctions.appendKeyRemover(reducer, keys);
}
}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/SortPartitionOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/SortPartitionOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/SortPartitionOperator.java
index d65bc68..c8a8684 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/SortPartitionOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/SortPartitionOperator.java
@@ -19,6 +19,7 @@
package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.InvalidProgramException;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.operators.Ordering;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/SortedGrouping.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/SortedGrouping.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/SortedGrouping.java
index 07d0b9a..2453f1b 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/SortedGrouping.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/SortedGrouping.java
@@ -19,6 +19,7 @@
package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.functions.GroupCombineFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Ordering;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.Utils;
@@ -31,7 +32,7 @@ import org.apache.flink.api.common.functions.GroupReduceFunction;
import org.apache.flink.api.common.functions.Partitioner;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.java.DataSet;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
import org.apache.flink.api.java.typeutils.TypeExtractor;
import com.google.common.base.Preconditions;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/UdfOperatorUtils.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/UdfOperatorUtils.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/UdfOperatorUtils.java
index c55d919..6144975 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/UdfOperatorUtils.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/UdfOperatorUtils.java
@@ -22,6 +22,7 @@ import org.apache.flink.api.common.CodeAnalysisMode;
import org.apache.flink.api.common.functions.Function;
import org.apache.flink.api.common.functions.InvalidTypesException;
import org.apache.flink.api.common.operators.DualInputSemanticProperties;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.SingleInputSemanticProperties;
import org.apache.flink.api.java.functions.FunctionAnnotation;
import org.apache.flink.api.java.sca.CodeAnalyzerException;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/UnsortedGrouping.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/UnsortedGrouping.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/UnsortedGrouping.java
index 5b0a368..4e6f6ff 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/UnsortedGrouping.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/UnsortedGrouping.java
@@ -23,6 +23,7 @@ import org.apache.flink.api.common.functions.GroupCombineFunction;
import org.apache.flink.api.common.functions.GroupReduceFunction;
import org.apache.flink.api.common.functions.Partitioner;
import org.apache.flink.api.common.functions.ReduceFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.DataSet;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/join/JoinOperatorSetsBase.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/join/JoinOperatorSetsBase.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/join/JoinOperatorSetsBase.java
index e14e06d..734456c 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/join/JoinOperatorSetsBase.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/join/JoinOperatorSetsBase.java
@@ -28,7 +28,7 @@ import org.apache.flink.api.java.Utils;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.operators.JoinOperator.DefaultJoin;
import org.apache.flink.api.java.operators.JoinOperator.EquiJoin;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.typeutils.TypeExtractor;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanBothUnwrappingCoGroupOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanBothUnwrappingCoGroupOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanBothUnwrappingCoGroupOperator.java
index fb74d1e..f620e11 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanBothUnwrappingCoGroupOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanBothUnwrappingCoGroupOperator.java
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.functions.CoGroupFunction;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
import org.apache.flink.api.common.operators.base.CoGroupOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanLeftUnwrappingCoGroupOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanLeftUnwrappingCoGroupOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanLeftUnwrappingCoGroupOperator.java
index 2c62732..2307c0c 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanLeftUnwrappingCoGroupOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanLeftUnwrappingCoGroupOperator.java
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.functions.CoGroupFunction;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
import org.apache.flink.api.common.operators.base.CoGroupOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanRightUnwrappingCoGroupOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanRightUnwrappingCoGroupOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanRightUnwrappingCoGroupOperator.java
index 56f34cc..30e28eb 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanRightUnwrappingCoGroupOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanRightUnwrappingCoGroupOperator.java
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.functions.CoGroupFunction;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
import org.apache.flink.api.common.operators.base.CoGroupOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingGroupCombineOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingGroupCombineOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingGroupCombineOperator.java
index c8e40ce..95b5840 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingGroupCombineOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingGroupCombineOperator.java
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.functions.GroupCombineFunction;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.GroupCombineOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceGroupOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceGroupOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceGroupOperator.java
index 72b79a4..21f15d4 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceGroupOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceGroupOperator.java
@@ -23,7 +23,7 @@ import org.apache.flink.api.common.functions.GroupReduceFunction;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.GroupReduceOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceOperator.java
index 2aa8d54..e85bb79 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingReduceOperator.java
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.ReduceOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple2;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedGroupCombineOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedGroupCombineOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedGroupCombineOperator.java
index e52a5c4..46773fa 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedGroupCombineOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedGroupCombineOperator.java
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.functions.GroupCombineFunction;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.GroupCombineOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedReduceGroupOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedReduceGroupOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedReduceGroupOperator.java
index 278d706..f0e8055 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedReduceGroupOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/translation/PlanUnwrappingSortedReduceGroupOperator.java
@@ -23,7 +23,7 @@ import org.apache.flink.api.common.functions.GroupReduceFunction;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.GroupReduceOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.util.Collector;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/sca/UdfAnalyzer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/sca/UdfAnalyzer.java b/flink-java/src/main/java/org/apache/flink/api/java/sca/UdfAnalyzer.java
index 1f4b44a..93cba33 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/sca/UdfAnalyzer.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/sca/UdfAnalyzer.java
@@ -32,8 +32,8 @@ import org.apache.flink.api.common.operators.SemanticProperties;
import org.apache.flink.api.common.operators.SingleInputSemanticProperties;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.functions.SemanticPropUtil;
-import org.apache.flink.api.java.operators.Keys;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.operators.Keys;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
import org.apache.flink.api.java.sca.TaggedValue.Input;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.MethodNode;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java
deleted file mode 100644
index 5f74513..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java
+++ /dev/null
@@ -1,78 +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.java.typeutils;
-
-import org.apache.avro.specific.SpecificRecordBase;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Special type information to generate a special AvroTypeInfo for Avro POJOs (implementing SpecificRecordBase, the typed Avro POJOs)
- *
- * Proceeding: It uses a regular pojo type analysis and replaces all {@code GenericType<CharSequence>}
- * with a {@code GenericType<avro.Utf8>}.
- * All other types used by Avro are standard Java types.
- * Only strings are represented as CharSequence fields and represented as Utf8 classes at runtime.
- * CharSequence is not comparable. To make them nicely usable with field expressions, we replace them here
- * by generic type infos containing Utf8 classes (which are comparable),
- *
- * This class is checked by the AvroPojoTest.
- * @param <T>
- */
-public class AvroTypeInfo<T extends SpecificRecordBase> extends PojoTypeInfo<T> {
- public AvroTypeInfo(Class<T> typeClass) {
- super(typeClass, generateFieldsFromAvroSchema(typeClass));
- }
-
- private static <T extends SpecificRecordBase> List<PojoField> generateFieldsFromAvroSchema(Class<T> typeClass) {
- PojoTypeExtractor pte = new PojoTypeExtractor();
- TypeInformation ti = pte.analyzePojo(typeClass, new ArrayList<Type>(), null, null, null);
-
- if(!(ti instanceof PojoTypeInfo)) {
- throw new IllegalStateException("Expecting type to be a PojoTypeInfo");
- }
- PojoTypeInfo pti = (PojoTypeInfo) ti;
- List<PojoField> newFields = new ArrayList<PojoField>(pti.getTotalFields());
-
- for(int i = 0; i < pti.getArity(); i++) {
- PojoField f = pti.getPojoFieldAt(i);
- TypeInformation newType = f.getTypeInformation();
- // check if type is a CharSequence
- if(newType instanceof GenericTypeInfo) {
- if((newType).getTypeClass().equals(CharSequence.class)) {
- // replace the type by a org.apache.avro.util.Utf8
- newType = new GenericTypeInfo(org.apache.avro.util.Utf8.class);
- }
- }
- PojoField newField = new PojoField(f.getField(), newType);
- newFields.add(newField);
- }
- return newFields;
- }
-
- private static class PojoTypeExtractor extends TypeExtractor {
- private PojoTypeExtractor() {
- super();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/Either.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/Either.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/Either.java
deleted file mode 100644
index 8382831..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/Either.java
+++ /dev/null
@@ -1,185 +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.java.typeutils;
-
-/**
- * This type represents a value of one two possible types, Left or Right (a
- * disjoint union), inspired by Scala's Either type.
- *
- * @param <L>
- * the type of Left
- * @param <R>
- * the type of Right
- */
-public abstract class Either<L, R> {
-
- /**
- * Create a Left value of Either
- */
- public static <L, R> Either<L, R> Left(L value) {
- return new Left<L, R>(value);
- }
-
- /**
- * Create a Right value of Either
- */
- public static <L, R> Either<L, R> Right(R value) {
- return new Right<L, R>(value);
- }
-
- /**
- * Retrieve the Left value of Either.
- *
- * @return the Left value
- * @throws IllegalStateException
- * if called on a Right
- */
- public abstract L left() throws IllegalStateException;
-
- /**
- * Retrieve the Right value of Either.
- *
- * @return the Right value
- * @throws IllegalStateException
- * if called on a Left
- */
- public abstract R right() throws IllegalStateException;
-
- /**
- *
- * @return true if this is a Left value, false if this is a Right value
- */
- public final boolean isLeft() {
- return getClass() == Left.class;
- }
-
- /**
- *
- * @return true if this is a Right value, false if this is a Left value
- */
- public final boolean isRight() {
- return getClass() == Right.class;
- }
-
- /**
- * A left value of {@link Either}
- *
- * @param <L>
- * the type of Left
- * @param <R>
- * the type of Right
- */
- public static class Left<L, R> extends Either<L, R> {
- private final L value;
-
- public Left(L value) {
- this.value = java.util.Objects.requireNonNull(value);
- }
-
- @Override
- public L left() {
- return value;
- }
-
- @Override
- public R right() {
- throw new IllegalStateException("Cannot retrieve Right value on a Left");
- }
-
- @Override
- public boolean equals(Object object) {
- if (object instanceof Left<?, ?>) {
- final Left<?, ?> other = (Left<?, ?>) object;
- return value.equals(other.value);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return value.hashCode();
- }
-
- @Override
- public String toString() {
- return "Left(" + value.toString() + ")";
- }
-
- /**
- * Creates a left value of {@link Either}
- *
- */
- public static <L, R> Left<L, R> of(L left) {
- return new Left<L, R>(left);
- }
- }
-
- /**
- * A right value of {@link Either}
- *
- * @param <L>
- * the type of Left
- * @param <R>
- * the type of Right
- */
- public static class Right<L, R> extends Either<L, R> {
- private final R value;
-
- public Right(R value) {
- this.value = java.util.Objects.requireNonNull(value);
- }
-
- @Override
- public L left() {
- throw new IllegalStateException("Cannot retrieve Left value on a Right");
- }
-
- @Override
- public R right() {
- return value;
- }
-
- @Override
- public boolean equals(Object object) {
- if (object instanceof Right<?, ?>) {
- final Right<?, ?> other = (Right<?, ?>) object;
- return value.equals(other.value);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return value.hashCode();
- }
-
- @Override
- public String toString() {
- return "Right(" + value.toString() + ")";
- }
-
- /**
- * Creates a right value of {@link Either}
- *
- */
- public static <L, R> Right<L, R> of(R right) {
- return new Right<L, R>(right);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java
deleted file mode 100644
index ec7be97..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java
+++ /dev/null
@@ -1,121 +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.java.typeutils;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.EitherSerializer;
-
-/**
- * A {@link TypeInformation} for the {@link Either} type of the Java API.
- *
- * @param <L> the Left value type
- * @param <R> the Right value type
- */
-public class EitherTypeInfo<L, R> extends TypeInformation<Either<L, R>> {
-
- private static final long serialVersionUID = 1L;
-
- private final TypeInformation<L> leftType;
-
- private final TypeInformation<R> rightType;
-
- public EitherTypeInfo(TypeInformation<L> leftType, TypeInformation<R> rightType) {
- this.leftType = leftType;
- this.rightType = rightType;
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public int getArity() {
- return 1;
- }
-
- @Override
- public int getTotalFields() {
- return 1;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<Either<L, R>> getTypeClass() {
- return (Class<Either<L, R>>) (Class<?>) Either.class;
- }
-
- @Override
- public boolean isKeyType() {
- return false;
- }
-
- @Override
- public TypeSerializer<Either<L, R>> createSerializer(ExecutionConfig config) {
- return new EitherSerializer<L, R>(leftType.createSerializer(config),
- rightType.createSerializer(config));
- }
-
- @Override
- public String toString() {
- return "Either <" + leftType.toString() + ", " + rightType.toString() + ">";
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EitherTypeInfo) {
- EitherTypeInfo<L, R> other = (EitherTypeInfo<L, R>) obj;
-
- return other.canEqual(this) &&
- leftType.equals(other.leftType) &&
- rightType.equals(other.rightType);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return 17 * leftType.hashCode() + rightType.hashCode();
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof EitherTypeInfo;
- }
-
- // --------------------------------------------------------------------------------------------
-
- public TypeInformation<L> getLeftType() {
- return leftType;
- }
-
- public TypeInformation<R> getRightType() {
- return rightType;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java
deleted file mode 100644
index de59c36..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java
+++ /dev/null
@@ -1,122 +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.java.typeutils;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.AtomicType;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.EnumComparator;
-import org.apache.flink.api.common.typeutils.base.EnumSerializer;
-
-/**
- * A {@link TypeInformation} for java enumeration types.
- *
- * @param <T> The type represented by this type information.
- */
-public class EnumTypeInfo<T extends Enum<T>> extends TypeInformation<T> implements AtomicType<T> {
-
- private static final long serialVersionUID = 8936740290137178660L;
-
- private final Class<T> typeClass;
-
- public EnumTypeInfo(Class<T> typeClass) {
- Preconditions.checkNotNull(typeClass, "Enum type class must not be null.");
-
- if (!Enum.class.isAssignableFrom(typeClass) ) {
- throw new IllegalArgumentException("EnumTypeInfo can only be used for subclasses of " + Enum.class.getName());
- }
-
- this.typeClass = typeClass;
- }
-
- @Override
- public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
- return new EnumComparator<T>(sortOrderAscending);
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public int getArity() {
- return 1;
- }
-
- @Override
- public int getTotalFields() {
- return 1;
- }
-
- @Override
- public Class<T> getTypeClass() {
- return this.typeClass;
- }
-
- @Override
- public boolean isKeyType() {
- return true;
- }
-
- @Override
- public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
- return new EnumSerializer<T>(typeClass);
- }
-
- // ------------------------------------------------------------------------
- // Standard utils
- // ------------------------------------------------------------------------
-
- @Override
- public String toString() {
- return "EnumTypeInfo<" + typeClass.getName() + ">";
- }
-
- @Override
- public int hashCode() {
- return typeClass.hashCode();
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof EnumTypeInfo;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EnumTypeInfo) {
- @SuppressWarnings("unchecked")
- EnumTypeInfo<T> enumTypeInfo = (EnumTypeInfo<T>) obj;
-
- return enumTypeInfo.canEqual(this) &&
- typeClass == enumTypeInfo.typeClass;
- } else {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java
deleted file mode 100644
index 7e7aa68..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java
+++ /dev/null
@@ -1,116 +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.java.typeutils;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.AtomicType;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.GenericTypeComparator;
-import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
-
-
-public class GenericTypeInfo<T> extends TypeInformation<T> implements AtomicType<T> {
-
- private static final long serialVersionUID = -7959114120287706504L;
-
- private final Class<T> typeClass;
-
- public GenericTypeInfo(Class<T> typeClass) {
- this.typeClass = Preconditions.checkNotNull(typeClass);
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public int getArity() {
- return 1;
- }
-
- @Override
- public int getTotalFields() {
- return 1;
- }
-
- @Override
- public Class<T> getTypeClass() {
- return typeClass;
- }
-
- @Override
- public boolean isKeyType() {
- return Comparable.class.isAssignableFrom(typeClass);
- }
-
- @Override
- public TypeSerializer<T> createSerializer(ExecutionConfig config) {
- return new KryoSerializer<T>(this.typeClass, config);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
- if (isKeyType()) {
- @SuppressWarnings("rawtypes")
- GenericTypeComparator comparator = new GenericTypeComparator(sortOrderAscending, createSerializer(executionConfig), this.typeClass);
- return (TypeComparator<T>) comparator;
- }
-
- throw new UnsupportedOperationException("Types that do not implement java.lang.Comparable cannot be used as keys.");
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return typeClass.hashCode();
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof GenericTypeInfo;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof GenericTypeInfo) {
- @SuppressWarnings("unchecked")
- GenericTypeInfo<T> genericTypeInfo = (GenericTypeInfo<T>) obj;
-
- return typeClass == genericTypeInfo.typeClass;
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return "GenericType<" + typeClass.getCanonicalName() + ">";
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java
deleted file mode 100644
index f8b4247..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java
+++ /dev/null
@@ -1,42 +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.java.typeutils;
-
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-
-/**
- * {@link org.apache.flink.api.common.io.OutputFormat}s can implement this interface to be configured
- * with the data type they will operate on. The method {@link #setInputType(org.apache.flink.api
- * .common.typeinfo.TypeInformation, org.apache.flink.api.common.ExecutionConfig)} will be
- * called when the output format is used with an output method such as
- * {@link org.apache.flink.api.java.DataSet#output(org.apache.flink.api.common.io.OutputFormat)}.
- */
-public interface InputTypeConfigurable {
-
- /**
- * Method that is called on an {@link org.apache.flink.api.common.io.OutputFormat} when it is passed to
- * the DataSet's output method. May be used to configures the output format based on the data type.
- *
- * @param type The data type of the input.
- * @param executionConfig
- */
- void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig);
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java
deleted file mode 100644
index 1dd7f01..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java
+++ /dev/null
@@ -1,121 +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.java.typeutils;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-/**
- * A special type information signifying that the type extraction failed. It contains
- * additional error information.
- */
-public class MissingTypeInfo extends TypeInformation<InvalidTypesException> {
-
- private static final long serialVersionUID = -4212082837126702723L;
-
- private final String functionName;
- private final InvalidTypesException typeException;
-
-
- public MissingTypeInfo(String functionName) {
- this(functionName, new InvalidTypesException("An unknown error occured."));
- }
-
- public MissingTypeInfo(String functionName, InvalidTypesException typeException) {
- this.functionName = functionName;
- this.typeException = typeException;
- }
-
- // --------------------------------------------------------------------------------------------
-
- public String getFunctionName() {
- return functionName;
- }
-
- public InvalidTypesException getTypeException() {
- return typeException;
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean isBasicType() {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-
- @Override
- public boolean isTupleType() {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-
- @Override
- public int getArity() {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-
- @Override
- public Class<InvalidTypesException> getTypeClass() {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-
- @Override
- public boolean isKeyType() {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-
- @Override
- public TypeSerializer<InvalidTypesException> createSerializer(ExecutionConfig executionConfig) {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "<" + functionName + ", " + typeException.getMessage() + ">";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MissingTypeInfo) {
- MissingTypeInfo missingTypeInfo = (MissingTypeInfo) obj;
-
- return missingTypeInfo.canEqual(this) &&
- functionName.equals(missingTypeInfo.functionName) &&
- typeException.equals(missingTypeInfo.typeException);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return 31 * functionName.hashCode() + typeException.hashCode();
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof MissingTypeInfo;
- }
-
- @Override
- public int getTotalFields() {
- throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
deleted file mode 100644
index 150c976..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
+++ /dev/null
@@ -1,141 +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.java.typeutils;
-
-import java.lang.reflect.Array;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.GenericArraySerializer;
-
-public class ObjectArrayTypeInfo<T, C> extends TypeInformation<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> arrayType;
- private final TypeInformation<C> componentInfo;
-
- private ObjectArrayTypeInfo(Class<T> arrayType, TypeInformation<C> componentInfo) {
- this.arrayType = Preconditions.checkNotNull(arrayType);
- this.componentInfo = Preconditions.checkNotNull(componentInfo);
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public int getArity() {
- return 1;
- }
-
- @Override
- public int getTotalFields() {
- return 1;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<T> getTypeClass() {
- return arrayType;
- }
-
- public TypeInformation<C> getComponentInfo() {
- return componentInfo;
- }
-
- @Override
- public boolean isKeyType() {
- return false;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
- return (TypeSerializer<T>) new GenericArraySerializer<C>(
- componentInfo.getTypeClass(),
- componentInfo.createSerializer(executionConfig));
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName() + "<" + this.componentInfo + ">";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ObjectArrayTypeInfo) {
- @SuppressWarnings("unchecked")
- ObjectArrayTypeInfo<T, C> objectArrayTypeInfo = (ObjectArrayTypeInfo<T, C>)obj;
-
- return objectArrayTypeInfo.canEqual(this) &&
- arrayType == objectArrayTypeInfo.arrayType &&
- componentInfo.equals(objectArrayTypeInfo.componentInfo);
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof ObjectArrayTypeInfo;
- }
-
- @Override
- public int hashCode() {
- return 31 * this.arrayType.hashCode() + this.componentInfo.hashCode();
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static <T, C> ObjectArrayTypeInfo<T, C> getInfoFor(Class<T> arrayClass, TypeInformation<C> componentInfo) {
- Preconditions.checkNotNull(arrayClass);
- Preconditions.checkNotNull(componentInfo);
- Preconditions.checkArgument(arrayClass.isArray(), "Class " + arrayClass + " must be an array.");
-
- return new ObjectArrayTypeInfo<T, C>(arrayClass, componentInfo);
- }
-
- /**
- * Creates a new {@link org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo} from a
- * {@link TypeInformation} for the component type.
- *
- * <p>
- * This must be used in cases where the complete type of the array is not available as a
- * {@link java.lang.reflect.Type} or {@link java.lang.Class}.
- */
- @SuppressWarnings("unchecked")
- public static <T, C> ObjectArrayTypeInfo<T, C> getInfoFor(TypeInformation<C> componentInfo) {
- Preconditions.checkNotNull(componentInfo);
-
- return new ObjectArrayTypeInfo<T, C>(
- (Class<T>)Array.newInstance(componentInfo.getTypeClass(), 0).getClass(),
- componentInfo);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java
deleted file mode 100644
index 1b008c0..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java
+++ /dev/null
@@ -1,108 +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.java.typeutils;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.Objects;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-
-/**
- * Represent a field definition for {@link PojoTypeInfo} type of objects.
- */
-public class PojoField implements Serializable {
-
- private static final long serialVersionUID = 1975295846436559363L;
-
- private transient Field field;
- private final TypeInformation<?> type;
-
- public PojoField(Field field, TypeInformation<?> type) {
- this.field = Preconditions.checkNotNull(field);
- this.type = Preconditions.checkNotNull(type);
- }
-
- public Field getField() {
- return field;
- }
-
- public TypeInformation<?> getTypeInformation() {
- return type;
- }
-
- private void writeObject(ObjectOutputStream out)
- throws IOException, ClassNotFoundException {
- out.defaultWriteObject();
- out.writeObject(field.getDeclaringClass());
- out.writeUTF(field.getName());
- }
-
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- Class<?> clazz = (Class<?>)in.readObject();
- String fieldName = in.readUTF();
- field = null;
- // try superclasses as well
- while (clazz != null) {
- try {
- field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- break;
- } catch (NoSuchFieldException e) {
- clazz = clazz.getSuperclass();
- }
- }
- if (field == null) {
- throw new RuntimeException("Class resolved at TaskManager is not compatible with class read during Plan setup."
- + " (" + fieldName + ")");
- }
- }
-
- @Override
- public String toString() {
- return "PojoField " + field.getDeclaringClass() + "." + field.getName() + " (" + type + ")";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof PojoField) {
- PojoField other = (PojoField) obj;
-
- return other.canEqual(this) && type.equals(other.type) &&
- Objects.equals(field, other.field);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(field, type);
- }
-
- public boolean canEqual(Object obj) {
- return obj instanceof PojoField;
- }
-}
\ No newline at end of file
[20/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java
new file mode 100644
index 0000000..b89a830
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java
@@ -0,0 +1,383 @@
+ /*
+ * 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.java.typeutils;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.types.Value;
+
+
+public class TypeInfoParser {
+ private static final String TUPLE_PACKAGE = "org.apache.flink.api.java.tuple";
+ private static final String VALUE_PACKAGE = "org.apache.flink.types";
+ private static final String WRITABLE_PACKAGE = "org.apache.hadoop.io";
+
+ private static final Pattern tuplePattern = Pattern.compile("^(" + TUPLE_PACKAGE.replaceAll("\\.", "\\\\.") + "\\.)?((Tuple[1-9][0-9]?)<|(Tuple0))");
+ private static final Pattern writablePattern = Pattern.compile("^((" + WRITABLE_PACKAGE.replaceAll("\\.", "\\\\.") + "\\.)?Writable)<([^\\s,>]*)(,|>|$|\\[)");
+ private static final Pattern enumPattern = Pattern.compile("^((java\\.lang\\.)?Enum)<([^\\s,>]*)(,|>|$|\\[)");
+ private static final Pattern basicTypePattern = Pattern
+ .compile("^((java\\.lang\\.)?(String|Integer|Byte|Short|Character|Double|Float|Long|Boolean|Void))(,|>|$|\\[)");
+ private static final Pattern basicTypeDatePattern = Pattern.compile("^((java\\.util\\.)?Date)(,|>|$|\\[)");
+ private static final Pattern primitiveTypePattern = Pattern.compile("^(int|byte|short|char|double|float|long|boolean|void)(,|>|$|\\[)");
+ private static final Pattern valueTypePattern = Pattern.compile("^((" + VALUE_PACKAGE.replaceAll("\\.", "\\\\.")
+ + "\\.)?(String|Int|Byte|Short|Char|Double|Float|Long|Boolean|List|Map|Null))Value(,|>|$|\\[)");
+ private static final Pattern pojoGenericObjectPattern = Pattern.compile("^([^\\s,<>\\[]+)(<)?");
+ private static final Pattern fieldPattern = Pattern.compile("^([^\\s,<>\\[]+)=");
+
+ /**
+ * Generates an instance of <code>TypeInformation</code> by parsing a type
+ * information string. A type information string can contain the following
+ * types:
+ *
+ * <ul>
+ * <li>Basic types such as <code>Integer</code>, <code>String</code>, etc.
+ * <li>Basic type arrays such as <code>Integer[]</code>,
+ * <code>String[]</code>, etc.
+ * <li>Tuple types such as <code>Tuple1<TYPE0></code>,
+ * <code>Tuple2<TYPE0, TYPE1></code>, etc.</li>
+ * <li>Pojo types such as <code>org.my.MyPojo<myFieldName=TYPE0,myFieldName2=TYPE1></code>, etc.</li>
+ * <li>Generic types such as <code>java.lang.Class</code>, etc.
+ * <li>Custom type arrays such as <code>org.my.CustomClass[]</code>,
+ * <code>org.my.CustomClass$StaticInnerClass[]</code>, etc.
+ * <li>Value types such as <code>DoubleValue</code>,
+ * <code>StringValue</code>, <code>IntegerValue</code>, etc.</li>
+ * <li>Tuple array types such as <code>Tuple2<TYPE0,TYPE1>[], etc.</code></li>
+ * <li>Writable types such as <code>Writable<org.my.CustomWritable></code></li>
+ * <li>Enum types such as <code>Enum<org.my.CustomEnum></code></li>
+ * </ul>
+ *
+ * Example:
+ * <code>"Tuple2<String,Tuple2<Integer,org.my.MyJob$Pojo<word=String>>>"</code>
+ *
+ * @param infoString
+ * type information string to be parsed
+ * @return <code>TypeInformation</code> representation of the string
+ */
+ @SuppressWarnings("unchecked")
+ public static <X> TypeInformation<X> parse(String infoString) {
+ try {
+ if (infoString == null) {
+ throw new IllegalArgumentException("String is null.");
+ }
+ String clearedString = infoString.replaceAll("\\s", "");
+ if (clearedString.length() == 0) {
+ throw new IllegalArgumentException("String must not be empty.");
+ }
+ StringBuilder sb = new StringBuilder(clearedString);
+ TypeInformation<X> ti = (TypeInformation<X>) parse(sb);
+ if (sb.length() > 0) {
+ throw new IllegalArgumentException("String could not be parsed completely.");
+ }
+ return ti;
+ } catch (Exception e) {
+ throw new IllegalArgumentException("String could not be parsed: " + e.getMessage(), e);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private static TypeInformation<?> parse(StringBuilder sb) throws ClassNotFoundException {
+ String infoString = sb.toString();
+ final Matcher tupleMatcher = tuplePattern.matcher(infoString);
+
+ final Matcher writableMatcher = writablePattern.matcher(infoString);
+ final Matcher enumMatcher = enumPattern.matcher(infoString);
+
+ final Matcher basicTypeMatcher = basicTypePattern.matcher(infoString);
+ final Matcher basicTypeDateMatcher = basicTypeDatePattern.matcher(infoString);
+
+ final Matcher primitiveTypeMatcher = primitiveTypePattern.matcher(infoString);
+
+ final Matcher valueTypeMatcher = valueTypePattern.matcher(infoString);
+
+ final Matcher pojoGenericMatcher = pojoGenericObjectPattern.matcher(infoString);
+
+ if (infoString.length() == 0) {
+ return null;
+ }
+
+ TypeInformation<?> returnType = null;
+ boolean isPrimitiveType = false;
+
+ // tuples
+ if (tupleMatcher.find()) {
+ boolean isGenericTuple = true;
+ String className = tupleMatcher.group(3);
+ if(className == null) { // matched Tuple0
+ isGenericTuple = false;
+ className = tupleMatcher.group(2);
+ sb.delete(0, className.length());
+ } else {
+ sb.delete(0, className.length() + 1); // +1 for "<"
+ }
+
+ if (infoString.startsWith(TUPLE_PACKAGE)) {
+ sb.delete(0, TUPLE_PACKAGE.length() + 1); // +1 for trailing "."
+ }
+
+ int arity = Integer.parseInt(className.replaceAll("\\D", ""));
+ Class<?> clazz = loadClass(TUPLE_PACKAGE + "." + className);
+
+ TypeInformation<?>[] types = new TypeInformation<?>[arity];
+ for (int i = 0; i < arity; i++) {
+ types[i] = parse(sb);
+ if (types[i] == null) {
+ throw new IllegalArgumentException("Tuple arity does not match given parameters.");
+ }
+ }
+ if (isGenericTuple) {
+ if(sb.charAt(0) != '>') {
+ throw new IllegalArgumentException("Tuple arity does not match given parameters.");
+ }
+ // remove '>'
+ sb.deleteCharAt(0);
+ }
+ returnType = new TupleTypeInfo(clazz, types);
+ }
+ // writable types
+ else if (writableMatcher.find()) {
+ String className = writableMatcher.group(1);
+ String fullyQualifiedName = writableMatcher.group(3);
+ sb.delete(0, className.length() + 1 + fullyQualifiedName.length() + 1);
+ Class<?> clazz = loadClass(fullyQualifiedName);
+ returnType = WritableTypeInfo.getWritableTypeInfo((Class) clazz);
+ }
+ // enum types
+ else if (enumMatcher.find()) {
+ String className = enumMatcher.group(1);
+ String fullyQualifiedName = enumMatcher.group(3);
+ sb.delete(0, className.length() + 1 + fullyQualifiedName.length() + 1);
+ Class<?> clazz = loadClass(fullyQualifiedName);
+ returnType = new EnumTypeInfo(clazz);
+ }
+ // basic types
+ else if (basicTypeMatcher.find()) {
+ String className = basicTypeMatcher.group(1);
+ sb.delete(0, className.length());
+ Class<?> clazz;
+ // check if fully qualified
+ if (className.startsWith("java.lang")) {
+ clazz = loadClass(className);
+ } else {
+ clazz = loadClass("java.lang." + className);
+ }
+ returnType = BasicTypeInfo.getInfoFor(clazz);
+ }
+ // special basic type "Date"
+ else if (basicTypeDateMatcher.find()) {
+ String className = basicTypeDateMatcher.group(1);
+ sb.delete(0, className.length());
+ Class<?> clazz;
+ // check if fully qualified
+ if (className.startsWith("java.util")) {
+ clazz = loadClass(className);
+ } else {
+ clazz = loadClass("java.util." + className);
+ }
+ returnType = BasicTypeInfo.getInfoFor(clazz);
+ }
+ // primitive types
+ else if (primitiveTypeMatcher.find()) {
+ String keyword = primitiveTypeMatcher.group(1);
+ sb.delete(0, keyword.length());
+
+ Class<?> clazz = null;
+ if (keyword.equals("int")) {
+ clazz = int.class;
+ } else if (keyword.equals("byte")) {
+ clazz = byte.class;
+ } else if (keyword.equals("short")) {
+ clazz = short.class;
+ } else if (keyword.equals("char")) {
+ clazz = char.class;
+ } else if (keyword.equals("double")) {
+ clazz = double.class;
+ } else if (keyword.equals("float")) {
+ clazz = float.class;
+ } else if (keyword.equals("long")) {
+ clazz = long.class;
+ } else if (keyword.equals("boolean")) {
+ clazz = boolean.class;
+ } else if (keyword.equals("void")) {
+ clazz = void.class;
+ }
+ returnType = BasicTypeInfo.getInfoFor(clazz);
+ isPrimitiveType = true;
+ }
+ // values
+ else if (valueTypeMatcher.find()) {
+ String className = valueTypeMatcher.group(1);
+ sb.delete(0, className.length() + 5);
+
+ Class<?> clazz;
+ // check if fully qualified
+ if (className.startsWith(VALUE_PACKAGE)) {
+ clazz = loadClass(className + "Value");
+ } else {
+ clazz = loadClass(VALUE_PACKAGE + "." + className + "Value");
+ }
+ returnType = ValueTypeInfo.getValueTypeInfo((Class<Value>) clazz);
+ }
+ // pojo objects or generic types
+ else if (pojoGenericMatcher.find()) {
+ String fullyQualifiedName = pojoGenericMatcher.group(1);
+ sb.delete(0, fullyQualifiedName.length());
+
+ boolean isPojo = pojoGenericMatcher.group(2) != null;
+
+ // pojo
+ if (isPojo) {
+ sb.deleteCharAt(0);
+ Class<?> clazz = loadClass(fullyQualifiedName);
+
+ ArrayList<PojoField> fields = new ArrayList<PojoField>();
+ while (sb.charAt(0) != '>') {
+ final Matcher fieldMatcher = fieldPattern.matcher(sb);
+ if (!fieldMatcher.find()) {
+ throw new IllegalArgumentException("Field name missing.");
+ }
+ String fieldName = fieldMatcher.group(1);
+ sb.delete(0, fieldName.length() + 1);
+
+ Field field = TypeExtractor.getDeclaredField(clazz, fieldName);
+ if (field == null) {
+ throw new IllegalArgumentException("Field '" + fieldName + "'could not be accessed.");
+ }
+ fields.add(new PojoField(field, parse(sb)));
+ }
+ sb.deleteCharAt(0); // remove '>'
+ returnType = new PojoTypeInfo(clazz, fields);
+ }
+ // generic type
+ else {
+ returnType = new GenericTypeInfo(loadClass(fullyQualifiedName));
+ }
+ }
+
+ if (returnType == null) {
+ throw new IllegalArgumentException("Error at '" + infoString + "'");
+ }
+
+ // arrays
+ int arrayDimensionCount = 0;
+ while (sb.length() > 1 && sb.charAt(0) == '[' && sb.charAt(1) == ']') {
+ arrayDimensionCount++;
+ sb.delete(0, 2);
+ }
+
+ if (sb.length() > 0 && sb.charAt(0) == '[') {
+ throw new IllegalArgumentException("Closing square bracket missing.");
+ }
+
+ // construct multidimension array
+ if (arrayDimensionCount > 0) {
+ TypeInformation<?> arrayInfo = null;
+
+ // first dimension
+ // primitive array
+ if (isPrimitiveType) {
+ if (returnType == BasicTypeInfo.INT_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.BYTE_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.SHORT_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.CHAR_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.DOUBLE_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.FLOAT_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.LONG_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
+ arrayInfo = PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.VOID_TYPE_INFO) {
+ throw new IllegalArgumentException("Can not create an array of void.");
+ }
+ }
+ // basic array
+ else if (returnType instanceof BasicTypeInfo
+ && returnType != BasicTypeInfo.DATE_TYPE_INFO) {
+ if (returnType == BasicTypeInfo.INT_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.BYTE_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.BYTE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.SHORT_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.SHORT_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.CHAR_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.CHAR_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.DOUBLE_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.DOUBLE_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.FLOAT_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.FLOAT_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.LONG_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.LONG_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.STRING_TYPE_INFO) {
+ arrayInfo = BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO;
+ } else if (returnType == BasicTypeInfo.VOID_TYPE_INFO) {
+ throw new IllegalArgumentException("Can not create an array of void.");
+ }
+ }
+ // object array
+ else {
+ arrayInfo = ObjectArrayTypeInfo.getInfoFor(loadClass("[L" + returnType.getTypeClass().getName() + ";"),
+ returnType);
+ }
+
+ // further dimensions
+ if (arrayDimensionCount > 1) {
+ String arrayPrefix = "[";
+ for (int i = 1; i < arrayDimensionCount; i++) {
+ arrayPrefix += "[";
+ arrayInfo = ObjectArrayTypeInfo.getInfoFor(loadClass(arrayPrefix + "L" +
+ returnType.getTypeClass().getName() + ";"), arrayInfo);
+ }
+ }
+ returnType = arrayInfo;
+ }
+
+ // remove possible ','
+ if (sb.length() > 0 && sb.charAt(0) == ',') {
+ sb.deleteCharAt(0);
+ }
+
+ // check if end
+ return returnType;
+ }
+
+ private static Class<?> loadClass(String fullyQualifiedName) {
+ try {
+ return Class.forName(fullyQualifiedName);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("Class '" + fullyQualifiedName
+ + "' could not be found. Please note that inner classes must be declared static.");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java
new file mode 100644
index 0000000..5187de7
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java
@@ -0,0 +1,183 @@
+/*
+ * 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.java.typeutils;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.api.common.typeinfo.AtomicType;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.CopyableValueComparator;
+import org.apache.flink.api.java.typeutils.runtime.CopyableValueSerializer;
+import org.apache.flink.api.java.typeutils.runtime.ValueComparator;
+import org.apache.flink.api.java.typeutils.runtime.ValueSerializer;
+import org.apache.flink.types.BooleanValue;
+import org.apache.flink.types.ByteValue;
+import org.apache.flink.types.CharValue;
+import org.apache.flink.types.CopyableValue;
+import org.apache.flink.types.DoubleValue;
+import org.apache.flink.types.FloatValue;
+import org.apache.flink.types.IntValue;
+import org.apache.flink.types.LongValue;
+import org.apache.flink.types.NullValue;
+import org.apache.flink.types.ShortValue;
+import org.apache.flink.types.StringValue;
+import org.apache.flink.types.Value;
+
+/**
+ * Type information for data types that extend the {@link Value} interface. The value
+ * interface allows types to define their custom serialization and deserialization routines.
+ *
+ * @param <T> The type of the class represented by this type information.
+ */
+public class ValueTypeInfo<T extends Value> extends TypeInformation<T> implements AtomicType<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ValueTypeInfo<BooleanValue> BOOLEAN_VALUE_TYPE_INFO = new ValueTypeInfo<>(BooleanValue.class);
+ public static final ValueTypeInfo<ByteValue> BYTE_VALUE_TYPE_INFO = new ValueTypeInfo<>(ByteValue.class);
+ public static final ValueTypeInfo<CharValue> CHAR_VALUE_TYPE_INFO = new ValueTypeInfo<>(CharValue.class);
+ public static final ValueTypeInfo<DoubleValue> DOUBLE_VALUE_TYPE_INFO = new ValueTypeInfo<>(DoubleValue.class);
+ public static final ValueTypeInfo<FloatValue> FLOAT_VALUE_TYPE_INFO = new ValueTypeInfo<>(FloatValue.class);
+ public static final ValueTypeInfo<IntValue> INT_VALUE_TYPE_INFO = new ValueTypeInfo<>(IntValue.class);
+ public static final ValueTypeInfo<LongValue> LONG_VALUE_TYPE_INFO = new ValueTypeInfo<>(LongValue.class);
+ public static final ValueTypeInfo<NullValue> NULL_VALUE_TYPE_INFO = new ValueTypeInfo<>(NullValue.class);
+ public static final ValueTypeInfo<ShortValue> SHORT_VALUE_TYPE_INFO = new ValueTypeInfo<>(ShortValue.class);
+ public static final ValueTypeInfo<StringValue> STRING_VALUE_TYPE_INFO = new ValueTypeInfo<>(StringValue.class);
+
+ private final Class<T> type;
+
+ public ValueTypeInfo(Class<T> type) {
+ this.type = Preconditions.checkNotNull(type);
+
+ Preconditions.checkArgument(
+ Value.class.isAssignableFrom(type) || type.equals(Value.class),
+ "ValueTypeInfo can only be used for subclasses of " + Value.class.getName());
+ }
+
+ @Override
+ public int getArity() {
+ return 1;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return 1;
+ }
+
+ @Override
+ public Class<T> getTypeClass() {
+ return this.type;
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ public boolean isBasicValueType() {
+ return type.equals(StringValue.class) || type.equals(ByteValue.class) || type.equals(ShortValue.class) || type.equals(CharValue.class) ||
+ type.equals(DoubleValue.class) || type.equals(FloatValue.class) || type.equals(IntValue.class) || type.equals(LongValue.class) ||
+ type.equals(NullValue.class) || type.equals(BooleanValue.class);
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public boolean isKeyType() {
+ return Comparable.class.isAssignableFrom(type);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
+ if (CopyableValue.class.isAssignableFrom(type)) {
+ return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
+ }
+ else {
+ return new ValueSerializer<T>(type);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
+ if (!isKeyType()) {
+ throw new RuntimeException("The type " + type.getName() + " is not Comparable.");
+ }
+
+ if (CopyableValue.class.isAssignableFrom(type)) {
+ return (TypeComparator<T>) new CopyableValueComparator(sortOrderAscending, type);
+ }
+ else {
+ return (TypeComparator<T>) new ValueComparator(sortOrderAscending, type);
+ }
+ }
+
+ // utility method to summon the necessary bound
+ private static <X extends CopyableValue<X>> CopyableValueSerializer<X> createCopyableValueSerializer(Class<X> clazz) {
+ return new CopyableValueSerializer<X>(clazz);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return this.type.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ValueTypeInfo) {
+ @SuppressWarnings("unchecked")
+ ValueTypeInfo<T> valueTypeInfo = (ValueTypeInfo<T>) obj;
+
+ return valueTypeInfo.canEqual(this) &&
+ type == valueTypeInfo.type;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof ValueTypeInfo;
+ }
+
+ @Override
+ public String toString() {
+ return "ValueType<" + type.getSimpleName() + ">";
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ static <X extends Value> TypeInformation<X> getValueTypeInfo(Class<X> typeClass) {
+ if (Value.class.isAssignableFrom(typeClass) && !typeClass.equals(Value.class)) {
+ return new ValueTypeInfo<X>(typeClass);
+ }
+ else {
+ throw new InvalidTypesException("The given class is no subclass of " + Value.class.getName());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java
new file mode 100644
index 0000000..6c140d9
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java
@@ -0,0 +1,139 @@
+/*
+ * 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.java.typeutils;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.api.common.typeinfo.AtomicType;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.WritableComparator;
+import org.apache.flink.api.java.typeutils.runtime.WritableSerializer;
+import org.apache.hadoop.io.Writable;
+
+/**
+ * Type information for data types that extend Hadoop's {@link Writable} interface. The Writable
+ * interface defines the serialization and deserialization routines for the data type.
+ *
+ * @param <T> The type of the class represented by this type information.
+ */
+public class WritableTypeInfo<T extends Writable> extends TypeInformation<T> implements AtomicType<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> typeClass;
+
+ public WritableTypeInfo(Class<T> typeClass) {
+ this.typeClass = Preconditions.checkNotNull(typeClass);
+
+ Preconditions.checkArgument(
+ Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class),
+ "WritableTypeInfo can only be used for subclasses of " + Writable.class.getName());
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
+ if(Comparable.class.isAssignableFrom(typeClass)) {
+ return new WritableComparator(sortOrderAscending, typeClass);
+ }
+ else {
+ throw new UnsupportedOperationException("Cannot create Comparator for "+typeClass.getCanonicalName()+". " +
+ "Class does not implement Comparable interface.");
+ }
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return 1;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return 1;
+ }
+
+ @Override
+ public Class<T> getTypeClass() {
+ return this.typeClass;
+ }
+
+ @Override
+ public boolean isKeyType() {
+ return Comparable.class.isAssignableFrom(typeClass);
+ }
+
+ @Override
+ public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
+ return new WritableSerializer<T>(typeClass);
+ }
+
+ @Override
+ public String toString() {
+ return "WritableType<" + typeClass.getName() + ">";
+ }
+
+ @Override
+ public int hashCode() {
+ return typeClass.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof WritableTypeInfo) {
+ @SuppressWarnings("unchecked")
+ WritableTypeInfo<T> writableTypeInfo = (WritableTypeInfo<T>) obj;
+
+ return writableTypeInfo.canEqual(this) &&
+ typeClass == writableTypeInfo.typeClass;
+
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof WritableTypeInfo;
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ static <T extends Writable> TypeInformation<T> getWritableTypeInfo(Class<T> typeClass) {
+ if (Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class)) {
+ return new WritableTypeInfo<T>(typeClass);
+ }
+ else {
+ throw new InvalidTypesException("The given class is no subclass of " + Writable.class.getName());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java
new file mode 100644
index 0000000..bc04367
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java
@@ -0,0 +1,201 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import com.google.common.base.Preconditions;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.reflect.ReflectDatumReader;
+import org.apache.avro.reflect.ReflectDatumWriter;
+import org.apache.avro.util.Utf8;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.kryo.Serializers;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.util.InstantiationUtil;
+
+import com.esotericsoftware.kryo.Kryo;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+
+/**
+ * General purpose serialization. Currently using Apache Avro's Reflect-serializers for serialization and
+ * Kryo for deep object copies. We want to change this to Kryo-only.
+ *
+ * @param <T> The type serialized.
+ */
+public final class AvroSerializer<T> extends TypeSerializer<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> type;
+
+ private final Class<? extends T> typeToInstantiate;
+
+ private transient ReflectDatumWriter<T> writer;
+ private transient ReflectDatumReader<T> reader;
+
+ private transient DataOutputEncoder encoder;
+ private transient DataInputDecoder decoder;
+
+ private transient Kryo kryo;
+
+ private transient T deepCopyInstance;
+
+ // --------------------------------------------------------------------------------------------
+
+ public AvroSerializer(Class<T> type) {
+ this(type, type);
+ }
+
+ public AvroSerializer(Class<T> type, Class<? extends T> typeToInstantiate) {
+ this.type = Preconditions.checkNotNull(type);
+ this.typeToInstantiate = Preconditions.checkNotNull(typeToInstantiate);
+
+ InstantiationUtil.checkForInstantiation(typeToInstantiate);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public AvroSerializer<T> duplicate() {
+ return new AvroSerializer<T>(type, typeToInstantiate);
+ }
+
+ @Override
+ public T createInstance() {
+ return InstantiationUtil.instantiate(this.typeToInstantiate);
+ }
+
+ @Override
+ public T copy(T from) {
+ checkKryoInitialized();
+
+ return KryoUtils.copy(from, kryo, this);
+ }
+
+ @Override
+ public T copy(T from, T reuse) {
+ checkKryoInitialized();
+
+ return KryoUtils.copy(from, reuse, kryo, this);
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+ @Override
+ public void serialize(T value, DataOutputView target) throws IOException {
+ checkAvroInitialized();
+ this.encoder.setOut(target);
+ this.writer.write(value, this.encoder);
+ }
+
+ @Override
+ public T deserialize(DataInputView source) throws IOException {
+ checkAvroInitialized();
+ this.decoder.setIn(source);
+ return this.reader.read(null, this.decoder);
+ }
+
+ @Override
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+ checkAvroInitialized();
+ this.decoder.setIn(source);
+ return this.reader.read(reuse, this.decoder);
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ checkAvroInitialized();
+
+ if (this.deepCopyInstance == null) {
+ this.deepCopyInstance = InstantiationUtil.instantiate(type, Object.class);
+ }
+
+ this.decoder.setIn(source);
+ this.encoder.setOut(target);
+
+ T tmp = this.reader.read(this.deepCopyInstance, this.decoder);
+ this.writer.write(tmp, this.encoder);
+ }
+
+
+ private void checkAvroInitialized() {
+ if (this.reader == null) {
+ this.reader = new ReflectDatumReader<T>(type);
+ this.writer = new ReflectDatumWriter<T>(type);
+ this.encoder = new DataOutputEncoder();
+ this.decoder = new DataInputDecoder();
+ }
+ }
+
+ private void checkKryoInitialized() {
+ if (this.kryo == null) {
+ this.kryo = new Kryo();
+
+ Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
+ instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+ kryo.setInstantiatorStrategy(instantiatorStrategy);
+
+ // register Avro types.
+ this.kryo.register(GenericData.Array.class, new Serializers.SpecificInstanceCollectionSerializerForArrayList());
+ this.kryo.register(Utf8.class);
+ this.kryo.register(GenericData.EnumSymbol.class);
+ this.kryo.register(GenericData.Fixed.class);
+ this.kryo.register(GenericData.StringType.class);
+ this.kryo.setAsmEnabled(true);
+ this.kryo.register(type);
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return 31 * this.type.hashCode() + this.typeToInstantiate.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof AvroSerializer) {
+ @SuppressWarnings("unchecked")
+ AvroSerializer<T> avroSerializer = (AvroSerializer<T>) obj;
+
+ return avroSerializer.canEqual(this) &&
+ type == avroSerializer.type &&
+ typeToInstantiate == avroSerializer.typeToInstantiate;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof AvroSerializer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java
new file mode 100644
index 0000000..9b3b191
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java
@@ -0,0 +1,167 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.types.CopyableValue;
+import org.apache.flink.types.NormalizableKey;
+import org.apache.flink.util.InstantiationUtil;
+
+/**
+ * Comparator for all Value types that extend Key
+ */
+public class CopyableValueComparator<T extends CopyableValue<T> & Comparable<T>> extends TypeComparator<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> type;
+
+ private final boolean ascendingComparison;
+
+ private transient T reference;
+
+ private transient T tempReference;
+
+ private final TypeComparator<?>[] comparators = new TypeComparator[] {this};
+
+ public CopyableValueComparator(boolean ascending, Class<T> type) {
+ this.type = type;
+ this.ascendingComparison = ascending;
+ this.reference = InstantiationUtil.instantiate(type, CopyableValue.class);
+ }
+
+ @Override
+ public int hash(T record) {
+ return record.hashCode();
+ }
+
+ @Override
+ public void setReference(T toCompare) {
+ toCompare.copyTo(reference);
+ }
+
+ @Override
+ public boolean equalToReference(T candidate) {
+ return candidate.equals(this.reference);
+ }
+
+ @Override
+ public int compareToReference(TypeComparator<T> referencedComparator) {
+ T otherRef = ((CopyableValueComparator<T>) referencedComparator).reference;
+ int comp = otherRef.compareTo(reference);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public int compare(T first, T second) {
+ int comp = first.compareTo(second);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
+ if (tempReference == null) {
+ tempReference = InstantiationUtil.instantiate(type, CopyableValue.class);
+ }
+
+ reference.read(firstSource);
+ tempReference.read(secondSource);
+ int comp = reference.compareTo(tempReference);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public boolean supportsNormalizedKey() {
+ return NormalizableKey.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public int getNormalizeKeyLen() {
+ NormalizableKey<?> key = (NormalizableKey<?>) reference;
+ return key.getMaxNormalizedKeyLen();
+ }
+
+ @Override
+ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
+ return keyBytes < getNormalizeKeyLen();
+ }
+
+ @Override
+ public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
+ NormalizableKey<?> key = (NormalizableKey<?>) record;
+ key.copyNormalizedKey(target, offset, numBytes);
+ }
+
+ @Override
+ public boolean invertNormalizedKey() {
+ return !ascendingComparison;
+ }
+
+ @Override
+ public TypeComparator<T> duplicate() {
+ return new CopyableValueComparator<T>(ascendingComparison, type);
+ }
+
+ @Override
+ public int extractKeys(Object record, Object[] target, int index) {
+ target[index] = record;
+ return 1;
+ }
+
+ @Override
+ public TypeComparator<?>[] getFlatComparators() {
+ return comparators;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // unsupported normalization
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean supportsSerializationWithKeyNormalization() {
+ return false;
+ }
+
+ @Override
+ public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // serialization
+ // --------------------------------------------------------------------------------------------
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
+ // read basic object and the type
+ s.defaultReadObject();
+
+ this.reference = InstantiationUtil.instantiate(type, CopyableValue.class);
+ this.tempReference = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java
new file mode 100644
index 0000000..9e46f27
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java
@@ -0,0 +1,129 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.types.CopyableValue;
+import org.apache.flink.util.InstantiationUtil;
+
+
+public class CopyableValueSerializer<T extends CopyableValue<T>> extends TypeSerializer<T> {
+
+ private static final long serialVersionUID = 1L;
+
+
+ private final Class<T> valueClass;
+
+ private transient T instance;
+
+
+ public CopyableValueSerializer(Class<T> valueClass) {
+ this.valueClass = Preconditions.checkNotNull(valueClass);
+ }
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public CopyableValueSerializer<T> duplicate() {
+ return this;
+ }
+
+ @Override
+ public T createInstance() {
+ return InstantiationUtil.instantiate(this.valueClass);
+ }
+
+ @Override
+ public T copy(T from) {
+ return copy(from, createInstance());
+ }
+
+ @Override
+ public T copy(T from, T reuse) {
+ from.copyTo(reuse);
+ return reuse;
+ }
+
+ @Override
+ public int getLength() {
+ ensureInstanceInstantiated();
+ return instance.getBinaryLength();
+ }
+
+ @Override
+ public void serialize(T value, DataOutputView target) throws IOException {
+ value.write(target);
+ }
+
+ @Override
+ public T deserialize(DataInputView source) throws IOException {
+ return deserialize(createInstance(), source);
+ }
+
+ @Override
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+ reuse.read(source);
+ return reuse;
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ ensureInstanceInstantiated();
+ instance.copy(source, target);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ private void ensureInstanceInstantiated() {
+ if (instance == null) {
+ instance = createInstance();
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return this.valueClass.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof CopyableValueSerializer) {
+ @SuppressWarnings("unchecked")
+ CopyableValueSerializer<T> copyableValueSerializer = (CopyableValueSerializer<T>) obj;
+
+ return copyableValueSerializer.canEqual(this) &&
+ valueClass == copyableValueSerializer.valueClass;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof CopyableValueSerializer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java
new file mode 100644
index 0000000..e48f9fa
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java
@@ -0,0 +1,229 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.avro.io.Decoder;
+import org.apache.avro.util.Utf8;
+
+
+public class DataInputDecoder extends Decoder implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private transient Utf8 stringDecoder = new Utf8();
+
+
+ private transient DataInput in;
+
+
+ public void setIn(DataInput in) {
+ this.in = in;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // primitives
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void readNull() {}
+
+
+ @Override
+ public boolean readBoolean() throws IOException {
+ return in.readBoolean();
+ }
+
+ @Override
+ public int readInt() throws IOException {
+ return in.readInt();
+ }
+
+ @Override
+ public long readLong() throws IOException {
+ return in.readLong();
+ }
+
+ @Override
+ public float readFloat() throws IOException {
+ return in.readFloat();
+ }
+
+ @Override
+ public double readDouble() throws IOException {
+ return in.readDouble();
+ }
+
+ @Override
+ public int readEnum() throws IOException {
+ return readInt();
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // bytes
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void readFixed(byte[] bytes, int start, int length) throws IOException {
+ in.readFully(bytes, start, length);
+ }
+
+ @Override
+ public ByteBuffer readBytes(ByteBuffer old) throws IOException {
+ int length = readInt();
+ ByteBuffer result;
+ if (old != null && length <= old.capacity() && old.hasArray()) {
+ result = old;
+ result.clear();
+ } else {
+ result = ByteBuffer.allocate(length);
+ }
+ in.readFully(result.array(), result.arrayOffset() + result.position(), length);
+ result.limit(length);
+ return result;
+ }
+
+
+ @Override
+ public void skipFixed(int length) throws IOException {
+ skipBytes(length);
+ }
+
+ @Override
+ public void skipBytes() throws IOException {
+ int num = readInt();
+ skipBytes(num);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // strings
+ // --------------------------------------------------------------------------------------------
+
+
+ @Override
+ public Utf8 readString(Utf8 old) throws IOException {
+ int length = readInt();
+ Utf8 result = (old != null ? old : new Utf8());
+ result.setByteLength(length);
+
+ if (length > 0) {
+ in.readFully(result.getBytes(), 0, length);
+ }
+
+ return result;
+ }
+
+ @Override
+ public String readString() throws IOException {
+ return readString(stringDecoder).toString();
+ }
+
+ @Override
+ public void skipString() throws IOException {
+ int len = readInt();
+ skipBytes(len);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // collection types
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public long readArrayStart() throws IOException {
+ return readVarLongCount(in);
+ }
+
+ @Override
+ public long arrayNext() throws IOException {
+ return readVarLongCount(in);
+ }
+
+ @Override
+ public long skipArray() throws IOException {
+ return readVarLongCount(in);
+ }
+
+ @Override
+ public long readMapStart() throws IOException {
+ return readVarLongCount(in);
+ }
+
+ @Override
+ public long mapNext() throws IOException {
+ return readVarLongCount(in);
+ }
+
+ @Override
+ public long skipMap() throws IOException {
+ return readVarLongCount(in);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // union
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int readIndex() throws IOException {
+ return readInt();
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // utils
+ // --------------------------------------------------------------------------------------------
+
+ private void skipBytes(int num) throws IOException {
+ while (num > 0) {
+ num -= in.skipBytes(num);
+ }
+ }
+
+ public static long readVarLongCount(DataInput in) throws IOException {
+ long value = in.readUnsignedByte();
+
+ if ((value & 0x80) == 0) {
+ return value;
+ }
+ else {
+ long curr;
+ int shift = 7;
+ value = value & 0x7f;
+ while (((curr = in.readUnsignedByte()) & 0x80) != 0){
+ value |= (curr & 0x7f) << shift;
+ shift += 7;
+ }
+ value |= curr << shift;
+ return value;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // serialization
+ // --------------------------------------------------------------------------------------------
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
+ // Read in size, and any hidden stuff
+ s.defaultReadObject();
+
+ this.stringDecoder = new Utf8();
+ this.in = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java
new file mode 100644
index 0000000..be17d64
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java
@@ -0,0 +1,71 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.core.memory.DataInputView;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An input stream that draws its data from a {@link DataInputView}.
+ */
+public class DataInputViewStream extends InputStream {
+
+ protected DataInputView inputView;
+
+ public DataInputViewStream(DataInputView inputView) {
+ this.inputView = inputView;
+ }
+
+ public DataInputView getInputView(){
+ return inputView;
+ }
+
+ @Override
+ public int read() throws IOException {
+ try {
+ return inputView.readUnsignedByte();
+ } catch(EOFException ex) {
+ return -1;
+ }
+ }
+
+ @Override
+ public long skip(long n) throws IOException {
+ long counter = n;
+ while(counter > Integer.MAX_VALUE) {
+ int skippedBytes = inputView.skipBytes(Integer.MAX_VALUE);
+
+ if (skippedBytes == 0) {
+ return n - counter;
+ }
+
+ counter -= skippedBytes;
+ }
+ return n - counter - inputView.skipBytes((int) counter);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ return inputView.read(b, off, len);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java
new file mode 100644
index 0000000..5c89962
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java
@@ -0,0 +1,190 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.avro.io.Encoder;
+import org.apache.avro.util.Utf8;
+
+
+public final class DataOutputEncoder extends Encoder implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private transient DataOutput out;
+
+
+ public void setOut(DataOutput out) {
+ this.out = out;
+ }
+
+
+ @Override
+ public void flush() throws IOException {}
+
+ // --------------------------------------------------------------------------------------------
+ // primitives
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void writeNull() {}
+
+
+ @Override
+ public void writeBoolean(boolean b) throws IOException {
+ out.writeBoolean(b);
+ }
+
+ @Override
+ public void writeInt(int n) throws IOException {
+ out.writeInt(n);
+ }
+
+ @Override
+ public void writeLong(long n) throws IOException {
+ out.writeLong(n);
+ }
+
+ @Override
+ public void writeFloat(float f) throws IOException {
+ out.writeFloat(f);
+ }
+
+ @Override
+ public void writeDouble(double d) throws IOException {
+ out.writeDouble(d);
+ }
+
+ @Override
+ public void writeEnum(int e) throws IOException {
+ out.writeInt(e);
+ }
+
+
+ // --------------------------------------------------------------------------------------------
+ // bytes
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void writeFixed(byte[] bytes, int start, int len) throws IOException {
+ out.write(bytes, start, len);
+ }
+
+ @Override
+ public void writeBytes(byte[] bytes, int start, int len) throws IOException {
+ out.writeInt(len);
+ if (len > 0) {
+ out.write(bytes, start, len);
+ }
+ }
+
+ @Override
+ public void writeBytes(ByteBuffer bytes) throws IOException {
+ int num = bytes.remaining();
+ out.writeInt(num);
+
+ if (num > 0) {
+ writeFixed(bytes);
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // strings
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void writeString(String str) throws IOException {
+ byte[] bytes = Utf8.getBytesFor(str);
+ writeBytes(bytes, 0, bytes.length);
+ }
+
+ @Override
+ public void writeString(Utf8 utf8) throws IOException {
+ writeBytes(utf8.getBytes(), 0, utf8.getByteLength());
+
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // collection types
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void writeArrayStart() {}
+
+ @Override
+ public void setItemCount(long itemCount) throws IOException {
+ if (itemCount > 0) {
+ writeVarLongCount(out, itemCount);
+ }
+ }
+
+ @Override
+ public void startItem() {}
+
+ @Override
+ public void writeArrayEnd() throws IOException {
+ // write a single byte 0, shortcut for a var-length long of 0
+ out.write(0);
+ }
+
+ @Override
+ public void writeMapStart() {}
+
+ @Override
+ public void writeMapEnd() throws IOException {
+ // write a single byte 0, shortcut for a var-length long of 0
+ out.write(0);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // union
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public void writeIndex(int unionIndex) throws IOException {
+ out.writeInt(unionIndex);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // utils
+ // --------------------------------------------------------------------------------------------
+
+
+ public static final void writeVarLongCount(DataOutput out, long val) throws IOException {
+ if (val < 0) {
+ throw new IOException("Illegal count (must be non-negative): " + val);
+ }
+
+ while ((val & ~0x7FL) != 0) {
+ out.write(((int) val) | 0x80);
+ val >>>= 7;
+ }
+ out.write((int) val);
+ }
+
+ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
+ // Read in size, and any hidden stuff
+ s.defaultReadObject();
+
+ this.out = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java
new file mode 100644
index 0000000..66f2af6
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java
@@ -0,0 +1,41 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.core.memory.DataOutputView;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class DataOutputViewStream extends OutputStream {
+ protected DataOutputView outputView;
+
+ public DataOutputViewStream(DataOutputView outputView){
+ this.outputView = outputView;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ outputView.writeByte(b);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ outputView.write(b, off, len);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java
new file mode 100644
index 0000000..7c9676b
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java
@@ -0,0 +1,193 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.apache.flink.types.Either.Left;
+import static org.apache.flink.types.Either.Right;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.types.Either;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+
+/**
+ * A {@link TypeSerializer} for the {@ link Either} type of the Java class.
+ *
+ * @param <L> the Left value type
+ * @param <R> the Right value type
+ */
+public class EitherSerializer<L, R> extends TypeSerializer<Either<L, R>> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final TypeSerializer<L> leftSerializer;
+
+ private final TypeSerializer<R> rightSerializer;
+
+ public EitherSerializer(TypeSerializer<L> leftSerializer, TypeSerializer<R> rightSerializer) {
+ this.leftSerializer = leftSerializer;
+ this.rightSerializer = rightSerializer;
+ }
+
+ @Override
+ public boolean isImmutableType() {
+ return leftSerializer.isImmutableType() && rightSerializer.isImmutableType();
+ }
+
+ @Override
+ public TypeSerializer<Either<L, R>> duplicate() {
+ TypeSerializer<L> duplicateLeft = leftSerializer.duplicate();
+ TypeSerializer<R> duplicateRight = rightSerializer.duplicate();
+
+ if ((leftSerializer != duplicateLeft) || (rightSerializer != duplicateRight)) {
+ // stateful
+ return new EitherSerializer<L, R>(duplicateLeft, duplicateRight);
+ }
+ else {
+ return this;
+ }
+ }
+
+
+ @Override
+ public Either<L, R> createInstance() {
+ // We arbitrarily always create a Right value instance.
+ return Right(rightSerializer.createInstance());
+ }
+
+ @Override
+ public Either<L, R> copy(Either<L, R> from) {
+ if (from.isLeft()) {
+ L left = from.left();
+ L copyLeft = leftSerializer.copy(left);
+ return Left(copyLeft);
+ }
+ else {
+ R right = from.right();
+ R copyRight = rightSerializer.copy(right);
+ return Right(copyRight);
+ }
+ }
+
+ @Override
+ public Either<L, R> copy(Either<L, R> from, Either<L, R> reuse) {
+ if (from.isRight()) {
+ final R right = from.right();
+ if (reuse.isRight()) {
+ R copyRight = rightSerializer.copy(right, reuse.right());
+ return Right(copyRight);
+ }
+ else {
+ // if the reuse record isn't a right value, we cannot reuse
+ R copyRight = rightSerializer.copy(right);
+ return Right(copyRight);
+ }
+ }
+ else {
+ L left = from.left();
+ // reuse record is never a left value because we always create a right instance
+ L copyLeft = leftSerializer.copy(left);
+ return Left(copyLeft);
+ }
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+ @Override
+ public void serialize(Either<L, R> record, DataOutputView target) throws IOException {
+ if (record.isLeft()) {
+ target.writeBoolean(true);
+ leftSerializer.serialize(record.left(), target);
+ }
+ else {
+ target.writeBoolean(false);
+ rightSerializer.serialize(record.right(), target);
+ }
+ }
+
+ @Override
+ public Either<L, R> deserialize(DataInputView source) throws IOException {
+ boolean isLeft = source.readBoolean();
+ if (isLeft) {
+ return Left(leftSerializer.deserialize(source));
+ }
+ else {
+ return Right(rightSerializer.deserialize(source));
+ }
+ }
+
+ @Override
+ public Either<L, R> deserialize(Either<L, R> reuse, DataInputView source) throws IOException {
+ boolean isLeft = source.readBoolean();
+ if (!isLeft) {
+ if (reuse.isRight()) {
+ return Right(rightSerializer.deserialize(reuse.right(), source));
+ }
+ else {
+ // if the reuse record isn't a right value, we cannot reuse
+ return Right(rightSerializer.deserialize(source));
+ }
+ }
+ else {
+ // reuse record is never a left value because we always create a right instance
+ return Left(leftSerializer.deserialize(source));
+ }
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ boolean isLeft = source.readBoolean();
+ target.writeBoolean(isLeft);
+ if (isLeft) {
+ leftSerializer.copy(source, target);
+ }
+ else {
+ rightSerializer.copy(source, target);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof EitherSerializer) {
+ EitherSerializer<L, R> other = (EitherSerializer<L, R>) obj;
+
+ return other.canEqual(this) &&
+ leftSerializer.equals(other.leftSerializer) &&
+ rightSerializer.equals(other.rightSerializer);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof EitherSerializer;
+ }
+
+ @Override
+ public int hashCode() {
+ return 17 * leftSerializer.hashCode() + rightSerializer.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java
new file mode 100644
index 0000000..28fea6a
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java
@@ -0,0 +1,177 @@
+/*
+ * 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.java.typeutils.runtime;
+
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.types.NormalizableKey;
+import org.apache.flink.util.InstantiationUtil;
+
+/**
+ * TypeComparator for all types that extend Comparable.
+ */
+public class GenericTypeComparator<T extends Comparable<T>> extends TypeComparator<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final boolean ascending;
+
+ private final Class<T> type;
+
+ private TypeSerializer<T> serializer;
+
+ private transient T reference;
+
+ private transient T tmpReference;
+
+ @SuppressWarnings("rawtypes")
+ private final TypeComparator[] comparators = new TypeComparator[] {this};
+
+ // ------------------------------------------------------------------------
+
+ public GenericTypeComparator(boolean ascending, TypeSerializer<T> serializer, Class<T> type) {
+ this.ascending = ascending;
+ this.serializer = serializer;
+ this.type = type;
+ }
+
+ private GenericTypeComparator(GenericTypeComparator<T> toClone) {
+ this.ascending = toClone.ascending;
+ this.serializer = toClone.serializer.duplicate();
+ this.type = toClone.type;
+ }
+
+ @Override
+ public int hash(T record) {
+ return record.hashCode();
+ }
+
+ @Override
+ public void setReference(T toCompare) {
+ this.reference = this.serializer.copy(toCompare);
+ }
+
+ @Override
+ public boolean equalToReference(T candidate) {
+ return candidate.equals(this.reference);
+ }
+
+ @Override
+ public int compareToReference(TypeComparator<T> referencedComparator) {
+ T otherRef = ((GenericTypeComparator<T>) referencedComparator).reference;
+ int cmp = otherRef.compareTo(this.reference);
+
+ return this.ascending ? cmp : -cmp;
+ }
+
+ @Override
+ public int compare(T first, T second) {
+ int cmp = first.compareTo(second);
+ return this.ascending ? cmp : -cmp;
+ }
+
+ @Override
+ public int compareSerialized(final DataInputView firstSource, final DataInputView secondSource) throws IOException {
+
+ if (this.reference == null) {
+ this.reference = this.serializer.createInstance();
+ }
+
+ if (this.tmpReference == null) {
+ this.tmpReference = this.serializer.createInstance();
+ }
+
+ this.reference = this.serializer.deserialize(this.reference, firstSource);
+ this.tmpReference = this.serializer.deserialize(this.tmpReference, secondSource);
+
+ int cmp = this.reference.compareTo(this.tmpReference);
+ return this.ascending ? cmp : -cmp;
+ }
+
+ @Override
+ public boolean supportsNormalizedKey() {
+ return NormalizableKey.class.isAssignableFrom(this.type);
+ }
+
+ @Override
+ public int getNormalizeKeyLen() {
+ if (this.reference == null) {
+ this.reference = InstantiationUtil.instantiate(this.type);
+ }
+
+ NormalizableKey<?> key = (NormalizableKey<?>) this.reference;
+ return key.getMaxNormalizedKeyLen();
+ }
+
+ @Override
+ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
+ return keyBytes < getNormalizeKeyLen();
+ }
+
+ @Override
+ public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
+ NormalizableKey<?> key = (NormalizableKey<?>) record;
+ key.copyNormalizedKey(target, offset, numBytes);
+ }
+
+ @Override
+ public boolean invertNormalizedKey() {
+ return !ascending;
+ }
+
+ @Override
+ public TypeComparator<T> duplicate() {
+ return new GenericTypeComparator<T>(this);
+ }
+
+ @Override
+ public int extractKeys(Object record, Object[] target, int index) {
+ target[index] = record;
+ return 1;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public TypeComparator[] getFlatComparators() {
+ return comparators;
+ }
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean supportsSerializationWithKeyNormalization() {
+ return false;
+ }
+
+ @Override
+ public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
new file mode 100644
index 0000000..faf5646
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
@@ -0,0 +1,87 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.KryoException;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.util.InstantiationUtil;
+
+import java.io.IOException;
+
+/**
+ * Convenience methods for Kryo
+ */
+public class KryoUtils {
+
+ /**
+ * Tries to copy the given record from using the provided Kryo instance. If this fails, then
+ * the record from is copied by serializing it into a byte buffer and deserializing it from
+ * there.
+ *
+ * @param from Element to copy
+ * @param kryo Kryo instance to use
+ * @param serializer TypeSerializer which is used in case of a Kryo failure
+ * @param <T> Type of the element to be copied
+ * @return Copied element
+ */
+ public static <T> T copy(T from, Kryo kryo, TypeSerializer<T> serializer) {
+ try {
+ return kryo.copy(from);
+ } catch (KryoException ke) {
+ // Kryo could not copy the object --> try to serialize/deserialize the object
+ try {
+ byte[] byteArray = InstantiationUtil.serializeToByteArray(serializer, from);
+
+ return InstantiationUtil.deserializeFromByteArray(serializer, byteArray);
+ } catch (IOException ioe) {
+ throw new RuntimeException("Could not copy object by serializing/deserializing" +
+ " it.", ioe);
+ }
+ }
+ }
+
+ /**
+ * Tries to copy the given record from using the provided Kryo instance. If this fails, then
+ * the record from is copied by serializing it into a byte buffer and deserializing it from
+ * there.
+ *
+ * @param from Element to copy
+ * @param reuse Reuse element for the deserialization
+ * @param kryo Kryo instance to use
+ * @param serializer TypeSerializer which is used in case of a Kryo failure
+ * @param <T> Type of the element to be copied
+ * @return Copied element
+ */
+ public static <T> T copy(T from, T reuse, Kryo kryo, TypeSerializer<T> serializer) {
+ try {
+ return kryo.copy(from);
+ } catch (KryoException ke) {
+ // Kryo could not copy the object --> try to serialize/deserialize the object
+ try {
+ byte[] byteArray = InstantiationUtil.serializeToByteArray(serializer, from);
+
+ return InstantiationUtil.deserializeFromByteArray(serializer, reuse, byteArray);
+ } catch (IOException ioe) {
+ throw new RuntimeException("Could not copy object by serializing/deserializing" +
+ " it.", ioe);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java
new file mode 100644
index 0000000..0f4fe94
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java
@@ -0,0 +1,141 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import com.esotericsoftware.kryo.KryoException;
+import com.esotericsoftware.kryo.io.Input;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class NoFetchingInput extends Input {
+ public NoFetchingInput(InputStream inputStream){
+ super(inputStream, 8);
+ }
+
+ @Override
+ public boolean eof(){
+ throw new UnsupportedOperationException("NoFetchingInput does not support EOF.");
+ }
+
+ @Override
+ public int read() throws KryoException {
+ require(1);
+ return buffer[position++] & 0xFF;
+ }
+
+ @Override
+ public boolean canReadInt() throws KryoException {
+ throw new UnsupportedOperationException("NoFetchingInput cannot prefetch data.");
+ }
+
+ @Override
+ public boolean canReadLong() throws KryoException {
+ throw new UnsupportedOperationException("NoFetchingInput cannot prefetch data.");
+ }
+
+ /**
+ * Require makes sure that at least required number of bytes are kept in the buffer. If not, then
+ * it will load exactly the difference between required and currently available number of bytes.
+ * Thus, it will only load the data which is required and never prefetch data.
+ *
+ * @param required the number of bytes being available in the buffer
+ * @return the number of bytes remaining, which is equal to required
+ * @throws KryoException
+ */
+ @Override
+ protected int require(int required) throws KryoException {
+ if(required > capacity) {
+ throw new KryoException("Buffer too small: capacity: " + capacity + ", " +
+ "required: " + required);
+ }
+
+ position = 0;
+ int bytesRead = 0;
+ int count;
+ while(true){
+ count = fill(buffer, bytesRead, required - bytesRead);
+
+ if(count == -1){
+ throw new KryoException(new EOFException("No more bytes left."));
+ }
+
+ bytesRead += count;
+ if(bytesRead == required){
+ break;
+ }
+ }
+ limit = required;
+ return required;
+ }
+
+ @Override
+ public int read(byte[] bytes, int offset, int count) throws KryoException {
+ if(bytes == null){
+ throw new IllegalArgumentException("bytes cannot be null.");
+ }
+
+ try {
+ return inputStream.read(bytes, offset, count);
+ }catch(IOException ex){
+ throw new KryoException(ex);
+ }
+ }
+
+ @Override
+ public void skip(int count) throws KryoException {
+ try{
+ inputStream.skip(count);
+ }catch(IOException ex){
+ throw new KryoException(ex);
+ }
+ }
+
+ @Override
+ public void readBytes(byte[] bytes, int offset, int count) throws KryoException {
+ if(bytes == null){
+ throw new IllegalArgumentException("bytes cannot be null.");
+ }
+
+ try{
+ int bytesRead = 0;
+ int c;
+
+ while(true){
+ c = inputStream.read(bytes, offset+bytesRead, count-bytesRead);
+
+ if(c == -1){
+ throw new KryoException(new EOFException("No more bytes left."));
+ }
+
+ bytesRead += c;
+
+ if(bytesRead == count){
+ break;
+ }
+ }
+ }catch(IOException ex){
+ throw new KryoException(ex);
+ }
+ }
+
+
+}
+
[16/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorTest.java
new file mode 100644
index 0000000..cdafa6a
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorTest.java
@@ -0,0 +1,1907 @@
+/*
+ * 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.java.typeutils;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.functions.RichCoGroupFunction;
+import org.apache.flink.api.common.functions.RichCrossFunction;
+import org.apache.flink.api.common.functions.RichFlatJoinFunction;
+import org.apache.flink.api.common.functions.RichFlatMapFunction;
+import org.apache.flink.api.common.functions.RichGroupReduceFunction;
+import org.apache.flink.api.common.functions.RichMapFunction;
+import org.apache.flink.api.common.functions.RuntimeContext;
+import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
+import org.apache.flink.api.java.functions.KeySelector;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.api.java.tuple.Tuple0;
+import org.apache.flink.api.java.tuple.Tuple1;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.tuple.Tuple9;
+import org.apache.flink.types.Either;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.types.DoubleValue;
+import org.apache.flink.types.IntValue;
+import org.apache.flink.types.StringValue;
+import org.apache.flink.types.Value;
+import org.apache.flink.util.Collector;
+
+import org.apache.hadoop.io.Writable;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+@SuppressWarnings("serial")
+public class TypeExtractorTest {
+
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testBasicType() {
+ // use getGroupReduceReturnTypes()
+ RichGroupReduceFunction<?, ?> function = new RichGroupReduceFunction<Boolean, Boolean>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void reduce(Iterable<Boolean> values, Collector<Boolean> out) throws Exception {
+ // nothing to do
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getGroupReduceReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Boolean"));
+
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
+ Assert.assertEquals(Boolean.class, ti.getTypeClass());
+
+ // use getForClass()
+ Assert.assertTrue(TypeExtractor.getForClass(Boolean.class).isBasicType());
+ Assert.assertEquals(ti, TypeExtractor.getForClass(Boolean.class));
+
+ // use getForObject()
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeExtractor.getForObject(true));
+ }
+
+ public static class MyWritable implements Writable {
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+ }
+
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testWritableType() {
+ RichMapFunction<?, ?> function = new RichMapFunction<MyWritable, MyWritable>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public MyWritable map(MyWritable value) throws Exception {
+ return null;
+ }
+
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) new WritableTypeInfo<MyWritable>(MyWritable.class));
+
+ Assert.assertTrue(ti instanceof WritableTypeInfo<?>);
+ Assert.assertEquals(MyWritable.class, ((WritableTypeInfo<?>) ti).getTypeClass());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTupleWithBasicTypes() throws Exception {
+ // use getMapReturnTypes()
+ RichMapFunction<?, ?> function = new RichMapFunction<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>, Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> map(
+ Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> value) throws Exception {
+ return null;
+ }
+
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(9, ti.getArity());
+ Assert.assertTrue(ti instanceof TupleTypeInfo);
+ List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
+ ((TupleTypeInfo) ti).getFlatFields("f3", 0, ffd);
+ Assert.assertTrue(ffd.size() == 1);
+ Assert.assertEquals(3, ffd.get(0).getPosition() );
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(Tuple9.class, tti.getTypeClass());
+
+ for (int i = 0; i < 9; i++) {
+ Assert.assertTrue(tti.getTypeAt(i) instanceof BasicTypeInfo);
+ }
+
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(3));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(4));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(5));
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(6));
+ Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti.getTypeAt(7));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti.getTypeAt(8));
+
+ // use getForObject()
+ Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> t = new Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>(
+ 1, 1L, 1.0, 1.0F, false, "Hello World", 'w', (short) 1, (byte) 1);
+
+ Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);
+
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti2.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti2.getTypeAt(2));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(3));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti2.getTypeAt(4));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti2.getTypeAt(5));
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti2.getTypeAt(6));
+ Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti2.getTypeAt(7));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti2.getTypeAt(8));
+
+ // test that getForClass does not work
+ try {
+ TypeExtractor.getForClass(Tuple9.class);
+ Assert.fail("Exception expected here");
+ } catch (InvalidTypesException e) {
+ // that is correct
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTupleWithTuples() {
+ // use getFlatMapReturnTypes()
+ RichFlatMapFunction<?, ?> function = new RichFlatMapFunction<Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>, Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void flatMap(Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>> value,
+ Collector<Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>> out) throws Exception {
+ // nothing to do
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getFlatMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>"));
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(3, ti.getArity());
+ Assert.assertTrue(ti instanceof TupleTypeInfo);
+ List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
+
+ ((TupleTypeInfo) ti).getFlatFields("f0.f0", 0, ffd);
+ Assert.assertEquals(0, ffd.get(0).getPosition() );
+ ffd.clear();
+
+ ((TupleTypeInfo) ti).getFlatFields("f0.f0", 0, ffd);
+ Assert.assertTrue( ffd.get(0).getType() instanceof BasicTypeInfo );
+ Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(String.class) );
+ ffd.clear();
+
+ ((TupleTypeInfo) ti).getFlatFields("f1.f0", 0, ffd);
+ Assert.assertEquals(1, ffd.get(0).getPosition() );
+ ffd.clear();
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(Tuple3.class, tti.getTypeClass());
+
+ Assert.assertTrue(tti.getTypeAt(0).isTupleType());
+ Assert.assertTrue(tti.getTypeAt(1).isTupleType());
+ Assert.assertTrue(tti.getTypeAt(2).isTupleType());
+
+ Assert.assertEquals(Tuple1.class, tti.getTypeAt(0).getTypeClass());
+ Assert.assertEquals(Tuple1.class, tti.getTypeAt(1).getTypeClass());
+ Assert.assertEquals(Tuple2.class, tti.getTypeAt(2).getTypeClass());
+
+ Assert.assertEquals(1, tti.getTypeAt(0).getArity());
+ Assert.assertEquals(1, tti.getTypeAt(1).getArity());
+ Assert.assertEquals(2, tti.getTypeAt(2).getArity());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(0)).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(1)).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(2)).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(2)).getTypeAt(1));
+
+ // use getForObject()
+ Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>> t = new Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>(
+ new Tuple1<String>("hello"), new Tuple1<Integer>(1), new Tuple2<Long, Long>(2L, 3L));
+ Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);
+
+ Assert.assertEquals(1, tti2.getTypeAt(0).getArity());
+ Assert.assertEquals(1, tti2.getTypeAt(1).getArity());
+ Assert.assertEquals(2, tti2.getTypeAt(2).getArity());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(0)).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(1)).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(2)).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(2)).getTypeAt(1));
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTuple0() {
+ // use getFlatMapReturnTypes()
+ RichFlatMapFunction<?, ?> function = new RichFlatMapFunction<Tuple0, Tuple0>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void flatMap(Tuple0 value, Collector<Tuple0> out) throws Exception {
+ // nothing to do
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getFlatMapReturnTypes(function,
+ (TypeInformation) TypeInfoParser.parse("Tuple0"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(0, ti.getArity());
+ Assert.assertTrue(ti instanceof TupleTypeInfo);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testSubclassOfTuple() {
+ // use getJoinReturnTypes()
+ RichFlatJoinFunction<?, ?, ?> function = new RichFlatJoinFunction<CustomTuple, String, CustomTuple>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void join(CustomTuple first, String second, Collector<CustomTuple> out) throws Exception {
+ out.collect(null);
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getFlatJoinReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, Integer>"), (TypeInformation) TypeInfoParser.parse("String"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) ti).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) ti).getTypeAt(1));
+ Assert.assertEquals(CustomTuple.class, ((TupleTypeInfo<?>) ti).getTypeClass());
+
+ // use getForObject()
+ CustomTuple t = new CustomTuple("hello", 1);
+ TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
+
+ Assert.assertTrue(ti2.isTupleType());
+ Assert.assertEquals(2, ti2.getArity());
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) ti2).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) ti2).getTypeAt(1));
+ Assert.assertEquals(CustomTuple.class, ((TupleTypeInfo<?>) ti2).getTypeClass());
+ }
+
+ public static class CustomTuple extends Tuple2<String, Integer> {
+ private static final long serialVersionUID = 1L;
+
+ public CustomTuple(String myField1, Integer myField2) {
+ this.setFields(myField1, myField2);
+ }
+
+ public String getMyField1() {
+ return this.f0;
+ }
+
+ public int getMyField2() {
+ return this.f1;
+ }
+ }
+
+ public static class PojoWithNonPublicDefaultCtor {
+ public int foo, bar;
+ PojoWithNonPublicDefaultCtor() {}
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testPojo() {
+ // use getCrossReturnTypes()
+ RichCrossFunction<?, ?, ?> function = new RichCrossFunction<CustomType, Integer, CustomType>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public CustomType cross(CustomType first, Integer second) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getCrossReturnTypes(function,
+ (TypeInformation) TypeInfoParser.parse("org.apache.flink.api.java.typeutils.TypeExtractorTest$CustomType"),
+ (TypeInformation) TypeInfoParser.parse("Integer"));
+
+ Assert.assertFalse(ti.isBasicType());
+ Assert.assertFalse(ti.isTupleType());
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ Assert.assertEquals(ti.getTypeClass(), CustomType.class);
+
+ // use getForClass()
+ Assert.assertTrue(TypeExtractor.getForClass(CustomType.class) instanceof PojoTypeInfo);
+ Assert.assertEquals(TypeExtractor.getForClass(CustomType.class).getTypeClass(), ti.getTypeClass());
+
+ // use getForObject()
+ CustomType t = new CustomType("World", 1);
+ TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
+
+ Assert.assertFalse(ti2.isBasicType());
+ Assert.assertFalse(ti2.isTupleType());
+ Assert.assertTrue(ti2 instanceof PojoTypeInfo);
+ Assert.assertEquals(ti2.getTypeClass(), CustomType.class);
+
+ Assert.assertFalse(TypeExtractor.getForClass(PojoWithNonPublicDefaultCtor.class) instanceof PojoTypeInfo);
+ }
+
+
+
+ public static class CustomType {
+ public String myField1;
+ public int myField2;
+
+ public CustomType() {
+ }
+
+ public CustomType(String myField1, int myField2) {
+ this.myField1 = myField1;
+ this.myField2 = myField2;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTupleWithPojo() {
+ // use getMapReturnTypes()
+ RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<Long, CustomType>, Tuple2<Long, CustomType>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<Long, CustomType> map(Tuple2<Long, CustomType> value) throws Exception {
+ return null;
+ }
+
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function,
+ (TypeInformation) TypeInfoParser.parse("Tuple2<Long,org.apache.flink.api.java.typeutils.TypeExtractorTest$CustomType>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(Tuple2.class, tti.getTypeClass());
+ List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
+
+ tti.getFlatFields("f0", 0, ffd);
+ Assert.assertEquals(1, ffd.size());
+ Assert.assertEquals(0, ffd.get(0).getPosition() ); // Long
+ Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(Long.class) );
+ ffd.clear();
+
+ tti.getFlatFields("f1.myField1", 0, ffd);
+ Assert.assertEquals(1, ffd.get(0).getPosition() );
+ Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(String.class) );
+ ffd.clear();
+
+
+ tti.getFlatFields("f1.myField2", 0, ffd);
+ Assert.assertEquals(2, ffd.get(0).getPosition() );
+ Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(Integer.class) );
+
+
+ Assert.assertEquals(Long.class, tti.getTypeAt(0).getTypeClass());
+ Assert.assertTrue(tti.getTypeAt(1) instanceof PojoTypeInfo);
+ Assert.assertEquals(CustomType.class, tti.getTypeAt(1).getTypeClass());
+
+ // use getForObject()
+ Tuple2<?, ?> t = new Tuple2<Long, CustomType>(1L, new CustomType("Hello", 1));
+ TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
+
+ Assert.assertTrue(ti2.isTupleType());
+ Assert.assertEquals(2, ti2.getArity());
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) ti2;
+
+ Assert.assertEquals(Tuple2.class, tti2.getTypeClass());
+ Assert.assertEquals(Long.class, tti2.getTypeAt(0).getTypeClass());
+ Assert.assertTrue(tti2.getTypeAt(1) instanceof PojoTypeInfo);
+ Assert.assertEquals(CustomType.class, tti2.getTypeAt(1).getTypeClass());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testValue() {
+ // use getKeyExtractorType()
+ KeySelector<?, ?> function = new KeySelector<StringValue, StringValue>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public StringValue getKey(StringValue value) {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getKeySelectorTypes(function, (TypeInformation) TypeInfoParser.parse("StringValue"));
+
+ Assert.assertFalse(ti.isBasicType());
+ Assert.assertFalse(ti.isTupleType());
+ Assert.assertTrue(ti instanceof ValueTypeInfo);
+ Assert.assertEquals(ti.getTypeClass(), StringValue.class);
+
+ // use getForClass()
+ Assert.assertTrue(TypeExtractor.getForClass(StringValue.class) instanceof ValueTypeInfo);
+ Assert.assertEquals(TypeExtractor.getForClass(StringValue.class).getTypeClass(), ti.getTypeClass());
+
+ // use getForObject()
+ StringValue v = new StringValue("Hello");
+ Assert.assertTrue(TypeExtractor.getForObject(v) instanceof ValueTypeInfo);
+ Assert.assertEquals(TypeExtractor.getForObject(v).getTypeClass(), ti.getTypeClass());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTupleOfValues() {
+ // use getMapReturnTypes()
+ RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<StringValue, IntValue>, Tuple2<StringValue, IntValue>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<StringValue, IntValue> map(Tuple2<StringValue, IntValue> value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<StringValue, IntValue>"));
+
+ Assert.assertFalse(ti.isBasicType());
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(StringValue.class, ((TupleTypeInfo<?>) ti).getTypeAt(0).getTypeClass());
+ Assert.assertEquals(IntValue.class, ((TupleTypeInfo<?>) ti).getTypeAt(1).getTypeClass());
+
+ // use getForObject()
+ Tuple2<StringValue, IntValue> t = new Tuple2<StringValue, IntValue>(new StringValue("x"), new IntValue(1));
+ TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
+
+ Assert.assertFalse(ti2.isBasicType());
+ Assert.assertTrue(ti2.isTupleType());
+ Assert.assertEquals(((TupleTypeInfo<?>) ti2).getTypeAt(0).getTypeClass(), StringValue.class);
+ Assert.assertEquals(((TupleTypeInfo<?>) ti2).getTypeAt(1).getTypeClass(), IntValue.class);
+ }
+
+ public static class LongKeyValue<V> extends Tuple2<Long, V> {
+ private static final long serialVersionUID = 1L;
+
+ public LongKeyValue(Long field1, V field2) {
+ this.f0 = field1;
+ this.f1 = field2;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericsNotInSuperclass() {
+ // use getMapReturnTypes()
+ RichMapFunction<?, ?> function = new RichMapFunction<LongKeyValue<String>, LongKeyValue<String>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public LongKeyValue<String> map(LongKeyValue<String> value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Long, String>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(LongKeyValue.class, tti.getTypeClass());
+
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public static class ChainedOne<X, Y> extends Tuple3<X, Long, Y> {
+ private static final long serialVersionUID = 1L;
+
+ public ChainedOne(X field0, Long field1, Y field2) {
+ this.f0 = field0;
+ this.f1 = field1;
+ this.f2 = field2;
+ }
+ }
+
+ public static class ChainedTwo<V> extends ChainedOne<String, V> {
+ private static final long serialVersionUID = 1L;
+
+ public ChainedTwo(String field0, Long field1, V field2) {
+ super(field0, field1, field2);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testChainedGenericsNotInSuperclass() {
+ // use TypeExtractor
+ RichMapFunction<?, ?> function = new RichMapFunction<ChainedTwo<Integer>, ChainedTwo<Integer>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ChainedTwo<Integer> map(ChainedTwo<Integer> value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, Long, Integer>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(3, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(ChainedTwo.class, tti.getTypeClass());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(2));
+ }
+
+ public static class ChainedThree extends ChainedTwo<String> {
+ private static final long serialVersionUID = 1L;
+
+ public ChainedThree(String field0, Long field1, String field2) {
+ super(field0, field1, field2);
+ }
+ }
+
+ public static class ChainedFour extends ChainedThree {
+ private static final long serialVersionUID = 1L;
+
+ public ChainedFour(String field0, Long field1, String field2) {
+ super(field0, field1, field2);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericsInDirectSuperclass() {
+ // use TypeExtractor
+ RichMapFunction<?, ?> function = new RichMapFunction<ChainedThree, ChainedThree>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ChainedThree map(ChainedThree value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, Long, String>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(3, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(ChainedThree.class, tti.getTypeClass());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(2));
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericsNotInSuperclassWithNonGenericClassAtEnd() {
+ // use TypeExtractor
+ RichMapFunction<?, ?> function = new RichMapFunction<ChainedFour, ChainedFour>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ChainedFour map(ChainedFour value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, Long, String>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(3, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(ChainedFour.class, tti.getTypeClass());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(2));
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testMissingTupleGenerics() {
+ RichMapFunction<?, ?> function = new RichMapFunction<String, Tuple2>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2 map(String value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"), "name", true);
+ Assert.assertTrue(ti instanceof MissingTypeInfo);
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"));
+ Assert.fail("Expected an exception");
+ }
+ catch (InvalidTypesException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTupleSupertype() {
+ RichMapFunction<?, ?> function = new RichMapFunction<String, Tuple>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple map(String value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"), "name", true);
+ Assert.assertTrue(ti instanceof MissingTypeInfo);
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"));
+ Assert.fail("Expected an exception");
+ }
+ catch (InvalidTypesException e) {
+ // expected
+ }
+ }
+
+ public static class SameTypeVariable<X> extends Tuple2<X, X> {
+ private static final long serialVersionUID = 1L;
+
+ public SameTypeVariable(X field0, X field1) {
+ super(field0, field1);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testSameGenericVariable() {
+ RichMapFunction<?, ?> function = new RichMapFunction<SameTypeVariable<String>, SameTypeVariable<String>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public SameTypeVariable<String> map(SameTypeVariable<String> value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, String>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(SameTypeVariable.class, tti.getTypeClass());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public static class Nested<V, T> extends Tuple2<V, Tuple2<T, T>> {
+ private static final long serialVersionUID = 1L;
+
+ public Nested(V field0, Tuple2<T, T> field1) {
+ super(field0, field1);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testNestedTupleGenerics() {
+ RichMapFunction<?, ?> function = new RichMapFunction<Nested<String, Integer>, Nested<String, Integer>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Nested<String, Integer> map(Nested<String, Integer> value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, Tuple2<Integer, Integer>>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(Nested.class, tti.getTypeClass());
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertTrue(tti.getTypeAt(1).isTupleType());
+ Assert.assertEquals(2, tti.getTypeAt(1).getArity());
+
+ // Nested
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(1);
+ Assert.assertEquals(Tuple2.class, tti2.getTypeClass());
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(1));
+ }
+
+ public static class Nested2<T> extends Nested<T, Nested<Integer, T>> {
+ private static final long serialVersionUID = 1L;
+
+ public Nested2(T field0, Tuple2<Nested<Integer, T>, Nested<Integer, T>> field1) {
+ super(field0, field1);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testNestedTupleGenerics2() {
+ RichMapFunction<?, ?> function = new RichMapFunction<Nested2<Boolean>, Nested2<Boolean>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Nested2<Boolean> map(Nested2<Boolean> value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Boolean, Tuple2<Tuple2<Integer, Tuple2<Boolean, Boolean>>, Tuple2<Integer, Tuple2<Boolean, Boolean>>>>"));
+
+ // Should be
+ // Tuple2<Boolean, Tuple2<Tuple2<Integer, Tuple2<Boolean, Boolean>>, Tuple2<Integer, Tuple2<Boolean, Boolean>>>>
+
+ // 1st nested level
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertTrue(tti.getTypeAt(1).isTupleType());
+
+ // 2nd nested level
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(1);
+ Assert.assertTrue(tti2.getTypeAt(0).isTupleType());
+ Assert.assertTrue(tti2.getTypeAt(1).isTupleType());
+
+ // 3rd nested level
+ TupleTypeInfo<?> tti3 = (TupleTypeInfo<?>) tti2.getTypeAt(0);
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti3.getTypeAt(0));
+ Assert.assertTrue(tti3.getTypeAt(1).isTupleType());
+
+ // 4th nested level
+ TupleTypeInfo<?> tti4 = (TupleTypeInfo<?>) tti3.getTypeAt(1);
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti4.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti4.getTypeAt(1));
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testFunctionWithMissingGenerics() {
+ RichMapFunction function = new RichMapFunction() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(Object value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, TypeInfoParser.parse("String"), "name", true);
+ Assert.assertTrue(ti instanceof MissingTypeInfo);
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, TypeInfoParser.parse("String"));
+ Assert.fail("Expected an exception");
+ }
+ catch (InvalidTypesException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testFunctionDependingOnInputAsSuperclass() {
+ IdentityMapper<Boolean> function = new IdentityMapper<Boolean>() {
+ private static final long serialVersionUID = 1L;
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Boolean"));
+
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
+ }
+
+ public class IdentityMapper<T> extends RichMapFunction<T, T> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public T map(T value) throws Exception {
+ return null;
+ }
+ }
+
+ @Test
+ public void testFunctionDependingOnInputFromInput() {
+ IdentityMapper<Boolean> function = new IdentityMapper<Boolean>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.BOOLEAN_TYPE_INFO);
+
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
+ }
+
+ @Test
+ public void testFunctionDependingOnInputWithMissingInput() {
+ IdentityMapper<Boolean> function = new IdentityMapper<Boolean>();
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, null);
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+ }
+
+ public class IdentityMapper2<T> extends RichMapFunction<Tuple2<T, String>, T> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public T map(Tuple2<T, String> value) throws Exception {
+ return null;
+ }
+ }
+
+ @Test
+ public void testFunctionDependingOnInputWithTupleInput() {
+ IdentityMapper2<Boolean> function = new IdentityMapper2<Boolean>();
+
+ TypeInformation<Tuple2<Boolean, String>> inputType = new TupleTypeInfo<Tuple2<Boolean, String>>(BasicTypeInfo.BOOLEAN_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO);
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, inputType);
+
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testFunctionDependingOnInputWithCustomTupleInput() {
+ IdentityMapper<SameTypeVariable<String>> function = new IdentityMapper<SameTypeVariable<String>>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, String>"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public class IdentityMapper3<T, V> extends RichMapFunction<T, V> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public V map(T value) throws Exception {
+ return null;
+ }
+ }
+
+ @Test
+ public void testFunctionDependingOnUnknownInput() {
+ IdentityMapper3<Boolean, String> function = new IdentityMapper3<Boolean, String>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.BOOLEAN_TYPE_INFO, "name", true);
+ Assert.assertTrue(ti instanceof MissingTypeInfo);
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.BOOLEAN_TYPE_INFO);
+ Assert.fail("Expected an exception");
+ }
+ catch (InvalidTypesException e) {
+ // expected
+ }
+ }
+
+ public class IdentityMapper4<D> extends IdentityMapper<D> {
+ private static final long serialVersionUID = 1L;
+ }
+
+ @Test
+ public void testFunctionDependingOnInputWithFunctionHierarchy() {
+ IdentityMapper4<String> function = new IdentityMapper4<String>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.STRING_TYPE_INFO);
+
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
+ }
+
+ public class IdentityMapper5<D> extends IdentityMapper<Tuple2<D, D>> {
+ private static final long serialVersionUID = 1L;
+ }
+
+ @Test
+ public void testFunctionDependingOnInputWithFunctionHierarchy2() {
+ IdentityMapper5<String> function = new IdentityMapper5<String>();
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, new TupleTypeInfo(BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO));
+
+ Assert.assertTrue(ti.isTupleType());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public class Mapper extends IdentityMapper<String> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(String value) throws Exception {
+ return null;
+ }
+ }
+
+ public class Mapper2 extends Mapper {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(String value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testFunctionWithNoGenericSuperclass() {
+ RichMapFunction<?, ?> function = new Mapper2();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"));
+
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
+ }
+
+ public class OneAppender<T> extends RichMapFunction<T, Tuple2<T, Integer>> {
+ private static final long serialVersionUID = 1L;
+
+ public Tuple2<T, Integer> map(T value) {
+ return new Tuple2<T, Integer>(value, 1);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testFunctionDependingPartialOnInput() {
+ RichMapFunction<?, ?> function = new OneAppender<DoubleValue>() {
+ private static final long serialVersionUID = 1L;
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("DoubleValue"));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+
+ Assert.assertTrue(tti.getTypeAt(0) instanceof ValueTypeInfo<?>);
+ ValueTypeInfo<?> vti = (ValueTypeInfo<?>) tti.getTypeAt(0);
+ Assert.assertEquals(DoubleValue.class, vti.getTypeClass());
+
+ Assert.assertTrue(tti.getTypeAt(1).isBasicType());
+ Assert.assertEquals(Integer.class , tti.getTypeAt(1).getTypeClass());
+ }
+
+ @Test
+ public void testFunctionDependingPartialOnInput2() {
+ RichMapFunction<DoubleValue, ?> function = new OneAppender<DoubleValue>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, new ValueTypeInfo<DoubleValue>(DoubleValue.class));
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+
+ Assert.assertTrue(tti.getTypeAt(0) instanceof ValueTypeInfo<?>);
+ ValueTypeInfo<?> vti = (ValueTypeInfo<?>) tti.getTypeAt(0);
+ Assert.assertEquals(DoubleValue.class, vti.getTypeClass());
+
+ Assert.assertTrue(tti.getTypeAt(1).isBasicType());
+ Assert.assertEquals(Integer.class , tti.getTypeAt(1).getTypeClass());
+ }
+
+ public class FieldDuplicator<T> extends RichMapFunction<T, Tuple2<T, T>> {
+ private static final long serialVersionUID = 1L;
+
+ public Tuple2<T, T> map(T value) {
+ return new Tuple2<T, T>(value, value);
+ }
+ }
+
+ @Test
+ public void testFunctionInputInOutputMultipleTimes() {
+ RichMapFunction<Float, ?> function = new FieldDuplicator<Float>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.FLOAT_TYPE_INFO);
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ @Test
+ public void testFunctionInputInOutputMultipleTimes2() {
+ RichMapFunction<Tuple2<Float, Float>, ?> function = new FieldDuplicator<Tuple2<Float, Float>>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, new TupleTypeInfo<Tuple2<Float, Float>>(
+ BasicTypeInfo.FLOAT_TYPE_INFO, BasicTypeInfo.FLOAT_TYPE_INFO));
+
+ // should be
+ // Tuple2<Tuple2<Float, Float>, Tuple2<Float, Float>>
+
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+
+ // 2nd nested level
+ Assert.assertTrue(tti.getTypeAt(0).isTupleType());
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(0);
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(1));
+ Assert.assertTrue(tti.getTypeAt(0).isTupleType());
+ TupleTypeInfo<?> tti3 = (TupleTypeInfo<?>) tti.getTypeAt(1);
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti3.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti3.getTypeAt(1));
+ }
+
+ public interface Testable {}
+
+ public static abstract class AbstractClassWithoutMember {}
+
+ public static abstract class AbstractClassWithMember {
+ public int x;
+ }
+
+ @Test
+ public void testAbstractAndInterfaceTypes() {
+
+ // interface
+ RichMapFunction<String, ?> function = new RichMapFunction<String, Testable>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Testable map(String value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertTrue(ti instanceof GenericTypeInfo);
+
+ // abstract class with out class member
+ RichMapFunction<String, ?> function2 = new RichMapFunction<String, AbstractClassWithoutMember>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public AbstractClassWithoutMember map(String value) throws Exception {
+ return null;
+ }
+ };
+
+ ti = TypeExtractor.getMapReturnTypes(function2, BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertTrue(ti instanceof GenericTypeInfo);
+
+ // abstract class with class member
+ RichMapFunction<String, ?> function3 = new RichMapFunction<String, AbstractClassWithMember>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public AbstractClassWithMember map(String value) throws Exception {
+ return null;
+ }
+ };
+
+ ti = TypeExtractor.getMapReturnTypes(function3, BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testValueSupertypeException() {
+ RichMapFunction<?, ?> function = new RichMapFunction<StringValue, Value>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Value map(StringValue value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti =TypeExtractor.getMapReturnTypes(function, (TypeInformation)TypeInfoParser.parse("StringValue"), "name", true);
+ Assert.assertTrue(ti instanceof MissingTypeInfo);
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, (TypeInformation)TypeInfoParser.parse("StringValue"));
+ Assert.fail("Expected an exception");
+ }
+ catch (InvalidTypesException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testBasicArray() {
+ // use getCoGroupReturnTypes()
+ RichCoGroupFunction<?, ?, ?> function = new RichCoGroupFunction<String[], String[], String[]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void coGroup(Iterable<String[]> first, Iterable<String[]> second, Collector<String[]> out) throws Exception {
+ // nothing to do
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getCoGroupReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String[]"), (TypeInformation) TypeInfoParser.parse("String[]"));
+
+ Assert.assertFalse(ti.isBasicType());
+ Assert.assertFalse(ti.isTupleType());
+
+ // Due to a Java 6 bug the classification can be slightly wrong
+ Assert.assertTrue(ti instanceof BasicArrayTypeInfo<?,?> || ti instanceof ObjectArrayTypeInfo<?,?>);
+
+ if(ti instanceof BasicArrayTypeInfo<?,?>) {
+ Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, ti);
+ }
+ else {
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((ObjectArrayTypeInfo<?,?>) ti).getComponentInfo());
+ }
+ }
+
+ @Test
+ public void testBasicArray2() {
+ RichMapFunction<Boolean[], ?> function = new IdentityMapper<Boolean[]>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO);
+
+ Assert.assertTrue(ti instanceof BasicArrayTypeInfo<?, ?>);
+ BasicArrayTypeInfo<?, ?> bati = (BasicArrayTypeInfo<?, ?>) ti;
+ Assert.assertTrue(bati.getComponentInfo().isBasicType());
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, bati.getComponentInfo());
+ }
+
+ public static class CustomArrayObject {}
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testCustomArray() {
+ RichMapFunction<?, ?> function = new RichMapFunction<CustomArrayObject[], CustomArrayObject[]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public CustomArrayObject[] map(CustomArrayObject[] value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function,
+ (TypeInformation) TypeInfoParser.parse("org.apache.flink.api.java.typeutils.TypeExtractorTest$CustomArrayObject[]"));
+
+ Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
+ Assert.assertEquals(CustomArrayObject.class, ((ObjectArrayTypeInfo<?, ?>) ti).getComponentInfo().getTypeClass());
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testTupleArray() {
+ RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<String, String>[], Tuple2<String, String>[]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<String, String>[] map(Tuple2<String, String>[] value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, String>[]"));
+
+ Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
+ ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) ti;
+ Assert.assertTrue(oati.getComponentInfo().isTupleType());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) oati.getComponentInfo();
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public class CustomArrayObject2<F> extends Tuple1<F> {
+ private static final long serialVersionUID = 1L;
+
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testCustomArrayWithTypeVariable() {
+ RichMapFunction<CustomArrayObject2<Boolean>[], ?> function = new IdentityMapper<CustomArrayObject2<Boolean>[]>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple1<Boolean>[]"));
+
+ Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
+ ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) ti;
+ Assert.assertTrue(oati.getComponentInfo().isTupleType());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) oati.getComponentInfo();
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(0));
+ }
+
+ public class GenericArrayClass<T> extends RichMapFunction<T[], T[]> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public T[] map(T[] value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testParameterizedArrays() {
+ GenericArrayClass<Boolean> function = new GenericArrayClass<Boolean>(){
+ private static final long serialVersionUID = 1L;
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Boolean[]"));
+ Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?,?>);
+ ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) ti;
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, oati.getComponentInfo());
+ }
+
+ public static class MyObject<T> {
+ public T myField;
+ }
+
+ public static class InType extends MyObject<String> {}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testParameterizedPojo() {
+ RichMapFunction<?, ?> function = new RichMapFunction<InType, MyObject<String>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public MyObject<String> map(InType value) throws Exception {
+ return null;
+ }
+ };
+ TypeInformation<?> inType = TypeExtractor.createTypeInfo(InType.class);
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) inType);
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ }
+
+ @Test
+ public void testFunctionDependingOnInputWithTupleInputWithTypeMismatch() {
+ IdentityMapper2<Boolean> function = new IdentityMapper2<Boolean>();
+
+ TypeInformation<Tuple2<Boolean, String>> inputType = new TupleTypeInfo<Tuple2<Boolean, String>>(BasicTypeInfo.BOOLEAN_TYPE_INFO,
+ BasicTypeInfo.INT_TYPE_INFO);
+
+ // input is: Tuple2<Boolean, Integer>
+ // allowed: Tuple2<?, String>
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, inputType);
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testInputMismatchExceptions() {
+
+ RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<String, String>, String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(Tuple2<String, String> value) throws Exception {
+ return null;
+ }
+ };
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Integer, String>"));
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+
+ try {
+ TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, String, String>"));
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+
+ RichMapFunction<?, ?> function2 = new RichMapFunction<StringValue, String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(StringValue value) throws Exception {
+ return null;
+ }
+ };
+
+ try {
+ TypeExtractor.getMapReturnTypes(function2, (TypeInformation) TypeInfoParser.parse("IntValue"));
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+
+ RichMapFunction<?, ?> function3 = new RichMapFunction<Tuple1<Integer>[], String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(Tuple1<Integer>[] value) throws Exception {
+ return null;
+ }
+ };
+
+ try {
+ TypeExtractor.getMapReturnTypes(function3, (TypeInformation) TypeInfoParser.parse("Integer[]"));
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+
+ RichMapFunction<?, ?> function4 = new RichMapFunction<Writable, String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String map(Writable value) throws Exception {
+ return null;
+ }
+ };
+
+ try {
+ TypeExtractor.getMapReturnTypes(function4, (TypeInformation) new WritableTypeInfo<MyWritable>(MyWritable.class));
+ Assert.fail("exception expected");
+ } catch (InvalidTypesException e) {
+ // right
+ }
+ }
+
+ public static class DummyFlatMapFunction<A,B,C,D> extends RichFlatMapFunction<Tuple2<A,B>, Tuple2<C,D>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void flatMap(Tuple2<A, B> value, Collector<Tuple2<C, D>> out) throws Exception {
+
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testTypeErasure() {
+ TypeInformation<?> ti = TypeExtractor.getFlatMapReturnTypes(new DummyFlatMapFunction<String, Integer, String, Boolean>(),
+ (TypeInformation) TypeInfoParser.parse("Tuple2<String, Integer>"), "name", true);
+ Assert.assertTrue(ti instanceof MissingTypeInfo);
+
+ try {
+ TypeExtractor.getFlatMapReturnTypes(new DummyFlatMapFunction<String, Integer, String, Boolean>(),
+ (TypeInformation) TypeInfoParser.parse("Tuple2<String, Integer>"));
+
+ Assert.fail("Expected an exception");
+ }
+ catch (InvalidTypesException e) {
+ // expected
+ }
+ }
+
+ public static class MyQueryableMapper<A> extends RichMapFunction<String, A> implements ResultTypeQueryable<A> {
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public TypeInformation<A> getProducedType() {
+ return (TypeInformation<A>) BasicTypeInfo.INT_TYPE_INFO;
+ }
+
+ @Override
+ public A map(String value) throws Exception {
+ return null;
+ }
+ }
+
+ @Test
+ public void testResultTypeQueryable() {
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(new MyQueryableMapper<Integer>(), BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
+ }
+
+ @Test
+ public void testTupleWithPrimitiveArray() {
+ RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>> function = new RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple9<int[], double[], long[], byte[], char[], float[], short[], boolean[], String[]> map(Integer value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.INT_TYPE_INFO);
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(2));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(3));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(4));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(5));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(6));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(7));
+ Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, tti.getTypeAt(8));
+ }
+
+ @Test
+ public void testFunction() {
+ RichMapFunction<String, Boolean> mapInterface = new RichMapFunction<String, Boolean>() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setRuntimeContext(RuntimeContext t) {
+
+ }
+
+ @Override
+ public void open(Configuration parameters) throws Exception {
+ }
+
+ @Override
+ public RuntimeContext getRuntimeContext() {
+ return null;
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+
+ @Override
+ public Boolean map(String record) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(mapInterface, BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
+ }
+
+ @Test
+ public void testInterface() {
+ MapFunction<String, Boolean> mapInterface = new MapFunction<String, Boolean>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Boolean map(String record) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(mapInterface, BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
+ }
+
+ @Test
+ public void testCreateTypeInfoFromInstance() {
+ ResultTypeQueryable instance = new ResultTypeQueryable<Long>() {
+ @Override
+ public TypeInformation<Long> getProducedType() {
+ return BasicTypeInfo.LONG_TYPE_INFO;
+ }
+ };
+ TypeInformation<?> ti = TypeExtractor.createTypeInfo(instance, null, null, 0);
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ti);
+
+ // method also needs to work for instances that do not implement ResultTypeQueryable
+ MapFunction<Integer, Long> func = new MapFunction<Integer, Long>() {
+ @Override
+ public Long map(Integer value) throws Exception {
+ return value.longValue();
+ }
+ };
+ ti = TypeExtractor.createTypeInfo(func, MapFunction.class, func.getClass(), 0);
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
+ }
+
+ @SuppressWarnings({ "serial", "unchecked", "rawtypes" })
+ @Test
+ public void testExtractKeySelector() {
+ KeySelector<String, Integer> selector = new KeySelector<String, Integer>() {
+ @Override
+ public Integer getKey(String value) { return null; }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getKeySelectorTypes(selector, BasicTypeInfo.STRING_TYPE_INFO);
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
+
+ try {
+ TypeExtractor.getKeySelectorTypes((KeySelector) selector, BasicTypeInfo.BOOLEAN_TYPE_INFO);
+ Assert.fail();
+ }
+ catch (InvalidTypesException e) {
+ // good
+ }
+ catch (Exception e) {
+ Assert.fail("wrong exception type");
+ }
+ }
+
+ public static class DuplicateValue<T> implements MapFunction<Tuple1<T>, Tuple2<T, T>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<T, T> map(Tuple1<T> vertex) {
+ return new Tuple2<T, T>(vertex.f0, vertex.f0);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testDuplicateValue() {
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) new DuplicateValue<String>(), TypeInfoParser.parse("Tuple1<String>"));
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public static class DuplicateValueNested<T> implements MapFunction<Tuple1<Tuple1<T>>, Tuple2<T, T>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<T, T> map(Tuple1<Tuple1<T>> vertex) {
+ return new Tuple2<T, T>(null, null);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testDuplicateValueNested() {
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) new DuplicateValueNested<String>(), TypeInfoParser.parse("Tuple1<Tuple1<String>>"));
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(2, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public static class Edge<K, V> extends Tuple3<K, K, V> {
+ private static final long serialVersionUID = 1L;
+
+ }
+
+ public static class EdgeMapper<K, V> implements MapFunction<Edge<K, V>, Edge<K, V>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Edge<K, V> map(Edge<K, V> value) throws Exception {
+ return null;
+ }
+
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testInputInference1() {
+ EdgeMapper<String, Double> em = new EdgeMapper<String, Double>();
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Tuple3<String, String, Double>"));
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(3, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
+ }
+
+ public static class EdgeMapper2<V> implements MapFunction<V, Edge<Long, V>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Edge<Long, V> map(V value) throws Exception {
+ return null;
+ }
+
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testInputInference2() {
+ EdgeMapper2<Boolean> em = new EdgeMapper2<Boolean>();
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Boolean"));
+ Assert.assertTrue(ti.isTupleType());
+ Assert.assertEquals(3, ti.getArity());
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(2));
+ }
+
+ public static class EdgeMapper3<K, V> implements MapFunction<Edge<K, V>, V> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public V map(Edge<K, V> value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testInputInference3() {
+ EdgeMapper3<Boolean, String> em = new EdgeMapper3<Boolean, String>();
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Tuple3<Boolean,Boolean,String>"));
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
+ }
+
+ public static class EdgeMapper4<K, V> implements MapFunction<Edge<K, V>[], V> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public V map(Edge<K, V>[] value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testInputInference4() {
+ EdgeMapper4<Boolean, String> em = new EdgeMapper4<Boolean, String>();
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Tuple3<Boolean,Boolean,String>[]"));
+ Assert.assertTrue(ti.isBasicType());
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
+ }
+
+ public static enum MyEnum {
+ ONE, TWO, THREE
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testEnumType() {
+ MapFunction<?, ?> mf = new MapFunction<MyEnum, MyEnum>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public MyEnum map(MyEnum value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) mf, new EnumTypeInfo(MyEnum.class));
+ Assert.assertTrue(ti instanceof EnumTypeInfo);
+ Assert.assertEquals(ti.getTypeClass(), MyEnum.class);
+ }
+
+ public static class MapperWithMultiDimGenericArray<T> implements MapFunction<T[][][], Tuple1<T>[][][]> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple1<T>[][][] map(T[][][] value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testMultiDimensionalArray() {
+ // tuple array
+ MapFunction<?,?> function = new MapFunction<Tuple2<Integer, Double>[][], Tuple2<Integer, Double>[][]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<Integer, Double>[][] map(
+ Tuple2<Integer, Double>[][] value) throws Exception {
+ return null;
+ }
+ };
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("Tuple2<Integer, Double>[][]"));
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<Java Tuple2<Integer, Double>>>", ti.toString());
+
+ // primitive array
+ function = new MapFunction<int[][][], int[][][]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public int[][][] map(
+ int[][][] value) throws Exception {
+ return null;
+ }
+ };
+ ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("int[][][]"));
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<int[]>>", ti.toString());
+
+ // basic array
+ function = new MapFunction<Integer[][][], Integer[][][]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Integer[][][] map(
+ Integer[][][] value) throws Exception {
+ return null;
+ }
+ };
+ ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("Integer[][][]"));
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<BasicArrayTypeInfo<Integer>>>", ti.toString());
+
+ // pojo array
+ function = new MapFunction<CustomType[][][], CustomType[][][]>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public CustomType[][][] map(
+ CustomType[][][] value) throws Exception {
+ return null;
+ }
+ };
+ ti = TypeExtractor.getMapReturnTypes((MapFunction)function,
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.TypeExtractorTest$CustomType<"
+ + "myField1=String,myField2=int"
+ + ">[][][]"));
+
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
+ + "PojoType<org.apache.flink.api.java.typeutils.TypeExtractorTest$CustomType, fields = [myField1: String, myField2: Integer]>"
+ + ">>>", ti.toString());
+
+ // generic array
+ ti = TypeExtractor.getMapReturnTypes((MapFunction) new MapperWithMultiDimGenericArray<String>(), TypeInfoParser.parse("String[][][]"));
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<Java Tuple1<String>>>>", ti.toString());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static class MapWithResultTypeQueryable implements MapFunction, ResultTypeQueryable {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public TypeInformation getProducedType() {
+ return BasicTypeInfo.STRING_TYPE_INFO;
+ }
+
+ @Override
+ public Object map(Object value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testInputMismatchWithRawFuntion() {
+ MapFunction<?, ?> function = new MapWithResultTypeQueryable();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction)function, BasicTypeInfo.INT_TYPE_INFO);
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
+ }
+
+ public static class Either1<T> extends Either<String, T> {
+ @Override
+ public String left() throws IllegalStateException {
+ return null;
+ }
+
+ @Override
+ public T right() throws IllegalStateException {
+ return null;
+ }
+ }
+
+ public static class Either2 extends Either1<Tuple1<Integer>> {
+ // nothing to do here
+ }
+
+ public static class EitherMapper<T> implements MapFunction<T, Either1<T>> {
+ @Override
+ public Either1<T> map(T value) throws Exception {
+ return null;
+ }
+ }
+
+ public static class EitherMapper2 implements MapFunction<String, Either2> {
+ @Override
+ public Either2 map(String value) throws Exception {
+ return null;
+ }
+ }
+
+ public static class EitherMapper3 implements MapFunction<Either2, Either2> {
+ @Override
+ public Either2 map(Either2 value) throws Exception {
+ return null;
+ }
+ }
+
+ @Test
+ public void testEither() {
+ MapFunction<?, ?> function = new MapFunction<Either<String, Boolean>, Either<String, Boolean>>() {
+ @Override
+ public Either<String, Boolean> map(Either<String, Boolean> value) throws Exception {
+ return null;
+ }
+ };
+ TypeInformation<?> expected = new EitherTypeInfo(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.BOOLEAN_TYPE_INFO);
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) function, expected);
+ Assert.assertEquals(expected, ti);
+ }
+
+ @Test
+ public void testEitherHierarchy() {
+ MapFunction<?, ?> function = new EitherMapper<Boolean>();
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) function, BasicTypeInfo.BOOLEAN_TYPE_INFO);
+ TypeInformation<?> expected = new EitherTypeInfo(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.BOOLEAN_TYPE_INFO);
+ Assert.assertEquals(expected, ti);
+
+ function = new EitherMapper2();
+ ti = TypeExtractor.getMapReturnTypes((MapFunction) function, BasicTypeInfo.STRING_TYPE_INFO);
+ expected = new EitherTypeInfo(BasicTypeInfo.STRING_TYPE_INFO, new TupleTypeInfo(BasicTypeInfo.INT_TYPE_INFO));
+ Assert.assertEquals(expected, ti);
+
+ function = new EitherMapper3();
+ ti = TypeExtractor.getMapReturnTypes((MapFunction) function, expected);
+ Assert.assertEquals(expected, ti);
+
+ Either<String, Tuple1<Integer>> either = new Either2();
+ ti = TypeExtractor.getForObject(either);
+ Assert.assertEquals(expected, ti);
+ }
+
+ @Test(expected=InvalidTypesException.class)
+ public void testEitherFromObjectException() {
+ Either<String, Tuple1<Integer>> either = Either.Left("test");
+ TypeExtractor.getForObject(either);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java
new file mode 100644
index 0000000..e225460
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeInfoParserTest.java
@@ -0,0 +1,338 @@
+/*
+ * 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.java.typeutils;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.types.BooleanValue;
+import org.apache.flink.types.ByteValue;
+import org.apache.flink.types.CharValue;
+import org.apache.flink.types.DoubleValue;
+import org.apache.flink.types.FloatValue;
+import org.apache.flink.types.IntValue;
+import org.apache.flink.types.ListValue;
+import org.apache.flink.types.LongValue;
+import org.apache.flink.types.MapValue;
+import org.apache.flink.types.NullValue;
+import org.apache.flink.types.ShortValue;
+import org.apache.flink.types.StringValue;
+import org.apache.hadoop.io.Writable;
+import org.junit.Test;
+
+public class TypeInfoParserTest {
+
+ @Test
+ public void testBasicTypes() {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, TypeInfoParser.parse("Integer"));
+ Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, TypeInfoParser.parse("Double"));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, TypeInfoParser.parse("Byte"));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, TypeInfoParser.parse("Float"));
+ Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, TypeInfoParser.parse("Short"));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, TypeInfoParser.parse("Long"));
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, TypeInfoParser.parse("Character"));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, TypeInfoParser.parse("String"));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeInfoParser.parse("Boolean"));
+ Assert.assertEquals(BasicTypeInfo.VOID_TYPE_INFO, TypeInfoParser.parse("Void"));
+ Assert.assertEquals(BasicTypeInfo.DATE_TYPE_INFO, TypeInfoParser.parse("Date"));
+
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, TypeInfoParser.parse("java.lang.Integer"));
+ Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, TypeInfoParser.parse("java.lang.Double"));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, TypeInfoParser.parse("java.lang.Byte"));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, TypeInfoParser.parse("java.lang.Float"));
+ Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, TypeInfoParser.parse("java.lang.Short"));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, TypeInfoParser.parse("java.lang.Long"));
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, TypeInfoParser.parse("java.lang.Character"));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, TypeInfoParser.parse("java.lang.String"));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeInfoParser.parse("java.lang.Boolean"));
+ Assert.assertEquals(BasicTypeInfo.VOID_TYPE_INFO, TypeInfoParser.parse("java.lang.Void"));
+ Assert.assertEquals(BasicTypeInfo.DATE_TYPE_INFO, TypeInfoParser.parse("java.util.Date"));
+
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, TypeInfoParser.parse("int"));
+ Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, TypeInfoParser.parse("double"));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, TypeInfoParser.parse("byte"));
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, TypeInfoParser.parse("float"));
+ Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, TypeInfoParser.parse("short"));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, TypeInfoParser.parse("long"));
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, TypeInfoParser.parse("char"));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeInfoParser.parse("boolean"));
+ Assert.assertEquals(BasicTypeInfo.VOID_TYPE_INFO, TypeInfoParser.parse("void"));
+ }
+
+ @Test
+ public void testValueTypes() {
+ helperValueType("StringValue", StringValue.class);
+ helperValueType("IntValue", IntValue.class);
+ helperValueType("ByteValue", ByteValue.class);
+ helperValueType("ShortValue", ShortValue.class);
+ helperValueType("CharValue", CharValue.class);
+ helperValueType("DoubleValue", DoubleValue.class);
+ helperValueType("FloatValue", FloatValue.class);
+ helperValueType("LongValue", LongValue.class);
+ helperValueType("BooleanValue", BooleanValue.class);
+ helperValueType("ListValue", ListValue.class);
+ helperValueType("MapValue", MapValue.class);
+ helperValueType("NullValue", NullValue.class);
+ }
+
+ private static void helperValueType(String str, Class<?> clazz) {
+ TypeInformation<?> ti = TypeInfoParser.parse(str);
+ Assert.assertTrue(ti instanceof ValueTypeInfo);
+ ValueTypeInfo<?> vti = (ValueTypeInfo<?>) ti;
+ Assert.assertEquals(clazz, vti.getTypeClass());
+ }
+
+ @Test
+ public void testBasicArrays() {
+ Assert.assertEquals(BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, TypeInfoParser.parse("Integer[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.DOUBLE_ARRAY_TYPE_INFO, TypeInfoParser.parse("Double[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.BYTE_ARRAY_TYPE_INFO, TypeInfoParser.parse("Byte[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.FLOAT_ARRAY_TYPE_INFO, TypeInfoParser.parse("Float[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.SHORT_ARRAY_TYPE_INFO, TypeInfoParser.parse("Short[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.LONG_ARRAY_TYPE_INFO, TypeInfoParser.parse("Long[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.CHAR_ARRAY_TYPE_INFO, TypeInfoParser.parse("Character[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, TypeInfoParser.parse("String[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO, TypeInfoParser.parse("Boolean[]"));
+
+ Assert.assertEquals(BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Integer[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.DOUBLE_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Double[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.BYTE_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Byte[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.FLOAT_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Float[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.SHORT_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Short[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.LONG_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Long[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.CHAR_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Character[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.String[]"));
+ Assert.assertEquals(BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO, TypeInfoParser.parse("java.lang.Boolean[]"));
+
+ Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("int[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("double[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("byte[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("float[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("short[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("long[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("char[]"));
+ Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, TypeInfoParser.parse("boolean[]"));
+ }
+
+ @Test
+ public void testTuples() {
+ TypeInformation<?> ti = TypeInfoParser.parse("Tuple2<Integer, Long>");
+ Assert.assertEquals(2, ti.getArity());
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>)ti).getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>)ti).getTypeAt(1));
+
+ ti = TypeInfoParser.parse("Tuple0");
+ Assert.assertEquals(0, ti.getArity());
+ Assert.assertEquals("Java Tuple0", ti.toString());
+
+ ti = TypeInfoParser.parse("org.apache.flink.api.java.tuple.Tuple0");
+ Assert.assertEquals(0, ti.getArity());
+ Assert.assertEquals("Java Tuple0", ti.toString());
+
+ ti = TypeInfoParser.parse("Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>");
+ Assert.assertEquals("Java Tuple3<Java Tuple1<String>, Java Tuple1<Integer>, Java Tuple2<Long, Long>>", ti.toString());
+ }
+
+ @Test
+ public void testGenericType() {
+ TypeInformation<?> ti = TypeInfoParser.parse("java.lang.Class");
+ Assert.assertTrue(ti instanceof GenericTypeInfo);
+ Assert.assertEquals(Class.class, ((GenericTypeInfo<?>) ti).getTypeClass());
+ }
+
+ public static class MyPojo {
+ public Integer basic;
+ public Tuple2<String, Integer> tuple;
+ public MyWritable hadoopCitizen;
+ public String[] array;
+ }
+
+ @Test
+ public void testPojoType() {
+ TypeInformation<?> ti = TypeInfoParser.parse(
+ "org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<"
+ + "basic=Integer,"
+ + "tuple=Tuple2<String, Integer>,"
+ + "hadoopCitizen=Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>,"
+ + "array=String[]"
+ + ">");
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
+ Assert.assertEquals("array", pti.getPojoFieldAt(0).getField().getName());
+ Assert.assertTrue(pti.getPojoFieldAt(0).getTypeInformation() instanceof BasicArrayTypeInfo);
+ Assert.assertEquals("basic", pti.getPojoFieldAt(1).getField().getName());
+ Assert.assertTrue(pti.getPojoFieldAt(1).getTypeInformation() instanceof BasicTypeInfo);
+ Assert.assertEquals("hadoopCitizen", pti.getPojoFieldAt(2).getField().getName());
+ Assert.assertTrue(pti.getPojoFieldAt(2).getTypeInformation() instanceof WritableTypeInfo);
+ Assert.assertEquals("tuple", pti.getPojoFieldAt(3).getField().getName());
+ Assert.assertTrue(pti.getPojoFieldAt(3).getTypeInformation() instanceof TupleTypeInfo);
+ }
+
+ @Test
+ public void testPojoType2() {
+ TypeInformation<?> ti = TypeInfoParser.parse("Tuple2<String,Tuple2<Integer,org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<basic=String>>>");
+ Assert.assertTrue(ti instanceof TupleTypeInfo);
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertTrue(tti.getTypeAt(0) instanceof BasicTypeInfo);
+ Assert.assertTrue(tti.getTypeAt(1) instanceof TupleTypeInfo);
+ TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>)(Object)tti.getTypeAt(1);
+ Assert.assertTrue(tti2.getTypeAt(0) instanceof BasicTypeInfo);
+ Assert.assertTrue(tti2.getTypeAt(1) instanceof PojoTypeInfo);
+ PojoTypeInfo<?> pti = (PojoTypeInfo<?>) tti2.getTypeAt(1);
+ Assert.assertEquals("basic", pti.getPojoFieldAt(0).getField().getName());
+ Assert.assertTrue(pti.getPojoFieldAt(0).getTypeInformation() instanceof BasicTypeInfo);
+ }
+
+ public static class MyWritable implements Writable {
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+
+ }
+
+ }
+
+ @Test
+ public void testWritableType() {
+ TypeInformation<?> ti = TypeInfoParser.parse("Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>");
+ Assert.assertTrue(ti instanceof WritableTypeInfo<?>);
+ Assert.assertEquals(MyWritable.class, ((WritableTypeInfo<?>) ti).getTypeClass());
+ }
+
+ @Test
+ public void testObjectArrays() {
+ TypeInformation<?> ti = TypeInfoParser.parse("java.lang.Class[]");
+
+ Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
+ Assert.assertEquals(Class.class, ((ObjectArrayTypeInfo<?, ?>) ti).getComponentInfo().getTypeClass());
+
+ TypeInformation<?> ti2 = TypeInfoParser.parse("Tuple2<Integer,Double>[]");
+
+ Assert.assertTrue(ti2 instanceof ObjectArrayTypeInfo<?, ?>);
+ Assert.assertTrue(((ObjectArrayTypeInfo<?, ?>) ti2).getComponentInfo() instanceof TupleTypeInfo);
+
+ TypeInformation<?> ti3 = TypeInfoParser.parse("Tuple2<Integer[],Double>[]");
+ Assert.assertEquals("ObjectArrayTypeInfo<Java Tuple2<BasicArrayTypeInfo<Integer>, Double>>", ti3.toString());
+ }
+
+ @Test
+ public void testLargeMixedTuple() {
+ TypeInformation<?> ti = TypeInfoParser.parse("org.apache.flink.api.java.tuple.Tuple4<Double,java.lang.Class[],StringValue,Tuple1<int>>[]");
+ Assert.assertEquals("ObjectArrayTypeInfo<Java Tuple4<Double, ObjectArrayTypeInfo<GenericType<java.lang.Class>>, ValueType<StringValue>, Java Tuple1<Integer>>>", ti.toString());
+ }
+
+ public static enum MyEnum {
+ ONE, TWO, THREE
+ }
+
+ @Test
+ public void testEnumType() {
+ TypeInformation<?> ti = TypeInfoParser.parse("Enum<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>");
+ Assert.assertEquals("EnumTypeInfo<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>", ti.toString());
+
+ TypeInformation<?> ti2 = TypeInfoParser.parse("java.lang.Enum<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>");
+ Assert.assertEquals("EnumTypeInfo<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>", ti2.toString());
+ }
+
+ @Test
+ public void testException() {
+ try {
+ TypeInfoParser.parse("THIS_CLASS_DOES_NOT_EXIST");
+ Assert.fail("exception expected");
+ } catch (IllegalArgumentException e) {
+ // right
+ }
+
+ try {
+ TypeInfoParser.parse("Tuple2<Integer>");
+ Assert.fail("exception expected");
+ } catch (IllegalArgumentException e) {
+ // right
+ }
+
+ try {
+ TypeInfoParser.parse("Tuple3<Integer,,>");
+ Assert.fail("exception expected");
+ } catch (IllegalArgumentException e) {
+ // right
+ }
+
+ try {
+ TypeInfoParser.parse("Tuple1<Integer,Double>");
+ Assert.fail("exception expected");
+ } catch (IllegalArgumentException e) {
+ // right
+ }
+ }
+
+ @Test
+ public void testMultiDimensionalArray() {
+ // tuple
+ TypeInformation<?> ti = TypeInfoParser.parse("Tuple2<Integer, Double>[][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<Java Tuple2<Integer, Double>>>", ti.toString());
+
+ // pojos
+ ti = TypeInfoParser.parse("org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<basic=String>[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
+ + "PojoType<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo, fields = [basic: String]>"
+ + ">>>", ti.toString());
+
+ // basic types
+ ti = TypeInfoParser.parse("Float[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<BasicArrayTypeInfo<Float>>>", ti.toString());
+ ti = TypeInfoParser.parse("String[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<BasicArrayTypeInfo<String>>>", ti.toString());
+ ti = TypeInfoParser.parse("Date[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<Date>>>", ti.toString());
+
+ // primitive types
+ ti = TypeInfoParser.parse("int[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<int[]>>", ti.toString());
+ ti = TypeInfoParser.parse("boolean[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<boolean[]>>", ti.toString());
+
+ // value types
+ ti = TypeInfoParser.parse("IntValue[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<ValueType<IntValue>>>>", ti.toString());
+
+ // writable types
+ ti = TypeInfoParser.parse("Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
+ + "WritableType<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>"
+ + ">>>", ti.toString());
+
+ // enum types
+ ti = TypeInfoParser.parse("Enum<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>[][][]");
+ Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
+ + "EnumTypeInfo<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyEnum>"
+ + ">>>", ti.toString());
+ }
+}
[13/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java
new file mode 100644
index 0000000..a196984
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java
@@ -0,0 +1,79 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.junit.Assert;
+
+public class TupleSerializerTestInstance<T extends Tuple> extends SerializerTestInstance<T> {
+
+ public TupleSerializerTestInstance(TypeSerializer<T> serializer, Class<T> typeClass, int length, T[] testData) {
+ super(serializer, typeClass, length, testData);
+ }
+
+ protected void deepEquals(String message, T shouldTuple, T isTuple) {
+ Assert.assertEquals(shouldTuple.getArity(), isTuple.getArity());
+
+ for (int i = 0; i < shouldTuple.getArity(); i++) {
+ Object should = shouldTuple.getField(i);
+ Object is = isTuple.getField(i);
+
+ if (should.getClass().isArray()) {
+ if (should instanceof boolean[]) {
+ Assert.assertTrue(message, Arrays.equals((boolean[]) should, (boolean[]) is));
+ }
+ else if (should instanceof byte[]) {
+ assertArrayEquals(message, (byte[]) should, (byte[]) is);
+ }
+ else if (should instanceof short[]) {
+ assertArrayEquals(message, (short[]) should, (short[]) is);
+ }
+ else if (should instanceof int[]) {
+ assertArrayEquals(message, (int[]) should, (int[]) is);
+ }
+ else if (should instanceof long[]) {
+ assertArrayEquals(message, (long[]) should, (long[]) is);
+ }
+ else if (should instanceof float[]) {
+ assertArrayEquals(message, (float[]) should, (float[]) is, 0.0f);
+ }
+ else if (should instanceof double[]) {
+ assertArrayEquals(message, (double[]) should, (double[]) is, 0.0);
+ }
+ else if (should instanceof char[]) {
+ assertArrayEquals(message, (char[]) should, (char[]) is);
+ }
+ else {
+ assertArrayEquals(message, (Object[]) should, (Object[]) is);
+ }
+ }
+ else {
+ assertEquals(message, should, is);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java
new file mode 100644
index 0000000..cf9874d
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.types.StringValue;
+
+public class ValueComparatorTest extends ComparatorTestBase<StringValue> {
+
+ StringValue[] data = new StringValue[]{
+ new StringValue(""),
+ new StringValue("Lorem Ipsum Dolor Omit Longer"),
+ new StringValue("aaaa"),
+ new StringValue("abcd"),
+ new StringValue("abce"),
+ new StringValue("abdd"),
+ new StringValue("accd"),
+ new StringValue("bbcd")
+ };
+
+ @Override
+ protected TypeComparator<StringValue> createComparator(boolean ascending) {
+ return new ValueComparator<StringValue>(ascending, StringValue.class);
+ }
+
+ @Override
+ protected TypeSerializer<StringValue> createSerializer() {
+ return new ValueSerializer<StringValue>(StringValue.class);
+ }
+
+ @Override
+ protected StringValue[] getSortedTestData() {
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java
new file mode 100644
index 0000000..a2c3e1e
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+import java.util.UUID;
+
+public class ValueComparatorUUIDTest extends ComparatorTestBase<ValueID> {
+ @Override
+ protected TypeComparator<ValueID> createComparator(boolean ascending) {
+ return new ValueComparator<>(ascending, ValueID.class);
+ }
+
+ @Override
+ protected TypeSerializer<ValueID> createSerializer() {
+ return new ValueSerializer<>(ValueID.class);
+ }
+
+ @Override
+ protected ValueID[] getSortedTestData() {
+ return new ValueID[] {
+ new ValueID(new UUID(0, 0)),
+ new ValueID(new UUID(1, 0)),
+ new ValueID(new UUID(1, 1))
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java
new file mode 100644
index 0000000..d644485
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java
@@ -0,0 +1,72 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.types.Value;
+
+import java.io.IOException;
+import java.util.UUID;
+
+public class ValueID implements Value, Comparable<ValueID> {
+ private static final long serialVersionUID = -562791433077971752L;
+
+ private UUID id;
+
+ public ValueID() {
+ id = UUID.randomUUID();
+ }
+
+ public ValueID(UUID id) {
+ this.id = id;
+ }
+
+ @Override
+ public int compareTo(ValueID o) {
+ return id.compareTo(o.id);
+ }
+
+ @Override
+ public void write(DataOutputView out) throws IOException {
+ out.writeLong(id.getMostSignificantBits());
+ out.writeLong(id.getLeastSignificantBits());
+ }
+
+ @Override
+ public void read(DataInputView in) throws IOException {
+ id = new UUID(in.readLong(), in.readLong());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ValueID) {
+ ValueID other = (ValueID) obj;
+
+ return id.equals(other.id);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java
new file mode 100644
index 0000000..9c07a5e
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.SerializerTestBase;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+import java.util.UUID;
+
+public class ValueSerializerUUIDTest extends SerializerTestBase<ValueID> {
+ @Override
+ protected TypeSerializer<ValueID> createSerializer() {
+ return new ValueSerializer<>(ValueID.class);
+ }
+
+ @Override
+ protected int getLength() {
+ return -1;
+ }
+
+ @Override
+ protected Class<ValueID> getTypeClass() {
+ return ValueID.class;
+ }
+
+ @Override
+ protected ValueID[] getTestData() {
+ return new ValueID[] {
+ new ValueID(new UUID(0, 0)),
+ new ValueID(new UUID(1, 0)),
+ new ValueID(new UUID(1, 1))
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java
new file mode 100644
index 0000000..f5a90b7
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+public class WritableComparatorTest extends ComparatorTestBase<StringArrayWritable> {
+
+ StringArrayWritable[] data = new StringArrayWritable[]{
+ new StringArrayWritable(new String[]{}),
+ new StringArrayWritable(new String[]{""}),
+ new StringArrayWritable(new String[]{"a","a"}),
+ new StringArrayWritable(new String[]{"a","b"}),
+ new StringArrayWritable(new String[]{"c","c"}),
+ new StringArrayWritable(new String[]{"d","f"}),
+ new StringArrayWritable(new String[]{"d","m"}),
+ new StringArrayWritable(new String[]{"z","x"}),
+ new StringArrayWritable(new String[]{"a","a", "a"})
+ };
+
+ @Override
+ protected TypeComparator<StringArrayWritable> createComparator(boolean ascending) {
+ return new WritableComparator<StringArrayWritable>(ascending, StringArrayWritable.class);
+ }
+
+ @Override
+ protected TypeSerializer<StringArrayWritable> createSerializer() {
+ return new WritableSerializer<StringArrayWritable>(StringArrayWritable.class);
+ }
+
+ @Override
+ protected StringArrayWritable[] getSortedTestData() {
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java
new file mode 100644
index 0000000..94e759d
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+import java.util.UUID;
+
+public class WritableComparatorUUIDTest extends ComparatorTestBase<WritableID> {
+ @Override
+ protected TypeComparator<WritableID> createComparator(boolean ascending) {
+ return new WritableComparator<>(ascending, WritableID.class);
+ }
+
+ @Override
+ protected TypeSerializer<WritableID> createSerializer() {
+ return new WritableSerializer<>(WritableID.class);
+ }
+
+ @Override
+ protected WritableID[] getSortedTestData() {
+ return new WritableID[] {
+ new WritableID(new UUID(0, 0)),
+ new WritableID(new UUID(1, 0)),
+ new WritableID(new UUID(1, 1))
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java
new file mode 100644
index 0000000..4274cf6
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java
@@ -0,0 +1,78 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.hadoop.io.WritableComparable;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.UUID;
+
+public class WritableID implements WritableComparable<WritableID> {
+ private UUID uuid;
+
+ public WritableID() {
+ this.uuid = UUID.randomUUID();
+ }
+
+ public WritableID(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public int compareTo(WritableID o) {
+ return this.uuid.compareTo(o.uuid);
+ }
+
+ @Override
+ public void write(DataOutput dataOutput) throws IOException {
+ dataOutput.writeLong(uuid.getMostSignificantBits());
+ dataOutput.writeLong(uuid.getLeastSignificantBits());
+ }
+
+ @Override
+ public void readFields(DataInput dataInput) throws IOException {
+ this.uuid = new UUID(dataInput.readLong(), dataInput.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return uuid.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ WritableID id = (WritableID) o;
+
+ return !(uuid != null ? !uuid.equals(id.uuid) : id.uuid != null);
+ }
+
+ @Override
+ public int hashCode() {
+ return uuid != null ? uuid.hashCode() : 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java
new file mode 100644
index 0000000..bb5f4d4
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.api.java.typeutils.WritableTypeInfo;
+import org.junit.Test;
+
+public class WritableSerializerTest {
+
+ @Test
+ public void testStringArrayWritable() {
+ StringArrayWritable[] data = new StringArrayWritable[]{
+ new StringArrayWritable(new String[]{}),
+ new StringArrayWritable(new String[]{""}),
+ new StringArrayWritable(new String[]{"a","a"}),
+ new StringArrayWritable(new String[]{"a","b"}),
+ new StringArrayWritable(new String[]{"c","c"}),
+ new StringArrayWritable(new String[]{"d","f"}),
+ new StringArrayWritable(new String[]{"d","m"}),
+ new StringArrayWritable(new String[]{"z","x"}),
+ new StringArrayWritable(new String[]{"a","a", "a"})
+ };
+
+ WritableTypeInfo<StringArrayWritable> writableTypeInfo = (WritableTypeInfo<StringArrayWritable>) TypeExtractor.getForObject(data[0]);
+ WritableSerializer<StringArrayWritable> writableSerializer = (WritableSerializer<StringArrayWritable>) writableTypeInfo.createSerializer(new ExecutionConfig());
+
+ SerializerTestInstance<StringArrayWritable> testInstance = new SerializerTestInstance<StringArrayWritable>(writableSerializer,writableTypeInfo.getTypeClass(), -1, data);
+
+ testInstance.testAll();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java
new file mode 100644
index 0000000..2af7730
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.SerializerTestBase;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+import java.util.UUID;
+
+public class WritableSerializerUUIDTest extends SerializerTestBase<WritableID> {
+ @Override
+ protected TypeSerializer<WritableID> createSerializer() {
+ return new WritableSerializer<>(WritableID.class);
+ }
+
+ @Override
+ protected int getLength() {
+ return -1;
+ }
+
+ @Override
+ protected Class<WritableID> getTypeClass() {
+ return WritableID.class;
+ }
+
+ @Override
+ protected WritableID[] getTestData() {
+ return new WritableID[] {
+ new WritableID(new UUID(0, 0)),
+ new WritableID(new UUID(1, 0)),
+ new WritableID(new UUID(1, 1))
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java
new file mode 100644
index 0000000..7572408
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java
@@ -0,0 +1,287 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataInputViewStreamWrapper;
+import org.apache.flink.core.memory.DataOutputView;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class KryoClearedBufferTest {
+
+ /**
+ * Tests that the kryo output buffer is cleared in case of an exception. Flink uses the
+ * EOFException to signal that a buffer is full. In such a case, the record which was tried
+ * to be written will be rewritten. Therefore, eventually buffered data of this record has
+ * to be cleared.
+ */
+ @Test
+ public void testOutputBufferedBeingClearedInCaseOfException() throws Exception {
+ ExecutionConfig executionConfig = new ExecutionConfig();
+ executionConfig.registerTypeWithKryoSerializer(TestRecord.class, new TestRecordSerializer());
+ executionConfig.registerKryoType(TestRecord.class);
+
+ KryoSerializer<TestRecord> kryoSerializer = new KryoSerializer<TestRecord>(
+ TestRecord.class,
+ executionConfig);
+
+ int size = 94;
+ int bufferSize = 150;
+
+ TestRecord testRecord = new TestRecord(size);
+
+ TestDataOutputView target = new TestDataOutputView(bufferSize);
+
+ kryoSerializer.serialize(testRecord, target);
+
+ try {
+ kryoSerializer.serialize(testRecord, target);
+ Assert.fail("Expected an EOFException.");
+ } catch(EOFException eofException) {
+ // expected exception
+ // now the Kryo Output should have been cleared
+ }
+
+ TestRecord actualRecord = kryoSerializer.deserialize(
+ new DataInputViewStreamWrapper(new ByteArrayInputStream(target.getBuffer())));
+
+ Assert.assertEquals(testRecord, actualRecord);
+
+ target.clear();
+
+ // if the kryo output has been cleared then we can serialize our test record into the target
+ // because the target buffer 150 bytes can host one TestRecord (total serialization size 100)
+ kryoSerializer.serialize(testRecord, target);
+
+ byte[] buffer = target.getBuffer();
+ int counter = 0;
+
+ for (int i = 0; i < buffer.length; i++) {
+ if(buffer[i] == 42) {
+ counter++;
+ }
+ }
+
+ Assert.assertEquals(size, counter);
+ }
+
+ public static class TestRecord {
+ private byte[] buffer;
+
+ public TestRecord(int size) {
+ buffer = new byte[size];
+
+ Arrays.fill(buffer, (byte)42);
+ }
+
+ public TestRecord(byte[] buffer){
+ this.buffer = buffer;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TestRecord) {
+ TestRecord record = (TestRecord) obj;
+
+ return Arrays.equals(buffer, record.buffer);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public static class TestRecordSerializer extends Serializer<TestRecord> implements Serializable {
+
+ private static final long serialVersionUID = 6971996565421454985L;
+
+ @Override
+ public void write(Kryo kryo, Output output, TestRecord object) {
+ output.writeInt(object.buffer.length);
+ output.write(object.buffer);
+ }
+
+ @Override
+ public TestRecord read(Kryo kryo, Input input, Class<TestRecord> type) {
+ int length = input.readInt();
+ byte[] buffer = input.readBytes(length);
+
+ return new TestRecord(buffer);
+ }
+ }
+
+ public static class TestDataOutputView implements DataOutputView {
+
+ private byte[] buffer;
+ private int position;
+
+ public TestDataOutputView(int size) {
+ buffer = new byte[size];
+ position = 0;
+ }
+
+ public void clear() {
+ position = 0;
+ }
+
+ public byte[] getBuffer() {
+ return buffer;
+ }
+
+ public void checkSize(int numBytes) throws EOFException {
+ if (position + numBytes > buffer.length) {
+ throw new EOFException();
+ }
+ }
+
+ @Override
+ public void skipBytesToWrite(int numBytes) throws IOException {
+ checkSize(numBytes);
+
+ position += numBytes;
+ }
+
+ @Override
+ public void write(DataInputView source, int numBytes) throws IOException {
+ checkSize(numBytes);
+
+ byte[] tempBuffer = new byte[numBytes];
+
+ source.read(tempBuffer);
+
+ System.arraycopy(tempBuffer, 0, buffer, position, numBytes);
+
+ position += numBytes;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ checkSize(4);
+
+ position += 4;
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ checkSize(b.length);
+
+ System.arraycopy(b, 0, buffer, position, b.length);
+ position += b.length;
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ checkSize(len);
+
+ System.arraycopy(b, off, buffer, position, len);
+
+ position += len;
+ }
+
+ @Override
+ public void writeBoolean(boolean v) throws IOException {
+ checkSize(1);
+ position += 1;
+ }
+
+ @Override
+ public void writeByte(int v) throws IOException {
+ checkSize(1);
+
+ buffer[position] = (byte)v;
+
+ position++;
+ }
+
+ @Override
+ public void writeShort(int v) throws IOException {
+ checkSize(2);
+
+ position += 2;
+ }
+
+ @Override
+ public void writeChar(int v) throws IOException {
+ checkSize(1);
+ position++;
+ }
+
+ @Override
+ public void writeInt(int v) throws IOException {
+ checkSize(4);
+
+ position += 4;
+ }
+
+ @Override
+ public void writeLong(long v) throws IOException {
+ checkSize(8);
+ position += 8;
+ }
+
+ @Override
+ public void writeFloat(float v) throws IOException {
+ checkSize(4);
+ position += 4;
+ }
+
+ @Override
+ public void writeDouble(double v) throws IOException {
+ checkSize(8);
+ position += 8;
+ }
+
+ @Override
+ public void writeBytes(String s) throws IOException {
+ byte[] sBuffer = s.getBytes();
+ checkSize(sBuffer.length);
+ System.arraycopy(sBuffer, 0, buffer, position, sBuffer.length);
+ position += sBuffer.length;
+ }
+
+ @Override
+ public void writeChars(String s) throws IOException {
+ byte[] sBuffer = s.getBytes();
+ checkSize(sBuffer.length);
+ System.arraycopy(sBuffer, 0, buffer, position, sBuffer.length);
+ position += sBuffer.length;
+ }
+
+ @Override
+ public void writeUTF(String s) throws IOException {
+ byte[] sBuffer = s.getBytes();
+ checkSize(sBuffer.length);
+ System.arraycopy(sBuffer, 0, buffer, position, sBuffer.length);
+ position += sBuffer.length;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java
new file mode 100644
index 0000000..9d3eef1
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericArraySerializerTest;
+
+public class KryoGenericArraySerializerTest extends AbstractGenericArraySerializerTest {
+ @Override
+ protected <T> TypeSerializer<T> createComponentSerializer(Class<T> type) {
+ return new KryoSerializer<T>(type, new ExecutionConfig());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java
new file mode 100644
index 0000000..19aed78
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeComparatorTest;
+
+public class KryoGenericTypeComparatorTest extends AbstractGenericTypeComparatorTest {
+ @Override
+ protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
+ return new KryoSerializer<T>(type, new ExecutionConfig());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
new file mode 100644
index 0000000..8ff0b1b
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import com.esotericsoftware.kryo.Kryo;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest;
+import org.apache.flink.api.java.typeutils.runtime.TestDataOutputSerializer;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Random;
+
+import static org.junit.Assert.*;
+
+@SuppressWarnings("unchecked")
+public class KryoGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
+
+ ExecutionConfig ec = new ExecutionConfig();
+
+ @Test
+ public void testJavaList(){
+ Collection<Integer> a = new ArrayList<>();
+
+ fillCollection(a);
+
+ runTests(a);
+ }
+
+ @Test
+ public void testJavaSet(){
+ Collection<Integer> b = new HashSet<>();
+
+ fillCollection(b);
+
+ runTests(b);
+ }
+
+
+
+ @Test
+ public void testJavaDequeue(){
+ Collection<Integer> c = new LinkedList<>();
+ fillCollection(c);
+ runTests(c);
+ }
+
+ private void fillCollection(Collection<Integer> coll) {
+ coll.add(42);
+ coll.add(1337);
+ coll.add(49);
+ coll.add(1);
+ }
+
+ @Override
+ protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
+ return new KryoSerializer<T>(type, ec);
+ }
+
+ /**
+ * Make sure that the kryo serializer forwards EOF exceptions properly when serializing
+ */
+ @Test
+ public void testForwardEOFExceptionWhileSerializing() {
+ try {
+ // construct a long string
+ String str;
+ {
+ char[] charData = new char[40000];
+ Random rnd = new Random();
+
+ for (int i = 0; i < charData.length; i++) {
+ charData[i] = (char) rnd.nextInt(10000);
+ }
+
+ str = new String(charData);
+ }
+
+ // construct a memory target that is too small for the string
+ TestDataOutputSerializer target = new TestDataOutputSerializer(10000, 30000);
+ KryoSerializer<String> serializer = new KryoSerializer<String>(String.class, new ExecutionConfig());
+
+ try {
+ serializer.serialize(str, target);
+ fail("should throw a java.io.EOFException");
+ }
+ catch (java.io.EOFException e) {
+ // that is how we like it
+ }
+ catch (Exception e) {
+ fail("throws wrong exception: should throw a java.io.EOFException, has thrown a " + e.getClass().getName());
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Make sure that the kryo serializer forwards EOF exceptions properly when serializing
+ */
+ @Test
+ public void testForwardEOFExceptionWhileDeserializing() {
+ try {
+ int numElements = 100;
+ // construct a memory target that is too small for the string
+ TestDataOutputSerializer target = new TestDataOutputSerializer(5*numElements, 5*numElements);
+ KryoSerializer<Integer> serializer = new KryoSerializer<>(Integer.class, new ExecutionConfig());
+
+ for(int i = 0; i < numElements; i++){
+ serializer.serialize(i, target);
+ }
+
+ ComparatorTestBase.TestInputView source = new ComparatorTestBase.TestInputView(target.copyByteBuffer());
+
+ for(int i = 0; i < numElements; i++){
+ int value = serializer.deserialize(source);
+ assertEquals(i, value);
+ }
+
+ try {
+ serializer.deserialize(source);
+ fail("should throw a java.io.EOFException");
+ }
+ catch (java.io.EOFException e) {
+ // that is how we like it :-)
+ }
+ catch (Exception e) {
+ fail("throws wrong exception: should throw a java.io.EOFException, has thrown a " + e.getClass().getName());
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void validateReferenceMappingDisabled() {
+ KryoSerializer<String> serializer = new KryoSerializer<>(String.class, new ExecutionConfig());
+ Kryo kryo = serializer.getKryo();
+ assertFalse(kryo.getReferences());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java
new file mode 100644
index 0000000..d68afd6
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest;
+import org.joda.time.LocalDate;
+import org.junit.Test;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+@SuppressWarnings("unchecked")
+public class KryoWithCustomSerializersTest extends AbstractGenericTypeSerializerTest {
+
+
+ @Test
+ public void testJodaTime(){
+ Collection<LocalDate> b = new HashSet<LocalDate>();
+
+ b.add(new LocalDate(1L));
+ b.add(new LocalDate(2L));
+
+ runTests(b);
+ }
+
+ @Override
+ protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
+ ExecutionConfig conf = new ExecutionConfig();
+ conf.registerTypeWithKryoSerializer(LocalDate.class, LocalDateSerializer.class);
+ TypeInformation<T> typeInfo = new GenericTypeInfo<T>(type);
+ return typeInfo.createSerializer(conf);
+ }
+
+ public static final class LocalDateSerializer extends Serializer<LocalDate> implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void write(Kryo kryo, Output output, LocalDate object) {
+ output.writeInt(object.getYear());
+ output.writeInt(object.getMonthOfYear());
+ output.writeInt(object.getDayOfMonth());
+ }
+
+ @Override
+ public LocalDate read(Kryo kryo, Input input, Class<LocalDate> type) {
+ return new LocalDate(input.readInt(), input.readInt(), input.readInt());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java
new file mode 100644
index 0000000..7c6d023
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import org.apache.flink.api.common.ExecutionConfig;
+
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.core.fs.Path;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+import static org.junit.Assert.assertTrue;
+
+public class SerializersTest {
+
+ // recursive
+ public static class Node {
+ private Node parent;
+ }
+
+ public static class FromNested {
+ Node recurseMe;
+ }
+
+ public static class FromGeneric1 {}
+ public static class FromGeneric2 {}
+
+ public static class Nested1 {
+ private FromNested fromNested;
+ private Path yodaIntervall;
+ }
+
+ public static class ClassWithNested {
+
+ Nested1 nested;
+ int ab;
+
+ ArrayList<FromGeneric1> addGenType;
+ FromGeneric2[] genericArrayType;
+ }
+
+ @Test
+ public void testTypeRegistration() {
+ ExecutionConfig conf = new ExecutionConfig();
+ Serializers.recursivelyRegisterType(ClassWithNested.class, conf, new HashSet<Class<?>>());
+
+ KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
+
+ Assert.assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
+ Assert.assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
+ Assert.assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
+
+ // check if the generic type from one field is also registered (its very likely that
+ // generic types are also used as fields somewhere.
+ Assert.assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
+ Assert.assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
+ Assert.assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
+
+
+ // register again and make sure classes are still registered
+ ExecutionConfig conf2 = new ExecutionConfig();
+ Serializers.recursivelyRegisterType(ClassWithNested.class, conf2, new HashSet<Class<?>>());
+ KryoSerializer<String> kryo2 = new KryoSerializer<>(String.class, conf);
+ assertTrue(kryo2.getKryo().getRegistration(FromNested.class).getId() > 0);
+ }
+
+ @Test
+ public void testTypeRegistrationFromTypeInfo() {
+ ExecutionConfig conf = new ExecutionConfig();
+ Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet<Class<?>>());
+
+ KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
+
+ assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
+ assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
+ assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
+
+ // check if the generic type from one field is also registered (its very likely that
+ // generic types are also used as fields somewhere.
+ assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
+ assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
+ assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java
new file mode 100644
index 0000000..faab26a
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java
@@ -0,0 +1,43 @@
+/*
+ * 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.java.typeutils.runtime.tuple.base;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.api.java.typeutils.runtime.TupleComparator;
+import org.apache.flink.api.java.typeutils.runtime.TupleSerializer;
+
+import static org.junit.Assert.assertEquals;
+
+public abstract class TupleComparatorTestBase<T extends Tuple> extends ComparatorTestBase<T> {
+
+ @Override
+ protected void deepEquals(String message, T should, T is) {
+ for (int x = 0; x < should.getArity(); x++) {
+ assertEquals(should.getField(x), is.getField(x));
+ }
+ }
+
+ @Override
+ protected abstract TupleComparator<T> createComparator(boolean ascending);
+
+ @Override
+ protected abstract TupleSerializer<T> createSerializer();
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java
new file mode 100644
index 0000000..1d414d8
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java
@@ -0,0 +1,109 @@
+/*
+ * 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.java.typeutils.runtime.tuple.base;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.flink.api.common.typeutils.TypePairComparator;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+
+/**
+ * Abstract test base for TuplePairComparators.
+ *
+ * @param <T>
+ * @param <R>
+ */
+public abstract class TuplePairComparatorTestBase<T extends Tuple, R extends Tuple> extends TestLogger {
+
+ protected abstract TypePairComparator<T, R> createComparator(boolean ascending);
+
+ protected abstract Tuple2<T[], R[]> getSortedTestData();
+
+ @Test
+ public void testEqualityWithReference() {
+ try {
+ TypePairComparator<T, R> comparator = getComparator(true);
+ Tuple2<T[], R[]> data = getSortedData();
+ for (int x = 0; x < data.f0.length; x++) {
+ comparator.setReference(data.f0[x]);
+
+ assertTrue(comparator.equalToReference(data.f1[x]));
+ }
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ fail("Exception in test: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testInequalityWithReference() {
+ testGreatSmallAscDescWithReference(true);
+ testGreatSmallAscDescWithReference(false);
+ }
+
+ protected void testGreatSmallAscDescWithReference(boolean ascending) {
+ try {
+ Tuple2<T[], R[]> data = getSortedData();
+
+ TypePairComparator<T, R> comparator = getComparator(ascending);
+
+ //compares every element in high with every element in low
+ for (int x = 0; x < data.f0.length - 1; x++) {
+ for (int y = x + 1; y < data.f1.length; y++) {
+ comparator.setReference(data.f0[x]);
+ if (ascending) {
+ assertTrue(comparator.compareToReference(data.f1[y]) > 0);
+ } else {
+ assertTrue(comparator.compareToReference(data.f1[y]) < 0);
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ fail("Exception in test: " + e.getMessage());
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ protected TypePairComparator<T, R> getComparator(boolean ascending) {
+ TypePairComparator<T, R> comparator = createComparator(ascending);
+ if (comparator == null) {
+ throw new RuntimeException("Test case corrupt. Returns null as comparator.");
+ }
+ return comparator;
+ }
+
+ protected Tuple2<T[], R[]> getSortedData() {
+ Tuple2<T[], R[]> data = getSortedTestData();
+ if (data == null || data.f0 == null || data.f1 == null) {
+ throw new RuntimeException("Test case corrupt. Returns null as test data.");
+ }
+ if (data.f0.length < 2 || data.f1.length < 2) {
+ throw new RuntimeException("Test case does not provide enough sorted test data.");
+ }
+
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/pom.xml
----------------------------------------------------------------------
diff --git a/flink-java/pom.xml b/flink-java/pom.xml
index a31e89d..3203d75 100644
--- a/flink-java/pom.xml
+++ b/flink-java/pom.xml
@@ -40,22 +40,12 @@ under the License.
<artifactId>flink-core</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>${shading-artifact.name}</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.apache.avro</groupId>
- <artifactId>avro</artifactId>
- <!-- version is derived from base module -->
- </dependency>
-
- <dependency>
- <groupId>com.esotericsoftware.kryo</groupId>
- <artifactId>kryo</artifactId>
- </dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
@@ -64,12 +54,6 @@ under the License.
</dependency>
<dependency>
- <groupId>com.twitter</groupId>
- <artifactId>chill-java</artifactId>
- <version>${chill.version}</version>
- </dependency>
-
- <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
@@ -88,20 +72,6 @@ under the License.
<type>test-jar</type>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.5</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.joda</groupId>
- <artifactId>joda-convert</artifactId>
- <version>1.7</version>
- <scope>test</scope>
- </dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java b/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java
index 6db32c5..6bcdb52 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/DataSet.java
@@ -63,7 +63,7 @@ import org.apache.flink.api.java.operators.GroupCombineOperator;
import org.apache.flink.api.java.operators.GroupReduceOperator;
import org.apache.flink.api.java.operators.IterativeDataSet;
import org.apache.flink.api.java.operators.JoinOperator.JoinOperatorSets;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.operators.MapOperator;
import org.apache.flink.api.java.operators.MapPartitionOperator;
import org.apache.flink.api.java.operators.PartitionOperator;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/Utils.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/Utils.java b/flink-java/src/main/java/org/apache/flink/api/java/Utils.java
index 2edc533..80f8199 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/Utils.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/Utils.java
@@ -33,7 +33,6 @@ import org.apache.flink.configuration.Configuration;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
-import java.util.List;
import java.util.Random;
import static org.apache.flink.api.java.functions.FunctionAnnotation.SkipCodeAnalysis;
@@ -61,24 +60,6 @@ public final class Utils {
return String.format("%s(%s:%d)", elem.getMethodName(), elem.getFileName(), elem.getLineNumber());
}
- /**
- * Returns all GenericTypeInfos contained in a composite type.
- *
- * @param typeInfo {@link CompositeType}
- */
- public static void getContainedGenericTypes(CompositeType<?> typeInfo, List<GenericTypeInfo<?>> target) {
- for (int i = 0; i < typeInfo.getArity(); i++) {
- TypeInformation<?> type = typeInfo.getTypeAt(i);
- if (type instanceof CompositeType) {
- getContainedGenericTypes((CompositeType<?>) type, target);
- } else if (type instanceof GenericTypeInfo) {
- if (!target.contains(type)) {
- target.add((GenericTypeInfo<?>) type);
- }
- }
- }
- }
-
// --------------------------------------------------------------------------------------------
/**
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/functions/KeySelector.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/functions/KeySelector.java b/flink-java/src/main/java/org/apache/flink/api/java/functions/KeySelector.java
deleted file mode 100644
index 3d06c59..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/functions/KeySelector.java
+++ /dev/null
@@ -1,63 +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.java.functions;
-
-import org.apache.flink.api.common.functions.Function;
-
-import java.io.Serializable;
-
-/**
- * The {@link KeySelector} allows to use arbitrary objects for operations such as
- * reduce, reduceGroup, join, coGoup, etc.
- *
- * The extractor takes an object and returns the key for that object.
- *
- * @param <IN> Type of objects to extract the key from.
- * @param <KEY> Type of key.
- */
-public interface KeySelector<IN, KEY> extends Function, Serializable {
-
- /**
- * User-defined function that extracts the key from an arbitrary object.
- *
- * For example for a class:
- * <pre>
- * public class Word {
- * String word;
- * int count;
- * }
- * </pre>
- * The key extractor could return the word as
- * a key to group all Word objects by the String they contain.
- *
- * The code would look like this
- * <pre>
- * public String getKey(Word w) {
- * return w.word;
- * }
- * </pre>
- *
- * @param value The object to get the key from.
- * @return The extracted key.
- *
- * @throws Exception Throwing an exception will cause the execution of the respective task to fail,
- * and trigger recovery or cancellation of the program.
- */
- KEY getKey(IN value) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/functions/SemanticPropUtil.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/functions/SemanticPropUtil.java b/flink-java/src/main/java/org/apache/flink/api/java/functions/SemanticPropUtil.java
index 761eeb3..a75b8e0 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/functions/SemanticPropUtil.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/functions/SemanticPropUtil.java
@@ -37,7 +37,7 @@ import org.apache.flink.api.java.functions.FunctionAnnotation.NonForwardedFields
import org.apache.flink.api.java.functions.FunctionAnnotation.ReadFields;
import org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsFirst;
import org.apache.flink.api.java.functions.FunctionAnnotation.ReadFieldsSecond;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.typeutils.TupleTypeInfo;
import java.lang.annotation.Annotation;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/io/SplitDataProperties.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/io/SplitDataProperties.java b/flink-java/src/main/java/org/apache/flink/api/java/io/SplitDataProperties.java
index c44929f..6763cdf 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/io/SplitDataProperties.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/io/SplitDataProperties.java
@@ -25,7 +25,7 @@ import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.operators.Ordering;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.operators.DataSource;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import java.util.Arrays;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/AggregateOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/AggregateOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/AggregateOperator.java
index 00e0d3b..6485936 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/AggregateOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/AggregateOperator.java
@@ -25,6 +25,7 @@ import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.functions.GroupCombineFunction;
import org.apache.flink.api.common.functions.GroupReduceFunction;
import org.apache.flink.api.common.functions.RichGroupReduceFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.SingleInputSemanticProperties;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupOperator.java
index 845deb4..6c6b051 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupOperator.java
@@ -30,6 +30,7 @@ import org.apache.flink.api.common.functions.CoGroupFunction;
import org.apache.flink.api.common.functions.Partitioner;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
import org.apache.flink.api.common.operators.DualInputSemanticProperties;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.operators.Ordering;
@@ -40,9 +41,9 @@ import org.apache.flink.api.java.Utils;
import org.apache.flink.api.java.functions.SemanticPropUtil;
import org.apache.flink.api.java.operators.DeltaIteration.SolutionSetPlaceHolder;
import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-import org.apache.flink.api.java.operators.Keys.IncompatibleKeysException;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.operators.Keys.IncompatibleKeysException;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.operators.translation.PlanBothUnwrappingCoGroupOperator;
import org.apache.flink.api.java.operators.translation.PlanLeftUnwrappingCoGroupOperator;
import org.apache.flink.api.java.operators.translation.PlanRightUnwrappingCoGroupOperator;
@@ -297,11 +298,11 @@ public class CoGroupOperator<I1, I2, OUT> extends TwoInputUdfOperator<I1, I2, OU
@SuppressWarnings("unchecked")
final SelectorFunctionKeys<I2, K> keys2 = (SelectorFunctionKeys<I2, K>) rawKeys2;
- final TypeInformation<Tuple2<K, I1>> typeInfoWithKey1 = SelectorFunctionKeys.createTypeWithKey(keys1);
- final TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = SelectorFunctionKeys.createTypeWithKey(keys2);
+ final TypeInformation<Tuple2<K, I1>> typeInfoWithKey1 = KeyFunctions.createTypeWithKey(keys1);
+ final TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = KeyFunctions.createTypeWithKey(keys2);
- final Operator<Tuple2<K, I1>> keyedInput1 = SelectorFunctionKeys.appendKeyExtractor(input1, keys1);
- final Operator<Tuple2<K, I2>> keyedInput2 = SelectorFunctionKeys.appendKeyExtractor(input2, keys2);
+ final Operator<Tuple2<K, I1>> keyedInput1 = KeyFunctions.appendKeyExtractor(input1, keys1);
+ final Operator<Tuple2<K, I2>> keyedInput2 = KeyFunctions.appendKeyExtractor(input2, keys2);
final PlanBothUnwrappingCoGroupOperator<I1, I2, OUT, K> cogroup =
new PlanBothUnwrappingCoGroupOperator<>(function, keys1, keys2, name, outputType, typeInfoWithKey1, typeInfoWithKey2);
@@ -324,8 +325,8 @@ public class CoGroupOperator<I1, I2, OUT> extends TwoInputUdfOperator<I1, I2, OU
@SuppressWarnings("unchecked")
final SelectorFunctionKeys<I2, K> keys2 = (SelectorFunctionKeys<I2, K>) rawKeys2;
- final TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = SelectorFunctionKeys.createTypeWithKey(keys2);
- final Operator<Tuple2<K, I2>> keyedInput2 = SelectorFunctionKeys.appendKeyExtractor(input2, keys2);
+ final TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = KeyFunctions.createTypeWithKey(keys2);
+ final Operator<Tuple2<K, I2>> keyedInput2 = KeyFunctions.appendKeyExtractor(input2, keys2);
final PlanRightUnwrappingCoGroupOperator<I1, I2, OUT, K> cogroup =
new PlanRightUnwrappingCoGroupOperator<>(
@@ -355,8 +356,8 @@ public class CoGroupOperator<I1, I2, OUT> extends TwoInputUdfOperator<I1, I2, OU
@SuppressWarnings("unchecked")
final SelectorFunctionKeys<I1, K> keys1 = (SelectorFunctionKeys<I1, K>) rawKeys1;
- final TypeInformation<Tuple2<K, I1>> typeInfoWithKey1 = SelectorFunctionKeys.createTypeWithKey(keys1);
- final Operator<Tuple2<K, I1>> keyedInput1 = SelectorFunctionKeys.appendKeyExtractor(input1, keys1);
+ final TypeInformation<Tuple2<K, I1>> typeInfoWithKey1 = KeyFunctions.createTypeWithKey(keys1);
+ final Operator<Tuple2<K, I1>> keyedInput1 = KeyFunctions.appendKeyExtractor(input1, keys1);
final PlanLeftUnwrappingCoGroupOperator<I1, I2, OUT, K> cogroup =
new PlanLeftUnwrappingCoGroupOperator<>(
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupRawOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupRawOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupRawOperator.java
index 30639c3..74f54b8 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupRawOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/CoGroupRawOperator.java
@@ -21,11 +21,12 @@ import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.functions.CoGroupFunction;
import org.apache.flink.api.common.functions.Function;
import org.apache.flink.api.common.operators.BinaryOperatorInformation;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.base.CoGroupRawOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.DataSet;
-import org.apache.flink.api.java.operators.Keys.IncompatibleKeysException;
+import org.apache.flink.api.common.operators.Keys.IncompatibleKeysException;
/**
* A {@link DataSet} that is the result of a CoGroup transformation.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/DataSink.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/DataSink.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/DataSink.java
index 915a053..8745271 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/DataSink.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/DataSink.java
@@ -21,6 +21,7 @@ package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.io.OutputFormat;
import org.apache.flink.api.common.operators.GenericDataSinkBase;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.operators.Ordering;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIteration.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIteration.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIteration.java
index a302478..7b3001f 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIteration.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIteration.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.aggregators.Aggregator;
import org.apache.flink.api.common.aggregators.AggregatorRegistry;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIterationResultSet.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIterationResultSet.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIterationResultSet.java
index 6717c6d..4af9108 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIterationResultSet.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/DeltaIterationResultSet.java
@@ -18,6 +18,7 @@
package org.apache.flink.api.java.operators;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/DistinctOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/DistinctOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/DistinctOperator.java
index 5102c80..9979f59 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/DistinctOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/DistinctOperator.java
@@ -20,12 +20,13 @@ package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.functions.GroupCombineFunction;
import org.apache.flink.api.common.functions.GroupReduceFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.SingleInputSemanticProperties;
import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.GroupReduceOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.operators.translation.PlanUnwrappingReduceGroupOperator;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;
@@ -116,8 +117,8 @@ public class DistinctOperator<T> extends SingleInputOperator<T, T, DistinctOpera
@SuppressWarnings("unchecked")
final SelectorFunctionKeys<IN, K> keys = (SelectorFunctionKeys<IN, K>) rawKeys;
- TypeInformation<Tuple2<K, IN>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(keys);
- Operator<Tuple2<K, IN>> keyedInput = SelectorFunctionKeys.appendKeyExtractor(input, keys);
+ TypeInformation<Tuple2<K, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
+ Operator<Tuple2<K, IN>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
PlanUnwrappingReduceGroupOperator<IN, OUT, K> reducer =
new PlanUnwrappingReduceGroupOperator<>(function, keys, name, outputType, typeInfoWithKey, true);
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupCombineOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupCombineOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupCombineOperator.java
index ef0c12f..a43b869 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupCombineOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupCombineOperator.java
@@ -19,6 +19,7 @@
package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.functions.GroupCombineFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.operators.Ordering;
@@ -30,7 +31,7 @@ import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.functions.SemanticPropUtil;
import org.apache.flink.api.java.operators.translation.PlanUnwrappingGroupCombineOperator;
import org.apache.flink.api.java.operators.translation.PlanUnwrappingSortedGroupCombineOperator;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
@@ -195,8 +196,8 @@ public class GroupCombineOperator<IN, OUT> extends SingleInputUdfOperator<IN, OU
{
final SelectorFunctionKeys<IN, K> keys = (SelectorFunctionKeys<IN, K>) rawKeys;
- TypeInformation<Tuple2<K, IN>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(keys);
- Operator<Tuple2<K, IN>> keyedInput = SelectorFunctionKeys.appendKeyExtractor(input, keys);
+ TypeInformation<Tuple2<K, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
+ Operator<Tuple2<K, IN>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
PlanUnwrappingGroupCombineOperator<IN, OUT, K> reducer =
new PlanUnwrappingGroupCombineOperator<>(function, keys, name, outputType, typeInfoWithKey);
@@ -217,9 +218,9 @@ public class GroupCombineOperator<IN, OUT> extends SingleInputUdfOperator<IN, OU
{
final SelectorFunctionKeys<IN, K1> groupingKey = (SelectorFunctionKeys<IN, K1>) rawGroupingKey;
final SelectorFunctionKeys<IN, K2> sortingKey = (SelectorFunctionKeys<IN, K2>)rawSortingKeys;
- TypeInformation<Tuple3<K1, K2, IN>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(groupingKey, sortingKey);
+ TypeInformation<Tuple3<K1, K2, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(groupingKey, sortingKey);
- Operator<Tuple3<K1, K2, IN>> inputWithKey = SelectorFunctionKeys.appendKeyExtractor(input, groupingKey, sortingKey);
+ Operator<Tuple3<K1, K2, IN>> inputWithKey = KeyFunctions.appendKeyExtractor(input, groupingKey, sortingKey);
PlanUnwrappingSortedGroupCombineOperator<IN, OUT, K1, K2> reducer =
new PlanUnwrappingSortedGroupCombineOperator<>(function, groupingKey, sortingKey, name, outputType, typeInfoWithKey);
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupReduceOperator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupReduceOperator.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupReduceOperator.java
index b1bf844..42553a0 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupReduceOperator.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/GroupReduceOperator.java
@@ -20,6 +20,7 @@ package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.functions.GroupCombineFunction;
import org.apache.flink.api.common.functions.GroupReduceFunction;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.common.operators.Operator;
import org.apache.flink.api.common.operators.Order;
import org.apache.flink.api.common.operators.Ordering;
@@ -28,7 +29,7 @@ import org.apache.flink.api.common.operators.UnaryOperatorInformation;
import org.apache.flink.api.common.operators.base.GroupReduceOperatorBase;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.functions.SemanticPropUtil;
-import org.apache.flink.api.java.operators.Keys.SelectorFunctionKeys;
+import org.apache.flink.api.common.operators.Keys.SelectorFunctionKeys;
import org.apache.flink.api.java.operators.translation.PlanUnwrappingReduceGroupOperator;
import org.apache.flink.api.java.operators.translation.PlanUnwrappingSortedReduceGroupOperator;
import org.apache.flink.api.java.tuple.Tuple2;
@@ -281,9 +282,9 @@ public class GroupReduceOperator<IN, OUT> extends SingleInputUdfOperator<IN, OUT
boolean combinable)
{
SelectorFunctionKeys<IN, K> keys = (SelectorFunctionKeys<IN, K>) rawKeys;
- TypeInformation<Tuple2<K, IN>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(keys);
+ TypeInformation<Tuple2<K, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(keys);
- Operator<Tuple2<K, IN>> keyedInput = SelectorFunctionKeys.appendKeyExtractor(input, keys);
+ Operator<Tuple2<K, IN>> keyedInput = KeyFunctions.appendKeyExtractor(input, keys);
PlanUnwrappingReduceGroupOperator<IN, OUT, K> reducer =
new PlanUnwrappingReduceGroupOperator(function, keys, name, outputType, typeInfoWithKey, combinable);
@@ -305,9 +306,9 @@ public class GroupReduceOperator<IN, OUT> extends SingleInputUdfOperator<IN, OUT
{
final SelectorFunctionKeys<IN, K1> groupingKey = (SelectorFunctionKeys<IN, K1>) rawGroupingKey;
final SelectorFunctionKeys<IN, K2> sortingKey = (SelectorFunctionKeys<IN, K2>) rawSortingKey;
- TypeInformation<Tuple3<K1, K2, IN>> typeInfoWithKey = SelectorFunctionKeys.createTypeWithKey(groupingKey,sortingKey);
+ TypeInformation<Tuple3<K1, K2, IN>> typeInfoWithKey = KeyFunctions.createTypeWithKey(groupingKey,sortingKey);
- Operator<Tuple3<K1, K2, IN>> inputWithKey = SelectorFunctionKeys.appendKeyExtractor(input, groupingKey, sortingKey);
+ Operator<Tuple3<K1, K2, IN>> inputWithKey = KeyFunctions.appendKeyExtractor(input, groupingKey, sortingKey);
PlanUnwrappingSortedReduceGroupOperator<IN, OUT, K1, K2> reducer =
new PlanUnwrappingSortedReduceGroupOperator<>(
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/operators/Grouping.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/operators/Grouping.java b/flink-java/src/main/java/org/apache/flink/api/java/operators/Grouping.java
index c117458..823aee4 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/operators/Grouping.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/operators/Grouping.java
@@ -20,6 +20,7 @@ package org.apache.flink.api.java.operators;
import org.apache.flink.api.common.InvalidProgramException;
import org.apache.flink.api.common.functions.Partitioner;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.DataSet;
/**
[02/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
deleted file mode 100644
index 8ff0b1b..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
+++ /dev/null
@@ -1,168 +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.java.typeutils.runtime.kryo;
-
-import com.esotericsoftware.kryo.Kryo;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest;
-import org.apache.flink.api.java.typeutils.runtime.TestDataOutputSerializer;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Random;
-
-import static org.junit.Assert.*;
-
-@SuppressWarnings("unchecked")
-public class KryoGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
-
- ExecutionConfig ec = new ExecutionConfig();
-
- @Test
- public void testJavaList(){
- Collection<Integer> a = new ArrayList<>();
-
- fillCollection(a);
-
- runTests(a);
- }
-
- @Test
- public void testJavaSet(){
- Collection<Integer> b = new HashSet<>();
-
- fillCollection(b);
-
- runTests(b);
- }
-
-
-
- @Test
- public void testJavaDequeue(){
- Collection<Integer> c = new LinkedList<>();
- fillCollection(c);
- runTests(c);
- }
-
- private void fillCollection(Collection<Integer> coll) {
- coll.add(42);
- coll.add(1337);
- coll.add(49);
- coll.add(1);
- }
-
- @Override
- protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
- return new KryoSerializer<T>(type, ec);
- }
-
- /**
- * Make sure that the kryo serializer forwards EOF exceptions properly when serializing
- */
- @Test
- public void testForwardEOFExceptionWhileSerializing() {
- try {
- // construct a long string
- String str;
- {
- char[] charData = new char[40000];
- Random rnd = new Random();
-
- for (int i = 0; i < charData.length; i++) {
- charData[i] = (char) rnd.nextInt(10000);
- }
-
- str = new String(charData);
- }
-
- // construct a memory target that is too small for the string
- TestDataOutputSerializer target = new TestDataOutputSerializer(10000, 30000);
- KryoSerializer<String> serializer = new KryoSerializer<String>(String.class, new ExecutionConfig());
-
- try {
- serializer.serialize(str, target);
- fail("should throw a java.io.EOFException");
- }
- catch (java.io.EOFException e) {
- // that is how we like it
- }
- catch (Exception e) {
- fail("throws wrong exception: should throw a java.io.EOFException, has thrown a " + e.getClass().getName());
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- /**
- * Make sure that the kryo serializer forwards EOF exceptions properly when serializing
- */
- @Test
- public void testForwardEOFExceptionWhileDeserializing() {
- try {
- int numElements = 100;
- // construct a memory target that is too small for the string
- TestDataOutputSerializer target = new TestDataOutputSerializer(5*numElements, 5*numElements);
- KryoSerializer<Integer> serializer = new KryoSerializer<>(Integer.class, new ExecutionConfig());
-
- for(int i = 0; i < numElements; i++){
- serializer.serialize(i, target);
- }
-
- ComparatorTestBase.TestInputView source = new ComparatorTestBase.TestInputView(target.copyByteBuffer());
-
- for(int i = 0; i < numElements; i++){
- int value = serializer.deserialize(source);
- assertEquals(i, value);
- }
-
- try {
- serializer.deserialize(source);
- fail("should throw a java.io.EOFException");
- }
- catch (java.io.EOFException e) {
- // that is how we like it :-)
- }
- catch (Exception e) {
- fail("throws wrong exception: should throw a java.io.EOFException, has thrown a " + e.getClass().getName());
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void validateReferenceMappingDisabled() {
- KryoSerializer<String> serializer = new KryoSerializer<>(String.class, new ExecutionConfig());
- Kryo kryo = serializer.getKryo();
- assertFalse(kryo.getReferences());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java
deleted file mode 100644
index d68afd6..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoWithCustomSerializersTest.java
+++ /dev/null
@@ -1,75 +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.java.typeutils.runtime.kryo;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest;
-import org.joda.time.LocalDate;
-import org.junit.Test;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.Serializer;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-
-@SuppressWarnings("unchecked")
-public class KryoWithCustomSerializersTest extends AbstractGenericTypeSerializerTest {
-
-
- @Test
- public void testJodaTime(){
- Collection<LocalDate> b = new HashSet<LocalDate>();
-
- b.add(new LocalDate(1L));
- b.add(new LocalDate(2L));
-
- runTests(b);
- }
-
- @Override
- protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
- ExecutionConfig conf = new ExecutionConfig();
- conf.registerTypeWithKryoSerializer(LocalDate.class, LocalDateSerializer.class);
- TypeInformation<T> typeInfo = new GenericTypeInfo<T>(type);
- return typeInfo.createSerializer(conf);
- }
-
- public static final class LocalDateSerializer extends Serializer<LocalDate> implements java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void write(Kryo kryo, Output output, LocalDate object) {
- output.writeInt(object.getYear());
- output.writeInt(object.getMonthOfYear());
- output.writeInt(object.getDayOfMonth());
- }
-
- @Override
- public LocalDate read(Kryo kryo, Input input, Class<LocalDate> type) {
- return new LocalDate(input.readInt(), input.readInt(), input.readInt());
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java
deleted file mode 100644
index 7c6d023..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/SerializersTest.java
+++ /dev/null
@@ -1,103 +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.java.typeutils.runtime.kryo;
-
-import org.apache.flink.api.common.ExecutionConfig;
-
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.core.fs.Path;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import static org.junit.Assert.assertTrue;
-
-public class SerializersTest {
-
- // recursive
- public static class Node {
- private Node parent;
- }
-
- public static class FromNested {
- Node recurseMe;
- }
-
- public static class FromGeneric1 {}
- public static class FromGeneric2 {}
-
- public static class Nested1 {
- private FromNested fromNested;
- private Path yodaIntervall;
- }
-
- public static class ClassWithNested {
-
- Nested1 nested;
- int ab;
-
- ArrayList<FromGeneric1> addGenType;
- FromGeneric2[] genericArrayType;
- }
-
- @Test
- public void testTypeRegistration() {
- ExecutionConfig conf = new ExecutionConfig();
- Serializers.recursivelyRegisterType(ClassWithNested.class, conf, new HashSet<Class<?>>());
-
- KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
-
- Assert.assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
- Assert.assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
- Assert.assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
-
- // check if the generic type from one field is also registered (its very likely that
- // generic types are also used as fields somewhere.
- Assert.assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
- Assert.assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
- Assert.assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
-
-
- // register again and make sure classes are still registered
- ExecutionConfig conf2 = new ExecutionConfig();
- Serializers.recursivelyRegisterType(ClassWithNested.class, conf2, new HashSet<Class<?>>());
- KryoSerializer<String> kryo2 = new KryoSerializer<>(String.class, conf);
- assertTrue(kryo2.getKryo().getRegistration(FromNested.class).getId() > 0);
- }
-
- @Test
- public void testTypeRegistrationFromTypeInfo() {
- ExecutionConfig conf = new ExecutionConfig();
- Serializers.recursivelyRegisterType(new GenericTypeInfo<>(ClassWithNested.class), conf, new HashSet<Class<?>>());
-
- KryoSerializer<String> kryo = new KryoSerializer<>(String.class, conf); // we create Kryo from another type.
-
- assertTrue(kryo.getKryo().getRegistration(FromNested.class).getId() > 0);
- assertTrue(kryo.getKryo().getRegistration(ClassWithNested.class).getId() > 0);
- assertTrue(kryo.getKryo().getRegistration(Path.class).getId() > 0);
-
- // check if the generic type from one field is also registered (its very likely that
- // generic types are also used as fields somewhere.
- assertTrue(kryo.getKryo().getRegistration(FromGeneric1.class).getId() > 0);
- assertTrue(kryo.getKryo().getRegistration(FromGeneric2.class).getId() > 0);
- assertTrue(kryo.getKryo().getRegistration(Node.class).getId() > 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java
deleted file mode 100644
index faab26a..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TupleComparatorTestBase.java
+++ /dev/null
@@ -1,43 +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.java.typeutils.runtime.tuple.base;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.api.java.typeutils.runtime.TupleComparator;
-import org.apache.flink.api.java.typeutils.runtime.TupleSerializer;
-
-import static org.junit.Assert.assertEquals;
-
-public abstract class TupleComparatorTestBase<T extends Tuple> extends ComparatorTestBase<T> {
-
- @Override
- protected void deepEquals(String message, T should, T is) {
- for (int x = 0; x < should.getArity(); x++) {
- assertEquals(should.getField(x), is.getField(x));
- }
- }
-
- @Override
- protected abstract TupleComparator<T> createComparator(boolean ascending);
-
- @Override
- protected abstract TupleSerializer<T> createSerializer();
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java
deleted file mode 100644
index 1d414d8..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/tuple/base/TuplePairComparatorTestBase.java
+++ /dev/null
@@ -1,109 +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.java.typeutils.runtime.tuple.base;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.flink.api.common.typeutils.TypePairComparator;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.util.TestLogger;
-import org.junit.Test;
-
-/**
- * Abstract test base for TuplePairComparators.
- *
- * @param <T>
- * @param <R>
- */
-public abstract class TuplePairComparatorTestBase<T extends Tuple, R extends Tuple> extends TestLogger {
-
- protected abstract TypePairComparator<T, R> createComparator(boolean ascending);
-
- protected abstract Tuple2<T[], R[]> getSortedTestData();
-
- @Test
- public void testEqualityWithReference() {
- try {
- TypePairComparator<T, R> comparator = getComparator(true);
- Tuple2<T[], R[]> data = getSortedData();
- for (int x = 0; x < data.f0.length; x++) {
- comparator.setReference(data.f0[x]);
-
- assertTrue(comparator.equalToReference(data.f1[x]));
- }
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- fail("Exception in test: " + e.getMessage());
- }
- }
-
- @Test
- public void testInequalityWithReference() {
- testGreatSmallAscDescWithReference(true);
- testGreatSmallAscDescWithReference(false);
- }
-
- protected void testGreatSmallAscDescWithReference(boolean ascending) {
- try {
- Tuple2<T[], R[]> data = getSortedData();
-
- TypePairComparator<T, R> comparator = getComparator(ascending);
-
- //compares every element in high with every element in low
- for (int x = 0; x < data.f0.length - 1; x++) {
- for (int y = x + 1; y < data.f1.length; y++) {
- comparator.setReference(data.f0[x]);
- if (ascending) {
- assertTrue(comparator.compareToReference(data.f1[y]) > 0);
- } else {
- assertTrue(comparator.compareToReference(data.f1[y]) < 0);
- }
- }
- }
- } catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- fail("Exception in test: " + e.getMessage());
- }
- }
-
- // --------------------------------------------------------------------------------------------
- protected TypePairComparator<T, R> getComparator(boolean ascending) {
- TypePairComparator<T, R> comparator = createComparator(ascending);
- if (comparator == null) {
- throw new RuntimeException("Test case corrupt. Returns null as comparator.");
- }
- return comparator;
- }
-
- protected Tuple2<T[], R[]> getSortedData() {
- Tuple2<T[], R[]> data = getSortedTestData();
- if (data == null || data.f0 == null || data.f1 == null) {
- throw new RuntimeException("Test case corrupt. Returns null as test data.");
- }
- if (data.f0.length < 2 || data.f1.length < 2) {
- throw new RuntimeException("Test case does not provide enough sorted test data.");
- }
-
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java b/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
index 1534ebf..0479c0b 100644
--- a/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
+++ b/flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
@@ -29,7 +29,7 @@ import org.apache.flink.api.java.operators.AggregateOperator;
import org.apache.flink.api.java.operators.CoGroupRawOperator;
import org.apache.flink.api.java.operators.CrossOperator.DefaultCross;
import org.apache.flink.api.java.operators.Grouping;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.operators.SortedGrouping;
import org.apache.flink.api.java.operators.UdfOperator;
import org.apache.flink.api.java.operators.UnsortedGrouping;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
index d25fa9d..22be45a 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
@@ -20,13 +20,14 @@ package org.apache.flink.api.java.table
import java.lang.reflect.Modifier
+import org.apache.flink.api.common.operators.Keys
import org.apache.flink.api.common.operators.base.JoinOperatorBase.JoinHint
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.typeutils.CompositeType
import org.apache.flink.api.java.aggregation.AggregationFunction
import org.apache.flink.api.java.operators.JoinOperator.EquiJoin
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys
-import org.apache.flink.api.java.operators.{GroupReduceOperator, Keys, MapOperator, UnsortedGrouping}
+import Keys.ExpressionKeys
+import org.apache.flink.api.java.operators.{GroupReduceOperator, MapOperator, UnsortedGrouping}
import org.apache.flink.api.java.{DataSet => JavaDataSet}
import org.apache.flink.api.table.expressions.analysis.ExtractEquiJoinFields
import org.apache.flink.api.table.plan._
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/java/org/apache/flink/api/scala/operators/ScalaAggregateOperator.java
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/java/org/apache/flink/api/scala/operators/ScalaAggregateOperator.java b/flink-scala/src/main/java/org/apache/flink/api/scala/operators/ScalaAggregateOperator.java
index a79c843..1e0a2b3 100644
--- a/flink-scala/src/main/java/org/apache/flink/api/scala/operators/ScalaAggregateOperator.java
+++ b/flink-scala/src/main/java/org/apache/flink/api/scala/operators/ScalaAggregateOperator.java
@@ -34,7 +34,7 @@ import org.apache.flink.api.java.aggregation.AggregationFunction;
import org.apache.flink.api.java.aggregation.AggregationFunctionFactory;
import org.apache.flink.api.java.aggregation.Aggregations;
import org.apache.flink.api.java.operators.Grouping;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.operators.SingleInputOperator;
import org.apache.flink.api.java.typeutils.TupleTypeInfoBase;
import org.apache.flink.api.java.typeutils.runtime.TupleSerializerBase;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/CoGroupDataSet.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/CoGroupDataSet.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/CoGroupDataSet.scala
index 3eb6472..a6cce43 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/CoGroupDataSet.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/CoGroupDataSet.scala
@@ -21,10 +21,10 @@ package org.apache.flink.api.scala
import org.apache.commons.lang3.tuple.{ImmutablePair, Pair}
import org.apache.flink.api.common.InvalidProgramException
import org.apache.flink.api.common.functions.{CoGroupFunction, Partitioner, RichCoGroupFunction}
-import org.apache.flink.api.common.operators.Order
+import org.apache.flink.api.common.operators.{Keys, Order}
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.typeutils.CompositeType
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys
+import Keys.ExpressionKeys
import org.apache.flink.api.java.operators._
import org.apache.flink.util.Collector
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/DataSet.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/DataSet.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/DataSet.scala
index 35f0faf..151e6b3 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/DataSet.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/DataSet.scala
@@ -22,7 +22,7 @@ import org.apache.flink.api.common.accumulators.SerializedListAccumulator
import org.apache.flink.api.common.aggregators.Aggregator
import org.apache.flink.api.common.functions._
import org.apache.flink.api.common.io.{FileOutputFormat, OutputFormat}
-import org.apache.flink.api.common.operators.Order
+import org.apache.flink.api.common.operators.{Keys, Order}
import org.apache.flink.api.common.operators.base.JoinOperatorBase.JoinHint
import org.apache.flink.api.common.operators.base.CrossOperatorBase.CrossHint
import org.apache.flink.api.common.operators.base.PartitionOperatorBase.PartitionMethod
@@ -31,7 +31,7 @@ import org.apache.flink.api.java.Utils.CountHelper
import org.apache.flink.api.java.aggregation.Aggregations
import org.apache.flink.api.java.functions.{FirstReducer, KeySelector}
import org.apache.flink.api.java.io.{PrintingOutputFormat, TextOutputFormat}
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys
+import Keys.ExpressionKeys
import org.apache.flink.api.java.operators._
import org.apache.flink.api.java.operators.join.JoinType
import org.apache.flink.api.java.{DataSet => JavaDataSet, Utils}
@@ -93,6 +93,7 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
/**
* Returns the execution environment associated with the current DataSet.
+ *
* @return associated execution environment
*/
def getExecutionEnvironment: ExecutionEnvironment =
@@ -515,7 +516,6 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
* Convenience method to get the count (number of elements) of a DataSet
*
* @return A long integer that represents the number of elements in the set
- *
* @see org.apache.flink.api.java.Utils.CountHelper
*/
@throws(classOf[Exception])
@@ -531,7 +531,6 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
* As DataSet can contain a lot of data, this method should be used with caution.
*
* @return A Seq containing the elements of the DataSet
- *
* @see org.apache.flink.api.java.Utils.CollectHelper
*/
@throws(classOf[Exception])
@@ -1369,7 +1368,7 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
/**
* Range-partitions a DataSet on the specified fields.
*
- '''important:''' This operation requires an extra pass over the DataSet to compute the range
+ *'''important:''' This operation requires an extra pass over the DataSet to compute the range
* boundaries and shuffles the whole DataSet over the network.
* This can take significant amount of time.
*/
@@ -1385,7 +1384,7 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
/**
* Range-partitions a DataSet using the specified key selector function.
*
- '''important:''' This operation requires an extra pass over the DataSet to compute the range
+ *'''important:''' This operation requires an extra pass over the DataSet to compute the range
* boundaries and shuffles the whole DataSet over the network.
* This can take significant amount of time.
*/
@@ -1516,6 +1515,7 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
/**
* Writes `this` DataSet to the specified location. This uses [[AnyRef.toString]] on
* each element.
+ *
* @see org.apache.flink.api.java.DataSet#writeAsText(String)
*/
def writeAsText(
@@ -1532,6 +1532,7 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
* Writes `this` DataSet to the specified location as CSV file(s).
*
* This only works on Tuple DataSets. For individual tuple fields [[AnyRef.toString]] is used.
+ *
* @see org.apache.flink.api.java.DataSet#writeAsText(String)
*/
def writeAsCsv(
@@ -1623,8 +1624,8 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
* *
* Writes a DataSet to the standard output stream (stdout) with a sink identifier prefixed.
* This uses [[AnyRef.toString]] on each element.
- * @param sinkIdentifier The string to prefix the output with.
- *
+ *
+ * @param sinkIdentifier The string to prefix the output with.
* @deprecated Use [[printOnTaskManager(String)]] instead.
*/
@Deprecated
@@ -1636,8 +1637,8 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
/**
* Writes a DataSet to the standard error stream (stderr) with a sink identifier prefixed.
* This uses [[AnyRef.toString]] on each element.
- * @param sinkIdentifier The string to prefix the output with.
- *
+ *
+ * @param sinkIdentifier The string to prefix the output with.
* @deprecated Use [[printOnTaskManager(String)]] instead.
*/
@Deprecated
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/GroupedDataSet.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/GroupedDataSet.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/GroupedDataSet.scala
index 7d5419b..bb8287a 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/GroupedDataSet.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/GroupedDataSet.scala
@@ -19,11 +19,11 @@ package org.apache.flink.api.scala
import org.apache.flink.api.common.InvalidProgramException
import org.apache.flink.api.common.functions.{GroupCombineFunction, GroupReduceFunction, Partitioner, ReduceFunction}
-import org.apache.flink.api.common.operators.Order
+import org.apache.flink.api.common.operators.{Keys, Order}
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.java.aggregation.Aggregations
import org.apache.flink.api.java.functions.{FirstReducer, KeySelector}
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys
+import Keys.ExpressionKeys
import org.apache.flink.api.java.operators._
import org.apache.flink.api.scala.operators.ScalaAggregateOperator
import org.apache.flink.util.Collector
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/UnfinishedCoGroupOperation.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/UnfinishedCoGroupOperation.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/UnfinishedCoGroupOperation.scala
index 91f8c85..ace0790 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/UnfinishedCoGroupOperation.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/UnfinishedCoGroupOperation.scala
@@ -19,6 +19,7 @@
package org.apache.flink.api.scala
import org.apache.flink.api.common.functions.CoGroupFunction
+import org.apache.flink.api.common.operators.Keys
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.java.operators._
import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo
@@ -36,6 +37,7 @@ import scala.reflect.ClassTag
* val right = ...
* val coGroupResult = left.coGroup(right).where(...).isEqualTo(...)
* }}}
+ *
* @tparam L The type of the left input of the coGroup.
* @tparam R The type of the right input of the coGroup.
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/joinDataSet.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/joinDataSet.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/joinDataSet.scala
index 49b2701..71f2bfb 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/joinDataSet.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/joinDataSet.scala
@@ -18,6 +18,7 @@
package org.apache.flink.api.scala
import org.apache.flink.api.common.functions.{FlatJoinFunction, JoinFunction, Partitioner, RichFlatJoinFunction}
+import org.apache.flink.api.common.operators.Keys
import org.apache.flink.api.common.operators.base.JoinOperatorBase.JoinHint
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.java.operators.JoinOperator.DefaultJoin.WrappingFlatJoinFunction
@@ -256,6 +257,7 @@ private[flink] abstract class UnfinishedJoinOperationBase[L, R, O <: JoinFunctio
* val right = ...
* val joinResult = left.join(right).where(...).equalTo(...)
* }}}
+ *
* @tparam L The type of the left input of the join.
* @tparam R The type of the right input of the join.
*/
@@ -287,6 +289,7 @@ class UnfinishedJoinOperation[L, R](
* (first, second) => ...
* }
* }}}
+ *
* @tparam L The type of the left input of the join.
* @tparam R The type of the right input of the join.
*/
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/typeutils/CaseClassTypeInfo.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/typeutils/CaseClassTypeInfo.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/typeutils/CaseClassTypeInfo.scala
index 5db7a91..e8bc3a4 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/typeutils/CaseClassTypeInfo.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/typeutils/CaseClassTypeInfo.scala
@@ -22,11 +22,12 @@ import java.util
import java.util.regex.{Pattern, Matcher}
import org.apache.flink.api.common.ExecutionConfig
+import org.apache.flink.api.common.operators.Keys
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.typeutils.CompositeType.{TypeComparatorBuilder,
InvalidFieldReferenceException, FlatFieldDescriptor}
import org.apache.flink.api.common.typeutils._
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys
+import Keys.ExpressionKeys
import org.apache.flink.api.java.typeutils.TupleTypeInfoBase
import scala.collection.JavaConverters._
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-scala/src/main/scala/org/apache/flink/api/scala/unfinishedKeyPairOperation.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/unfinishedKeyPairOperation.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/unfinishedKeyPairOperation.scala
index 08d0242..ddb45a4 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/unfinishedKeyPairOperation.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/unfinishedKeyPairOperation.scala
@@ -19,10 +19,10 @@
package org.apache.flink.api.scala
import org.apache.flink.api.common.InvalidProgramException
+import org.apache.flink.api.common.operators.Keys
import org.apache.flink.api.java.functions.KeySelector
-import org.apache.flink.api.java.operators.Keys
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys
+import Keys.ExpressionKeys
import org.apache.flink.api.common.typeinfo.TypeInformation
/**
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java
index 254af19..f4b6e7f 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/datastream/DataStream.java
@@ -37,7 +37,7 @@ import org.apache.flink.api.java.Utils;
import org.apache.flink.api.java.functions.KeySelector;
import org.apache.flink.api.java.io.CsvOutputFormat;
import org.apache.flink.api.java.io.TextOutputFormat;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.typeutils.InputTypeConfigurable;
import org.apache.flink.api.java.typeutils.TypeExtractor;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-streaming-java/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java
index afbd8ab..cf40a3b 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/util/keys/KeySelectorUtil.java
@@ -29,7 +29,7 @@ import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeutils.CompositeType;
import org.apache.flink.api.common.typeutils.TypeComparator;
import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
import org.apache.flink.api.java.typeutils.TupleTypeInfo;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/AggregationFunctionTest.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/AggregationFunctionTest.java b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/AggregationFunctionTest.java
index dd8dec9..d0617d0 100644
--- a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/AggregationFunctionTest.java
+++ b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/AggregationFunctionTest.java
@@ -29,7 +29,7 @@ import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.functions.ReduceFunction;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/CoGroupOperatorTest.scala
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/CoGroupOperatorTest.scala b/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/CoGroupOperatorTest.scala
index 46059a6..ab5ebf5 100644
--- a/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/CoGroupOperatorTest.scala
+++ b/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/CoGroupOperatorTest.scala
@@ -20,7 +20,8 @@ package org.apache.flink.api.scala.operators
import java.util
import org.apache.flink.api.common.InvalidProgramException
-import org.apache.flink.api.java.operators.Keys.IncompatibleKeysException
+import org.apache.flink.api.common.operators.Keys
+import Keys.IncompatibleKeysException
import org.junit.Assert
import org.junit.Test
import org.apache.flink.api.scala._
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/GroupCombineITCase.scala
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/GroupCombineITCase.scala b/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/GroupCombineITCase.scala
index 576ecdf..2dabb56 100644
--- a/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/GroupCombineITCase.scala
+++ b/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/GroupCombineITCase.scala
@@ -19,9 +19,9 @@ package org.apache.flink.api.scala.operators
import org.apache.flink.api.common.operators.Order
import org.apache.flink.api.java.io.DiscardingOutputFormat
-import org.apache.flink.api.scala.{ExecutionEnvironment, _}
+import org.apache.flink.api.scala._
import org.apache.flink.api.scala.util.CollectionDataSets
-import org.apache.flink.test.javaApiOperators.GroupCombineITCase
+import org.apache.flink.test.javaApiOperators.GroupCombineITCase.ScalaGroupCombineFunctionExample
import org.apache.flink.test.util.MultipleProgramsTestBase.TestExecutionMode
import org.apache.flink.test.util.MultipleProgramsTestBase
import org.apache.flink.util.Collector
@@ -43,7 +43,7 @@ class GroupCombineITCase(mode: TestExecutionMode) extends MultipleProgramsTestBa
.map(str => Tuple1(str))
// all methods on DataSet
- ds.combineGroup(new GroupCombineITCase.ScalaGroupCombineFunctionExample())
+ ds.combineGroup(new ScalaGroupCombineFunctionExample())
.output(new DiscardingOutputFormat[Tuple1[String]])
ds.combineGroup((in, out: Collector[Tuple1[String]]) => in.toSet foreach (out.collect))
@@ -51,7 +51,7 @@ class GroupCombineITCase(mode: TestExecutionMode) extends MultipleProgramsTestBa
// all methods on UnsortedGrouping
ds.groupBy(0)
- .combineGroup(new GroupCombineITCase.ScalaGroupCombineFunctionExample())
+ .combineGroup(new ScalaGroupCombineFunctionExample())
.output(new DiscardingOutputFormat[Tuple1[String]])
ds.groupBy(0)
@@ -60,7 +60,7 @@ class GroupCombineITCase(mode: TestExecutionMode) extends MultipleProgramsTestBa
// all methods on SortedGrouping
ds.groupBy(0).sortGroup(0, Order.ASCENDING)
- .combineGroup(new GroupCombineITCase.ScalaGroupCombineFunctionExample())
+ .combineGroup(new ScalaGroupCombineFunctionExample())
.output(new DiscardingOutputFormat[Tuple1[String]])
ds.groupBy(0).sortGroup(0, Order.ASCENDING)
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/JoinOperatorTest.scala
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/JoinOperatorTest.scala b/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/JoinOperatorTest.scala
index 0d9ea9e..81a7d7e 100644
--- a/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/JoinOperatorTest.scala
+++ b/flink-tests/src/test/scala/org/apache/flink/api/scala/operators/JoinOperatorTest.scala
@@ -20,7 +20,8 @@ package org.apache.flink.api.scala.operators
import java.util
import org.apache.flink.api.common.InvalidProgramException
-import org.apache.flink.api.java.operators.Keys.IncompatibleKeysException
+import org.apache.flink.api.common.operators.Keys
+import Keys.IncompatibleKeysException
import org.apache.flink.api.scala._
import org.apache.flink.api.scala.util.CollectionDataSets.CustomType
import org.junit.{Assert, Test}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-tests/src/test/scala/org/apache/flink/api/scala/types/TypeInformationGenTest.scala
----------------------------------------------------------------------
diff --git a/flink-tests/src/test/scala/org/apache/flink/api/scala/types/TypeInformationGenTest.scala b/flink-tests/src/test/scala/org/apache/flink/api/scala/types/TypeInformationGenTest.scala
index 70276cb..46495d0 100644
--- a/flink-tests/src/test/scala/org/apache/flink/api/scala/types/TypeInformationGenTest.scala
+++ b/flink-tests/src/test/scala/org/apache/flink/api/scala/types/TypeInformationGenTest.scala
@@ -19,7 +19,7 @@ package org.apache.flink.api.scala.types
import java.io.{DataInput, DataOutput}
-import org.apache.flink.api.java.`type`.extractor.TypeExtractorTest.CustomTuple
+import org.apache.flink.api.java.typeutils.TypeExtractorTest.CustomTuple
import org.apache.flink.api.java.io.CollectionInputFormat
import org.apache.hadoop.io.Writable
import org.junit.{Assert, Test}
@@ -602,7 +602,7 @@ class TypeInformationGenTest {
// This checks the condition in checkCollection. If this fails with IllegalArgumentException,
// then things like "env.fromElements((),(),())" won't work.
import scala.collection.JavaConversions._
- CollectionInputFormat.checkCollection(Seq((),(),()), (new UnitTypeInfo).getTypeClass)
+ CollectionInputFormat.checkCollection(Seq((),(),()), (new UnitTypeInfo).getTypeClass())
}
}
[24/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java
deleted file mode 100644
index 15d3ea9..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple5.java
+++ /dev/null
@@ -1,214 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 5 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- */
-public class Tuple5<T0, T1, T2, T3, T4> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple5() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- */
- public Tuple5(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- }
-
- @Override
- public int getArity() { return 5; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple5)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple5 tuple = (Tuple5) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple5<T0,T1,T2,T3,T4> copy(){
- return new Tuple5<T0,T1,T2,T3,T4>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4> Tuple5<T0,T1,T2,T3,T4> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4) {
- return new Tuple5<T0,T1,T2,T3,T4>(value0, value1, value2, value3, value4);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java
deleted file mode 100644
index 1d45a26..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java
+++ /dev/null
@@ -1,229 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 6 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- */
-public class Tuple6<T0, T1, T2, T3, T4, T5> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple6() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- */
- public Tuple6(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- }
-
- @Override
- public int getArity() { return 6; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple6)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple6 tuple = (Tuple6) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple6<T0,T1,T2,T3,T4,T5> copy(){
- return new Tuple6<T0,T1,T2,T3,T4,T5>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5> Tuple6<T0,T1,T2,T3,T4,T5> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) {
- return new Tuple6<T0,T1,T2,T3,T4,T5>(value0, value1, value2, value3, value4, value5);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java
deleted file mode 100644
index 2008117..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple7.java
+++ /dev/null
@@ -1,244 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 7 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- */
-public class Tuple7<T0, T1, T2, T3, T4, T5, T6> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple7() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- */
- public Tuple7(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- }
-
- @Override
- public int getArity() { return 7; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple7)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple7 tuple = (Tuple7) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple7<T0,T1,T2,T3,T4,T5,T6> copy(){
- return new Tuple7<T0,T1,T2,T3,T4,T5,T6>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6> Tuple7<T0,T1,T2,T3,T4,T5,T6> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
- return new Tuple7<T0,T1,T2,T3,T4,T5,T6>(value0, value1, value2, value3, value4, value5, value6);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java
deleted file mode 100644
index 7aaa265..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple8.java
+++ /dev/null
@@ -1,259 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 8 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- */
-public class Tuple8<T0, T1, T2, T3, T4, T5, T6, T7> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple8() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- */
- public Tuple8(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- }
-
- @Override
- public int getArity() { return 8; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple8)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple8 tuple = (Tuple8) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple8<T0,T1,T2,T3,T4,T5,T6,T7> copy(){
- return new Tuple8<T0,T1,T2,T3,T4,T5,T6,T7>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7> Tuple8<T0,T1,T2,T3,T4,T5,T6,T7> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) {
- return new Tuple8<T0,T1,T2,T3,T4,T5,T6,T7>(value0, value1, value2, value3, value4, value5, value6, value7);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java
deleted file mode 100644
index 86ea998..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple9.java
+++ /dev/null
@@ -1,274 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 9 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- */
-public class Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple9() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- */
- public Tuple9(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- }
-
- @Override
- public int getArity() { return 9; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple9)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple9 tuple = (Tuple9) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8> copy(){
- return new Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8> Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) {
- return new Tuple9<T0,T1,T2,T3,T4,T5,T6,T7,T8>(value0, value1, value2, value3, value4, value5, value6, value7, value8);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/TupleGenerator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/TupleGenerator.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/TupleGenerator.java
deleted file mode 100644
index 70b9393..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/TupleGenerator.java
+++ /dev/null
@@ -1,879 +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.java.tuple;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Scanner;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-/**
- * Source code generator for tuple classes and classes which depend on the arity of tuples.
- */
-class TupleGenerator {
-
- // Parameters for tuple classes
-
- private static final String ROOT_DIRECTORY = "./src/main/java";
-
- private static final String PACKAGE = "org.apache.flink.api.java.tuple";
-
- private static final String BUILDER_SUFFIX = "builder";
-
- private static final String GEN_TYPE_PREFIX = "T";
-
- // Parameters for tuple-dependent classes
- private static final String BEGIN_INDICATOR = "BEGIN_OF_TUPLE_DEPENDENT_CODE";
-
- private static final String END_INDICATOR = "END_OF_TUPLE_DEPENDENT_CODE";
-
- // Parameters for CsvReader
- private static final String CSV_READER_PACKAGE = "org.apache.flink.api.java.io";
-
- private static final String CSV_READER_CLASSNAME = "CsvReader";
-
- // Parameters for TupleTypeInfo
- private static final String TUPLE_PACKAGE = "org.apache.flink.api.java.tuple";
-
- private static final String TUPLE_CLASSNAME = "Tuple";
-
- // Parameters for ProjectOperator
- private static final String PROJECT_OPERATOR_PACKAGE = "org.apache.flink.api.java.operators";
-
- private static final String PROJECT_OPERATOR_CLASSNAME = "ProjectOperator";
-
- // Parameters for JoinOperator
- private static final String JOIN_OPERATOR_PACKAGE = "org.apache.flink.api.java.operators";
-
- private static final String JOIN_OPERATOR_CLASSNAME = "JoinOperator";
-
- // parameters for CrossOperator
- private static final String CROSS_OPERATOR_PACKAGE = "org.apache.flink.api.java.operators";
-
- private static final String CROSS_OPERATOR_CLASSNAME = "CrossOperator";
-
- // min. and max. tuple arity
- private static final int FIRST = 1;
-
- private static final int LAST = 25;
-
- public static void main(String[] args) throws Exception {
- System.err.println("Current directory "+System.getProperty("user.dir"));
- String rootDir = ROOT_DIRECTORY;
- if(args.length > 0) {
- rootDir = args[0] + "/" + ROOT_DIRECTORY;
- }
- System.err.println("Using root directory: "+rootDir);
- File root = new File(rootDir);
-
- createTupleClasses(root);
-
- createTupleBuilderClasses(root);
-
- modifyCsvReader(root);
-
- modifyTupleType(root);
-
- modifyProjectOperator(root);
-
- modifyJoinProjectOperator(root);
-
- modifyCrossProjectOperator(root);
-
- }
-
- private static File getPackage(File root, String packageString) {
- File dir = new File(root, packageString.replace('.', '/'));
- if (!dir.exists() && dir.isDirectory()) {
- System.err.println("None existent directory: " + dir.getAbsolutePath());
- System.exit(1);
- }
- return dir;
- }
-
- private static void insertCodeIntoFile(String code, File file) throws IOException {
- String fileContent = Files.toString(file, Charsets.UTF_8);
- Scanner s = new Scanner(fileContent);
-
- StringBuilder sb = new StringBuilder();
- String line = null;
-
- boolean indicatorFound = false;
-
- // add file beginning
- while (s.hasNextLine() && (line = s.nextLine()) != null) {
- sb.append(line + "\n");
- if (line.contains(BEGIN_INDICATOR)) {
- indicatorFound = true;
- break;
- }
- }
-
- if(!indicatorFound) {
- System.out.println("No indicator found in '" + file + "'. Will skip code generation.");
- s.close();
- return;
- }
-
- // add generator signature
- sb.append("\t// GENERATED FROM " + TupleGenerator.class.getName() + ".\n");
-
- // add tuple dependent code
- sb.append(code + "\n");
-
- // skip generated code
- while (s.hasNextLine() && (line = s.nextLine()) != null) {
- if (line.contains(END_INDICATOR)) {
- sb.append(line + "\n");
- break;
- }
- }
-
- // add file ending
- while (s.hasNextLine() && (line = s.nextLine()) != null) {
- sb.append(line + "\n");
- }
- s.close();
- Files.write(sb.toString(), file, Charsets.UTF_8);
- }
-
- private static void modifyCrossProjectOperator(File root) throws IOException {
- // generate code
- StringBuilder sb = new StringBuilder();
-
- // method begin
- sb.append("\n");
-
- // method comment
- sb.append("\t\t/**\n");
- sb.append("\t\t * Chooses a projectTupleX according to the length of\n");
- sb.append("\t\t * {@link org.apache.flink.api.java.operators.CrossOperator.CrossProjection#fieldIndexes} \n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @return The projected DataSet.\n");
- sb.append("\t\t */\n");
-
- // method signature
- sb.append("\t\t@SuppressWarnings(\"unchecked\")\n");
- sb.append("\t\tpublic <OUT extends Tuple> ProjectCross<I1, I2, OUT> projectTupleX() {\n");
- sb.append("\t\t\tProjectCross<I1, I2, OUT> projectionCross = null;\n\n");
- sb.append("\t\t\tswitch (fieldIndexes.length) {\n");
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
- sb.append("\t\t\tcase " + numFields +":" + " projectionCross = (ProjectCross<I1, I2, OUT>) projectTuple"+numFields+"(); break;\n");
- }
- sb.append("\t\t\tdefault: throw new IllegalStateException(\"Excessive arity in tuple.\");\n");
- sb.append("\t\t\t}\n\n");
- sb.append("\t\t\treturn projectionCross;\n");
-
- // method end
- sb.append("\t\t}\n");
-
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
-
- // method begin
- sb.append("\n");
-
- // method comment
- sb.append("\t\t/**\n");
- sb.append("\t\t * Projects a pair of crossed elements to a {@link Tuple} with the previously selected fields. \n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @return The projected data set.\n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @see Tuple\n");
- sb.append("\t\t * @see DataSet\n");
- sb.append("\t\t */\n");
-
- // method signature
- sb.append("\t\tpublic <");
- appendTupleTypeGenerics(sb, numFields);
- sb.append("> ProjectCross<I1, I2, Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> projectTuple"+numFields+"(");
- sb.append(") {\n");
-
- // extract field types
- sb.append("\t\t\tTypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);\n");
-
- // create new tuple type info
- sb.append("\t\t\tTupleTypeInfo<Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> tType = new TupleTypeInfo<Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(fTypes);\n\n");
-
- // create and return new project operator
- sb.append("\t\t\treturn new ProjectCross<I1, I2, Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);\n");
-
- // method end
- sb.append("\t\t}\n");
-
- }
-
- // insert code into file
- File dir = getPackage(root, CROSS_OPERATOR_PACKAGE);
- File projectOperatorClass = new File(dir, CROSS_OPERATOR_CLASSNAME + ".java");
- insertCodeIntoFile(sb.toString(), projectOperatorClass);
- }
-
- private static void modifyProjectOperator(File root) throws IOException {
- // generate code
- StringBuilder sb = new StringBuilder();
-
- // method begin
- sb.append("\n");
-
- // method comment
- sb.append("\t\t/**\n");
- sb.append("\t\t * Chooses a projectTupleX according to the length of\n");
- sb.append("\t\t * {@link org.apache.flink.api.java.operators.ProjectOperator.Projection#fieldIndexes} \n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @return The projected DataSet.\n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @see org.apache.flink.api.java.operators.ProjectOperator.Projection\n");
- sb.append("\t\t */\n");
-
- // method signature
- sb.append("\t\t@SuppressWarnings(\"unchecked\")\n");
- sb.append("\t\tpublic <OUT extends Tuple> ProjectOperator<T, OUT> projectTupleX() {\n");
- sb.append("\t\t\tProjectOperator<T, OUT> projOperator;\n\n");
- sb.append("\t\t\tswitch (fieldIndexes.length) {\n");
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
- sb.append("\t\t\tcase " + numFields +":" + " projOperator = (ProjectOperator<T, OUT>) projectTuple"+numFields+"(); break;\n");
- }
- sb.append("\t\t\tdefault: throw new IllegalStateException(\"Excessive arity in tuple.\");\n");
- sb.append("\t\t\t}\n\n");
- sb.append("\t\t\treturn projOperator;\n");
-
- // method end
- sb.append("\t\t}\n");
-
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
-
- // method begin
- sb.append("\n");
-
- // method comment
- sb.append("\t\t/**\n");
- sb.append("\t\t * Projects a {@link Tuple} {@link DataSet} to the previously selected fields. \n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @return The projected DataSet.\n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @see Tuple\n");
- sb.append("\t\t * @see DataSet\n");
- sb.append("\t\t */\n");
-
- // method signature
- sb.append("\t\tpublic <");
- appendTupleTypeGenerics(sb, numFields);
- sb.append("> ProjectOperator<T, Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> projectTuple"+numFields+"(");
- sb.append(") {\n");
-
- // extract field types
- sb.append("\t\t\tTypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());\n");
-
- // create new tuple type info
- sb.append("\t\t\tTupleTypeInfo<Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> tType = new TupleTypeInfo<Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(fTypes);\n\n");
-
- // create and return new project operator
- sb.append("\t\t\treturn new ProjectOperator<T, Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(this.ds, this.fieldIndexes, tType);\n");
-
- // method end
- sb.append("\t\t}\n");
-
- }
-
- // insert code into file
- File dir = getPackage(root, PROJECT_OPERATOR_PACKAGE);
- File projectOperatorClass = new File(dir, PROJECT_OPERATOR_CLASSNAME + ".java");
- insertCodeIntoFile(sb.toString(), projectOperatorClass);
- }
-
- private static void modifyJoinProjectOperator(File root) throws IOException {
- // generate code
- StringBuilder sb = new StringBuilder();
-
- // method begin
- sb.append("\n");
-
- // method comment
- sb.append("\t\t/**\n");
- sb.append("\t\t * Chooses a projectTupleX according to the length of\n");
- sb.append("\t\t * {@link org.apache.flink.api.java.operators.JoinOperator.JoinProjection#fieldIndexes}\n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @return The projected DataSet.\n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @see org.apache.flink.api.java.operators.JoinOperator.ProjectJoin\n");
- sb.append("\t\t */\n");
-
- // method signature
- sb.append("\t\t@SuppressWarnings(\"unchecked\")\n");
- sb.append("\t\tpublic <OUT extends Tuple> ProjectJoin<I1, I2, OUT> projectTupleX() {\n");
- sb.append("\t\t\tProjectJoin<I1, I2, OUT> projectJoin = null;\n\n");
- sb.append("\t\t\tswitch (fieldIndexes.length) {\n");
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
- sb.append("\t\t\tcase " + numFields +":" + " projectJoin = (ProjectJoin<I1, I2, OUT>) projectTuple"+numFields+"(); break;\n");
- }
- sb.append("\t\t\tdefault: throw new IllegalStateException(\"Excessive arity in tuple.\");\n");
- sb.append("\t\t\t}\n\n");
- sb.append("\t\t\treturn projectJoin;\n");
-
- // method end
- sb.append("\t\t}\n");
-
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
-
- // method begin
- sb.append("\n");
-
- // method comment
- sb.append("\t\t/**\n");
- sb.append("\t\t * Projects a pair of joined elements to a {@link Tuple} with the previously selected fields. \n");
- sb.append("\t\t * Requires the classes of the fields of the resulting tuples. \n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @return The projected data set.\n");
- sb.append("\t\t * \n");
- sb.append("\t\t * @see Tuple\n");
- sb.append("\t\t * @see DataSet\n");
- sb.append("\t\t */\n");
-
- // method signature
- sb.append("\t\tpublic <");
- appendTupleTypeGenerics(sb, numFields);
- sb.append("> ProjectJoin<I1, I2, Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> projectTuple"+numFields+"(");
- sb.append(") {\n");
-
- // extract field types
- sb.append("\t\t\tTypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);\n");
-
- // create new tuple type info
- sb.append("\t\t\tTupleTypeInfo<Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> tType = new TupleTypeInfo<Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(fTypes);\n\n");
-
- // create and return new project operator
- sb.append("\t\t\treturn new ProjectJoin<I1, I2, Tuple"+numFields+"<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);\n");
-
- // method end
- sb.append("\t\t}\n");
-
- }
-
- // insert code into file
- File dir = getPackage(root, JOIN_OPERATOR_PACKAGE);
- File projectOperatorClass = new File(dir, JOIN_OPERATOR_CLASSNAME + ".java");
- insertCodeIntoFile(sb.toString(), projectOperatorClass);
- }
-
- private static void modifyTupleType(File root) throws IOException {
- // generate code
- StringBuilder sb = new StringBuilder();
- sb.append("\tprivate static final Class<?>[] CLASSES = new Class<?>[] {\n\t\tTuple0.class");
- for (int i = FIRST; i <= LAST; i++) {
- sb.append(", Tuple" + i + ".class");
- }
- sb.append("\n\t};");
-
- // insert code into file
- File dir = getPackage(root, TUPLE_PACKAGE);
- File tupleTypeInfoClass = new File(dir, TUPLE_CLASSNAME + ".java");
- insertCodeIntoFile(sb.toString(), tupleTypeInfoClass);
- }
-
- private static void modifyCsvReader(File root) throws IOException {
- // generate code
- StringBuilder sb = new StringBuilder(1000);
- for (int numFields = FIRST; numFields <= LAST; numFields++) {
-
- // method begin
- sb.append("\n");
-
- // java doc
- sb.append("\t/**\n");
- sb.append("\t * Specifies the types for the CSV fields. This method parses the CSV data to a ").append(numFields).append("-tuple\n");
- sb.append("\t * which has fields of the specified types.\n");
- sb.append("\t * This method is overloaded for each possible length of the tuples to support type safe\n");
- sb.append("\t * creation of data sets through CSV parsing.\n");
- sb.append("\t *\n");
-
- for (int pos = 0; pos < numFields; pos++) {
- sb.append("\t * @param type").append(pos);
- sb.append(" The type of CSV field ").append(pos).append(" and the type of field ");
- sb.append(pos).append(" in the returned tuple type.\n");
- }
- sb.append("\t * @return The {@link org.apache.flink.api.java.DataSet} representing the parsed CSV data.\n");
- sb.append("\t */\n");
-
- // method signature
- sb.append("\tpublic <");
- appendTupleTypeGenerics(sb, numFields);
- sb.append("> DataSource<Tuple" + numFields + "<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> types(");
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append("Class<");
- sb.append(GEN_TYPE_PREFIX + i);
- sb.append("> type" + i);
- }
- sb.append(") {\n");
-
- // get TupleTypeInfo
- sb.append("\t\tTupleTypeInfo<Tuple" + numFields + "<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> types = TupleTypeInfo.getBasicAndBasicValueTupleTypeInfo(");
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append("type" + i);
- }
- sb.append(");\n");
-
- // create csv input format
- sb.append("\t\tCsvInputFormat<Tuple" + numFields + "<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">> inputFormat = new TupleCsvInputFormat<Tuple" + numFields + "<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(path, types, this.includedMask);\n");
-
- // configure input format
- sb.append("\t\tconfigureInputFormat(inputFormat);\n");
-
- // return
- sb.append("\t\treturn new DataSource<Tuple" + numFields + "<");
- appendTupleTypeGenerics(sb, numFields);
- sb.append(">>(executionContext, inputFormat, types, Utils.getCallLocationName());\n");
-
- // end of method
- sb.append("\t}\n");
- }
-
- // insert code into file
- File dir = getPackage(root, CSV_READER_PACKAGE);
- File csvReaderClass = new File(dir, CSV_READER_CLASSNAME + ".java");
- insertCodeIntoFile(sb.toString(), csvReaderClass);
- }
-
- private static void appendTupleTypeGenerics(StringBuilder sb, int numFields) {
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append(GEN_TYPE_PREFIX + i);
- }
- }
-
- private static void createTupleClasses(File root) throws FileNotFoundException {
- File dir = getPackage(root, PACKAGE);
-
- for (int i = FIRST; i <= LAST; i++) {
- File tupleFile = new File(dir, "Tuple" + i + ".java");
- PrintWriter writer = new PrintWriter(tupleFile);
- writeTupleClass(writer, i);
- writer.flush();
- writer.close();
- }
- }
-
- private static void writeTupleClass(PrintWriter w, int numFields) {
- final String className = "Tuple" + numFields;
-
- // head
- w.print(HEADER);
-
- // package and imports
- w.println("package " + PACKAGE + ';');
- w.println();
- w.println("import org.apache.flink.util.StringUtils;");
- w.println();
-
- // class declaration and class comments
- w.println("/**");
- w.println(" * A tuple with " + numFields + " fields. Tuples are strongly typed; each field may be of a separate type.");
- w.println(" * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position");
- w.println(" * through the {@link #getField(int)} method. The tuple field positions start at zero.");
- w.println(" * <p>");
- w.println(" * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work");
- w.println(" * with Tuples to reuse objects in order to reduce pressure on the garbage collector.");
- w.println(" *");
- w.println(" * @see Tuple");
- w.println(" *");
- for (int i = 0; i < numFields; i++) {
- w.println(" * @param <" + GEN_TYPE_PREFIX + i + "> The type of field " + i);
- }
- w.println(" */");
- w.print("public class " + className + "<");
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- w.print(", ");
- }
- w.print(GEN_TYPE_PREFIX + i);
- }
- w.println("> extends Tuple {");
- w.println();
-
- w.println("\tprivate static final long serialVersionUID = 1L;");
- w.println();
-
- // fields
- for (int i = 0; i < numFields; i++) {
- w.println("\t/** Field " + i + " of the tuple. */");
- w.println("\tpublic " + GEN_TYPE_PREFIX + i + " f" + i + ';');
- }
- w.println();
-
- String paramList = "("; // This will be like "(T0 value0, T1 value1)"
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- paramList += ", ";
- }
- paramList += GEN_TYPE_PREFIX + i + " value" + i;
- }
- paramList += ")";
-
- // constructors
- w.println("\t/**");
- w.println("\t * Creates a new tuple where all fields are null.");
- w.println("\t */");
- w.println("\tpublic " + className + "() {}");
- w.println();
- w.println("\t/**");
- w.println("\t * Creates a new tuple and assigns the given values to the tuple's fields.");
- w.println("\t *");
- for (int i = 0; i < numFields; i++) {
- w.println("\t * @param value" + i + " The value for field " + i);
- }
- w.println("\t */");
- w.println("\tpublic " + className + paramList + " {");
- for (int i = 0; i < numFields; i++) {
- w.println("\t\tthis.f" + i + " = value" + i + ';');
- }
- w.println("\t}");
- w.println();
-
-
- // arity accessor
- w.println("\t@Override");
- w.println("\tpublic int getArity() { return " + numFields + "; }");
- w.println();
-
- // accessor getter method
- w.println("\t@Override");
- w.println("\t@SuppressWarnings(\"unchecked\")");
- w.println("\tpublic <T> T getField(int pos) {");
- w.println("\t\tswitch(pos) {");
- for (int i = 0; i < numFields; i++) {
- w.println("\t\t\tcase " + i + ": return (T) this.f" + i + ';');
- }
- w.println("\t\t\tdefault: throw new IndexOutOfBoundsException(String.valueOf(pos));");
- w.println("\t\t}");
- w.println("\t}");
- w.println();
-
- // accessor setter method
- w.println("\t@Override");
- w.println("\t@SuppressWarnings(\"unchecked\")");
- w.println("\tpublic <T> void setField(T value, int pos) {");
- w.println("\t\tswitch(pos) {");
- for (int i = 0; i < numFields; i++) {
- w.println("\t\t\tcase " + i + ':');
- w.println("\t\t\t\tthis.f" + i + " = (" + GEN_TYPE_PREFIX + i + ") value;");
- w.println("\t\t\t\tbreak;");
- }
- w.println("\t\t\tdefault: throw new IndexOutOfBoundsException(String.valueOf(pos));");
- w.println("\t\t}");
- w.println("\t}");
- w.println();
-
- // accessor setter method for all fields
- w.println("\t/**");
- w.println("\t * Sets new values to all fields of the tuple.");
- w.println("\t *");
- for (int i = 0; i < numFields; i++) {
- w.println("\t * @param value" + i + " The value for field " + i);
- }
- w.println("\t */");
- w.println("\tpublic void setFields" + paramList + " {");
- for (int i = 0; i < numFields; i++) {
- w.println("\t\tthis.f" + i + " = value" + i + ';');
- }
- w.println("\t}");
- w.println();
-
- // swap method only for Tuple2
- if (numFields == 2) {
- w.println("\t/**");
- w.println("\t* Returns a shallow copy of the tuple with swapped values.");
- w.println("\t*");
- w.println("\t* @return shallow copy of the tuple with swapped values");
- w.println("\t*/");
- w.println("\tpublic Tuple2<T1, T0> swap() {");
- w.println("\t\treturn new Tuple2<T1, T0>(f1, f0);");
- w.println("\t}");
- }
-
- // standard utilities (toString, equals, hashCode, copy)
- w.println();
- w.println("\t// -------------------------------------------------------------------------------------------------");
- w.println("\t// standard utilities");
- w.println("\t// -------------------------------------------------------------------------------------------------");
- w.println();
- w.println("\t/**");
- w.println("\t * Creates a string representation of the tuple in the form");
- w.print("\t * (f0");
- for (int i = 1; i < numFields; i++) {
- w.print(", f" + i);
- }
- w.println("),");
- w.println("\t * where the individual fields are the value returned by calling {@link Object#toString} on that field.");
- w.println("\t * @return The string representation of the tuple.");
- w.println("\t */");
- w.println("\t@Override");
- w.println("\tpublic String toString() {");
- w.println("\t\treturn \"(\" + StringUtils.arrayAwareToString(this.f0)");
- for (int i = 1; i < numFields; i++) {
- w.println("\t\t\t+ \",\" + StringUtils.arrayAwareToString(this.f" + i + ")");
- }
- w.println("\t\t\t+ \")\";");
- w.println("\t}");
-
- w.println();
- w.println("\t/**");
- w.println("\t * Deep equality for tuples by calling equals() on the tuple members");
- w.println("\t * @param o the object checked for equality");
- w.println("\t * @return true if this is equal to o.");
- w.println("\t */");
- w.println("\t@Override");
- w.println("\tpublic boolean equals(Object o) {");
- w.println("\t\tif(this == o) { return true; }");
- w.println("\t\tif (!(o instanceof " + className + ")) { return false; }");
- w.println("\t\t@SuppressWarnings(\"rawtypes\")");
- w.println("\t\t" + className + " tuple = (" + className + ") o;");
- for (int i = 0; i < numFields; i++) {
- String field = "f" + i;
- w.println("\t\tif (" + field + " != null ? !" + field +".equals(tuple." +
- field + ") : tuple." + field + " != null) { return false; }");
- }
- w.println("\t\treturn true;");
- w.println("\t}");
-
- w.println();
- w.println("\t@Override");
- w.println("\tpublic int hashCode() {");
- w.println("\t\tint result = f0 != null ? f0.hashCode() : 0;");
- for (int i = 1; i < numFields; i++) {
- String field = "f" + i;
- w.println("\t\tresult = 31 * result + (" + field + " != null ? " + field + ".hashCode() : 0);");
- }
- w.println("\t\treturn result;");
- w.println("\t}");
-
-
- String tupleTypes = "<";
- for (int i = 0; i < numFields; i++) {
- tupleTypes += "T" + i;
- if (i < numFields - 1) {
- tupleTypes += ",";
- }
- }
- tupleTypes += ">";
-
- w.println();
- w.println("\t/**");
- w.println("\t* Shallow tuple copy.");
- w.println("\t* @return A new Tuple with the same fields as this.");
- w.println("\t*/");
- w.println("\t@Override");
- w.println("\t@SuppressWarnings(\"unchecked\")");
- w.println("\tpublic " + className + tupleTypes + " copy(){ ");
-
- w.print("\t\treturn new " + className + tupleTypes + "(this.f0");
- if (numFields > 1) {
- w.println(",");
- }
- for (int i = 1; i < numFields; i++) {
- String field = "f" + i;
- w.print("\t\t\tthis." + field);
- if (i < numFields - 1) {
- w.println(",");
- }
- }
- w.println(");");
- w.println("\t}");
-
- w.println();
- w.println("\t/**");
- w.println("\t * Creates a new tuple and assigns the given values to the tuple's fields.");
- w.println("\t * This is more convenient than using the constructor, because the compiler can");
- w.println("\t * infer the generic type arguments implicitly. For example:");
- w.println("\t * {@code Tuple3.of(n, x, s)}");
- w.println("\t * instead of");
- w.println("\t * {@code new Tuple3<Integer, Double, String>(n, x, s)}");
- w.println("\t */");
- w.println("\tpublic static " + tupleTypes + " " + className + tupleTypes + " of" + paramList + " {");
- w.print("\t\treturn new " + className + tupleTypes + "(");
- for(int i = 0; i < numFields; i++) {
- w.print("value" + i);
- if(i < numFields - 1) {
- w.print(", ");
- }
- }
- w.println(");");
- w.println("\t}");
-
- // foot
- w.println("}");
- }
-
- private static void createTupleBuilderClasses(File root) throws FileNotFoundException {
- File dir = getPackage(root, PACKAGE+"."+BUILDER_SUFFIX);
-
- for (int i = FIRST; i <= LAST; i++) {
- File tupleFile = new File(dir, "Tuple" + i + "Builder.java");
- PrintWriter writer = new PrintWriter(tupleFile);
- writeTupleBuilderClass(writer, i);
- writer.flush();
- writer.close();
- }
- }
-
- private static void printGenericsString(PrintWriter w, int numFields){
- w.print("<");
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- w.print(", ");
- }
- w.print(GEN_TYPE_PREFIX + i);
- }
- w.print(">");
- }
-
- private static void writeTupleBuilderClass(PrintWriter w, int numFields) {
- final String className = "Tuple" + numFields + "Builder";
-
- // head
- w.print(HEADER);
-
- // package and imports
- w.println("package " + PACKAGE + "." + BUILDER_SUFFIX + ';');
- w.println();
- w.println("import java.util.ArrayList;");
- w.println("import java.util.List;");
- w.println();
- w.println("import " + PACKAGE + ".Tuple" + numFields + ";");
- w.println();
-
- // class declaration
- w.print("public class " + className);
- printGenericsString(w, numFields);
- w.println(" {");
- w.println();
-
- // Class-Attributes - a list of tuples
- w.print("\tprivate List<Tuple" + numFields);
- printGenericsString(w, numFields);
- w.print("> tuples = new ArrayList<Tuple" + numFields );
- printGenericsString(w, numFields);
- w.println(">();");
- w.println();
-
- // add(...) function for adding a single tuple
- w.print("\tpublic " + className);
- printGenericsString(w, numFields);
- w.print(" add(");
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- w.print(", ");
- }
- w.print(GEN_TYPE_PREFIX + i + " value" + i);
- }
- w.println("){");
- w.print("\t\ttuples.add(new Tuple" + numFields);
- printGenericsString(w, numFields);
- w.print("(");
- for (int i = 0; i < numFields; i++) {
- if (i > 0) {
- w.print(", ");
- }
- w.print("value" + i);
- }
- w.println("));");
- w.println("\t\treturn this;");
- w.println("\t}");
- w.println();
-
- // build() function, returns an array of tuples
- w.println("\t@SuppressWarnings(\"unchecked\")");
- w.print("\tpublic Tuple" + numFields);
- printGenericsString(w, numFields);
- w.println("[] build(){");
- w.println("\t\treturn tuples.toArray(new Tuple" + numFields + "[tuples.size()]);");
- w.println("\t}");
-
- // foot
- w.println("}");
- }
-
- private static String HEADER =
- "/*\n"
- + " * Licensed to the Apache Software Foundation (ASF) under one\n"
- + " * or more contributor license agreements. See the NOTICE file\n"
- + " * distributed with this work for additional information\n"
- + " * regarding copyright ownership. The ASF licenses this file\n"
- + " * to you under the Apache License, Version 2.0 (the\n"
- + " * \"License\"); you may not use this file except in compliance\n"
- + " * with the License. You may obtain a copy of the License at\n"
- + " *\n"
- + " * http://www.apache.org/licenses/LICENSE-2.0\n"
- + " *\n"
- + " * Unless required by applicable law or agreed to in writing, software\n"
- + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"
- + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
- + " * See the License for the specific language governing permissions and\n"
- + " * limitations under the License.\n"
- + " */" +
- "\n" +
- "\n" +
- "\n" +
- "// --------------------------------------------------------------\n" +
- "// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!\n" +
- "// GENERATED FROM " + TupleGenerator.class.getName() + ".\n" +
- "// --------------------------------------------------------------\n\n\n";
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java
deleted file mode 100644
index 5facb7e..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple0Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple0;
-
-public class Tuple0Builder {
-
- private List<Tuple0> tuples = new ArrayList<Tuple0>();
-
- public Tuple0Builder add() {
- tuples.add(Tuple0.INSTANCE);
- return this;
- }
-
- public Tuple0[] build() {
- return tuples.toArray(new Tuple0[tuples.size()]);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java
deleted file mode 100644
index d09ba11..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple10Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple10;
-
-public class Tuple10Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> {
-
- private List<Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>> tuples = new ArrayList<Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>>();
-
- public Tuple10Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9){
- tuples.add(new Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>[] build(){
- return tuples.toArray(new Tuple10[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java
deleted file mode 100644
index 727fab0..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple11Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple11;
-
-public class Tuple11Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> {
-
- private List<Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> tuples = new ArrayList<Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>();
-
- public Tuple11Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10){
- tuples.add(new Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>[] build(){
- return tuples.toArray(new Tuple11[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java
deleted file mode 100644
index 7f77a8d..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple12Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple12;
-
-public class Tuple12Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> {
-
- private List<Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> tuples = new ArrayList<Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>();
-
- public Tuple12Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11){
- tuples.add(new Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>[] build(){
- return tuples.toArray(new Tuple12[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java
deleted file mode 100644
index e223e7a..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple13Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple13;
-
-public class Tuple13Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> {
-
- private List<Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>> tuples = new ArrayList<Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>();
-
- public Tuple13Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12){
- tuples.add(new Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>[] build(){
- return tuples.toArray(new Tuple13[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java
deleted file mode 100644
index a3847c2..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple14Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple14;
-
-public class Tuple14Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> {
-
- private List<Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> tuples = new ArrayList<Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>>();
-
- public Tuple14Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13){
- tuples.add(new Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>[] build(){
- return tuples.toArray(new Tuple14[tuples.size()]);
- }
-}
[31/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java
new file mode 100644
index 0000000..0d45352
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java
@@ -0,0 +1,364 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 15 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ */
+public class Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple15() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ */
+ public Tuple15(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ }
+
+ @Override
+ public int getArity() { return 15; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple15)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple15 tuple = (Tuple15) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> copy(){
+ return new Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
+ return new Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java
new file mode 100644
index 0000000..5c57ee7
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java
@@ -0,0 +1,379 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 16 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ */
+public class Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple16() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ */
+ public Tuple16(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ }
+
+ @Override
+ public int getArity() { return 16; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple16)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple16 tuple = (Tuple16) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> copy(){
+ return new Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
+ return new Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java
new file mode 100644
index 0000000..70da5bb
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java
@@ -0,0 +1,394 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 17 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ */
+public class Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple17() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ */
+ public Tuple17(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ }
+
+ @Override
+ public int getArity() { return 17; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple17)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple17 tuple = (Tuple17) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> copy(){
+ return new Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
+ return new Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java
new file mode 100644
index 0000000..c221ee6
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java
@@ -0,0 +1,409 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 18 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ */
+public class Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple18() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ */
+ public Tuple18(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ }
+
+ @Override
+ public int getArity() { return 18; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple18)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple18 tuple = (Tuple18) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> copy(){
+ return new Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
+ return new Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java
new file mode 100644
index 0000000..3d4d262
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java
@@ -0,0 +1,424 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 19 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ * @param <T14> The type of field 14
+ * @param <T15> The type of field 15
+ * @param <T16> The type of field 16
+ * @param <T17> The type of field 17
+ * @param <T18> The type of field 18
+ */
+public class Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+ /** Field 14 of the tuple. */
+ public T14 f14;
+ /** Field 15 of the tuple. */
+ public T15 f15;
+ /** Field 16 of the tuple. */
+ public T16 f16;
+ /** Field 17 of the tuple. */
+ public T17 f17;
+ /** Field 18 of the tuple. */
+ public T18 f18;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple19() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ */
+ public Tuple19(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ }
+
+ @Override
+ public int getArity() { return 19; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ case 14: return (T) this.f14;
+ case 15: return (T) this.f15;
+ case 16: return (T) this.f16;
+ case 17: return (T) this.f17;
+ case 18: return (T) this.f18;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ case 14:
+ this.f14 = (T14) value;
+ break;
+ case 15:
+ this.f15 = (T15) value;
+ break;
+ case 16:
+ this.f16 = (T16) value;
+ break;
+ case 17:
+ this.f17 = (T17) value;
+ break;
+ case 18:
+ this.f18 = (T18) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ * @param value14 The value for field 14
+ * @param value15 The value for field 15
+ * @param value16 The value for field 16
+ * @param value17 The value for field 17
+ * @param value18 The value for field 18
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ this.f14 = value14;
+ this.f15 = value15;
+ this.f16 = value16;
+ this.f17 = value17;
+ this.f18 = value18;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + "," + StringUtils.arrayAwareToString(this.f14)
+ + "," + StringUtils.arrayAwareToString(this.f15)
+ + "," + StringUtils.arrayAwareToString(this.f16)
+ + "," + StringUtils.arrayAwareToString(this.f17)
+ + "," + StringUtils.arrayAwareToString(this.f18)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple19)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple19 tuple = (Tuple19) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
+ if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
+ if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
+ if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
+ if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ result = 31 * result + (f14 != null ? f14.hashCode() : 0);
+ result = 31 * result + (f15 != null ? f15.hashCode() : 0);
+ result = 31 * result + (f16 != null ? f16.hashCode() : 0);
+ result = 31 * result + (f17 != null ? f17.hashCode() : 0);
+ result = 31 * result + (f18 != null ? f18.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> copy(){
+ return new Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13,
+ this.f14,
+ this.f15,
+ this.f16,
+ this.f17,
+ this.f18);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
+ return new Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java
new file mode 100644
index 0000000..4ec930c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 2 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ */
+public class Tuple2<T0, T1> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple2() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ */
+ public Tuple2(T0 value0, T1 value1) {
+ this.f0 = value0;
+ this.f1 = value1;
+ }
+
+ @Override
+ public int getArity() { return 2; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ */
+ public void setFields(T0 value0, T1 value1) {
+ this.f0 = value0;
+ this.f1 = value1;
+ }
+
+ /**
+ * Returns a shallow copy of the tuple with swapped values.
+ *
+ * @return shallow copy of the tuple with swapped values
+ */
+ public Tuple2<T1, T0> swap() {
+ return new Tuple2<T1, T0>(f1, f0);
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple2)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple2 tuple = (Tuple2) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple2<T0,T1> copy(){
+ return new Tuple2<T0,T1>(this.f0,
+ this.f1);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1> Tuple2<T0,T1> of(T0 value0, T1 value1) {
+ return new Tuple2<T0,T1>(value0, value1);
+ }
+}
[09/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java
deleted file mode 100644
index 5187de7..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/ValueTypeInfo.java
+++ /dev/null
@@ -1,183 +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.java.typeutils;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.api.common.typeinfo.AtomicType;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.CopyableValueComparator;
-import org.apache.flink.api.java.typeutils.runtime.CopyableValueSerializer;
-import org.apache.flink.api.java.typeutils.runtime.ValueComparator;
-import org.apache.flink.api.java.typeutils.runtime.ValueSerializer;
-import org.apache.flink.types.BooleanValue;
-import org.apache.flink.types.ByteValue;
-import org.apache.flink.types.CharValue;
-import org.apache.flink.types.CopyableValue;
-import org.apache.flink.types.DoubleValue;
-import org.apache.flink.types.FloatValue;
-import org.apache.flink.types.IntValue;
-import org.apache.flink.types.LongValue;
-import org.apache.flink.types.NullValue;
-import org.apache.flink.types.ShortValue;
-import org.apache.flink.types.StringValue;
-import org.apache.flink.types.Value;
-
-/**
- * Type information for data types that extend the {@link Value} interface. The value
- * interface allows types to define their custom serialization and deserialization routines.
- *
- * @param <T> The type of the class represented by this type information.
- */
-public class ValueTypeInfo<T extends Value> extends TypeInformation<T> implements AtomicType<T> {
-
- private static final long serialVersionUID = 1L;
-
- public static final ValueTypeInfo<BooleanValue> BOOLEAN_VALUE_TYPE_INFO = new ValueTypeInfo<>(BooleanValue.class);
- public static final ValueTypeInfo<ByteValue> BYTE_VALUE_TYPE_INFO = new ValueTypeInfo<>(ByteValue.class);
- public static final ValueTypeInfo<CharValue> CHAR_VALUE_TYPE_INFO = new ValueTypeInfo<>(CharValue.class);
- public static final ValueTypeInfo<DoubleValue> DOUBLE_VALUE_TYPE_INFO = new ValueTypeInfo<>(DoubleValue.class);
- public static final ValueTypeInfo<FloatValue> FLOAT_VALUE_TYPE_INFO = new ValueTypeInfo<>(FloatValue.class);
- public static final ValueTypeInfo<IntValue> INT_VALUE_TYPE_INFO = new ValueTypeInfo<>(IntValue.class);
- public static final ValueTypeInfo<LongValue> LONG_VALUE_TYPE_INFO = new ValueTypeInfo<>(LongValue.class);
- public static final ValueTypeInfo<NullValue> NULL_VALUE_TYPE_INFO = new ValueTypeInfo<>(NullValue.class);
- public static final ValueTypeInfo<ShortValue> SHORT_VALUE_TYPE_INFO = new ValueTypeInfo<>(ShortValue.class);
- public static final ValueTypeInfo<StringValue> STRING_VALUE_TYPE_INFO = new ValueTypeInfo<>(StringValue.class);
-
- private final Class<T> type;
-
- public ValueTypeInfo(Class<T> type) {
- this.type = Preconditions.checkNotNull(type);
-
- Preconditions.checkArgument(
- Value.class.isAssignableFrom(type) || type.equals(Value.class),
- "ValueTypeInfo can only be used for subclasses of " + Value.class.getName());
- }
-
- @Override
- public int getArity() {
- return 1;
- }
-
- @Override
- public int getTotalFields() {
- return 1;
- }
-
- @Override
- public Class<T> getTypeClass() {
- return this.type;
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- public boolean isBasicValueType() {
- return type.equals(StringValue.class) || type.equals(ByteValue.class) || type.equals(ShortValue.class) || type.equals(CharValue.class) ||
- type.equals(DoubleValue.class) || type.equals(FloatValue.class) || type.equals(IntValue.class) || type.equals(LongValue.class) ||
- type.equals(NullValue.class) || type.equals(BooleanValue.class);
- }
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public boolean isKeyType() {
- return Comparable.class.isAssignableFrom(type);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
- if (CopyableValue.class.isAssignableFrom(type)) {
- return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
- }
- else {
- return new ValueSerializer<T>(type);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
- if (!isKeyType()) {
- throw new RuntimeException("The type " + type.getName() + " is not Comparable.");
- }
-
- if (CopyableValue.class.isAssignableFrom(type)) {
- return (TypeComparator<T>) new CopyableValueComparator(sortOrderAscending, type);
- }
- else {
- return (TypeComparator<T>) new ValueComparator(sortOrderAscending, type);
- }
- }
-
- // utility method to summon the necessary bound
- private static <X extends CopyableValue<X>> CopyableValueSerializer<X> createCopyableValueSerializer(Class<X> clazz) {
- return new CopyableValueSerializer<X>(clazz);
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return this.type.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ValueTypeInfo) {
- @SuppressWarnings("unchecked")
- ValueTypeInfo<T> valueTypeInfo = (ValueTypeInfo<T>) obj;
-
- return valueTypeInfo.canEqual(this) &&
- type == valueTypeInfo.type;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof ValueTypeInfo;
- }
-
- @Override
- public String toString() {
- return "ValueType<" + type.getSimpleName() + ">";
- }
-
- // --------------------------------------------------------------------------------------------
-
- static <X extends Value> TypeInformation<X> getValueTypeInfo(Class<X> typeClass) {
- if (Value.class.isAssignableFrom(typeClass) && !typeClass.equals(Value.class)) {
- return new ValueTypeInfo<X>(typeClass);
- }
- else {
- throw new InvalidTypesException("The given class is no subclass of " + Value.class.getName());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java
deleted file mode 100644
index 6c140d9..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/WritableTypeInfo.java
+++ /dev/null
@@ -1,139 +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.java.typeutils;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.api.common.typeinfo.AtomicType;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.WritableComparator;
-import org.apache.flink.api.java.typeutils.runtime.WritableSerializer;
-import org.apache.hadoop.io.Writable;
-
-/**
- * Type information for data types that extend Hadoop's {@link Writable} interface. The Writable
- * interface defines the serialization and deserialization routines for the data type.
- *
- * @param <T> The type of the class represented by this type information.
- */
-public class WritableTypeInfo<T extends Writable> extends TypeInformation<T> implements AtomicType<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> typeClass;
-
- public WritableTypeInfo(Class<T> typeClass) {
- this.typeClass = Preconditions.checkNotNull(typeClass);
-
- Preconditions.checkArgument(
- Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class),
- "WritableTypeInfo can only be used for subclasses of " + Writable.class.getName());
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
- if(Comparable.class.isAssignableFrom(typeClass)) {
- return new WritableComparator(sortOrderAscending, typeClass);
- }
- else {
- throw new UnsupportedOperationException("Cannot create Comparator for "+typeClass.getCanonicalName()+". " +
- "Class does not implement Comparable interface.");
- }
- }
-
- @Override
- public boolean isBasicType() {
- return false;
- }
-
- @Override
- public boolean isTupleType() {
- return false;
- }
-
- @Override
- public int getArity() {
- return 1;
- }
-
- @Override
- public int getTotalFields() {
- return 1;
- }
-
- @Override
- public Class<T> getTypeClass() {
- return this.typeClass;
- }
-
- @Override
- public boolean isKeyType() {
- return Comparable.class.isAssignableFrom(typeClass);
- }
-
- @Override
- public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
- return new WritableSerializer<T>(typeClass);
- }
-
- @Override
- public String toString() {
- return "WritableType<" + typeClass.getName() + ">";
- }
-
- @Override
- public int hashCode() {
- return typeClass.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof WritableTypeInfo) {
- @SuppressWarnings("unchecked")
- WritableTypeInfo<T> writableTypeInfo = (WritableTypeInfo<T>) obj;
-
- return writableTypeInfo.canEqual(this) &&
- typeClass == writableTypeInfo.typeClass;
-
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof WritableTypeInfo;
- }
-
- // --------------------------------------------------------------------------------------------
-
- static <T extends Writable> TypeInformation<T> getWritableTypeInfo(Class<T> typeClass) {
- if (Writable.class.isAssignableFrom(typeClass) && !typeClass.equals(Writable.class)) {
- return new WritableTypeInfo<T>(typeClass);
- }
- else {
- throw new InvalidTypesException("The given class is no subclass of " + Writable.class.getName());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java
deleted file mode 100644
index bc04367..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializer.java
+++ /dev/null
@@ -1,201 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import com.google.common.base.Preconditions;
-import org.apache.avro.generic.GenericData;
-import org.apache.avro.reflect.ReflectDatumReader;
-import org.apache.avro.reflect.ReflectDatumWriter;
-import org.apache.avro.util.Utf8;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.kryo.Serializers;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.util.InstantiationUtil;
-
-import com.esotericsoftware.kryo.Kryo;
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-
-/**
- * General purpose serialization. Currently using Apache Avro's Reflect-serializers for serialization and
- * Kryo for deep object copies. We want to change this to Kryo-only.
- *
- * @param <T> The type serialized.
- */
-public final class AvroSerializer<T> extends TypeSerializer<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> type;
-
- private final Class<? extends T> typeToInstantiate;
-
- private transient ReflectDatumWriter<T> writer;
- private transient ReflectDatumReader<T> reader;
-
- private transient DataOutputEncoder encoder;
- private transient DataInputDecoder decoder;
-
- private transient Kryo kryo;
-
- private transient T deepCopyInstance;
-
- // --------------------------------------------------------------------------------------------
-
- public AvroSerializer(Class<T> type) {
- this(type, type);
- }
-
- public AvroSerializer(Class<T> type, Class<? extends T> typeToInstantiate) {
- this.type = Preconditions.checkNotNull(type);
- this.typeToInstantiate = Preconditions.checkNotNull(typeToInstantiate);
-
- InstantiationUtil.checkForInstantiation(typeToInstantiate);
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public AvroSerializer<T> duplicate() {
- return new AvroSerializer<T>(type, typeToInstantiate);
- }
-
- @Override
- public T createInstance() {
- return InstantiationUtil.instantiate(this.typeToInstantiate);
- }
-
- @Override
- public T copy(T from) {
- checkKryoInitialized();
-
- return KryoUtils.copy(from, kryo, this);
- }
-
- @Override
- public T copy(T from, T reuse) {
- checkKryoInitialized();
-
- return KryoUtils.copy(from, reuse, kryo, this);
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
- @Override
- public void serialize(T value, DataOutputView target) throws IOException {
- checkAvroInitialized();
- this.encoder.setOut(target);
- this.writer.write(value, this.encoder);
- }
-
- @Override
- public T deserialize(DataInputView source) throws IOException {
- checkAvroInitialized();
- this.decoder.setIn(source);
- return this.reader.read(null, this.decoder);
- }
-
- @Override
- public T deserialize(T reuse, DataInputView source) throws IOException {
- checkAvroInitialized();
- this.decoder.setIn(source);
- return this.reader.read(reuse, this.decoder);
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- checkAvroInitialized();
-
- if (this.deepCopyInstance == null) {
- this.deepCopyInstance = InstantiationUtil.instantiate(type, Object.class);
- }
-
- this.decoder.setIn(source);
- this.encoder.setOut(target);
-
- T tmp = this.reader.read(this.deepCopyInstance, this.decoder);
- this.writer.write(tmp, this.encoder);
- }
-
-
- private void checkAvroInitialized() {
- if (this.reader == null) {
- this.reader = new ReflectDatumReader<T>(type);
- this.writer = new ReflectDatumWriter<T>(type);
- this.encoder = new DataOutputEncoder();
- this.decoder = new DataInputDecoder();
- }
- }
-
- private void checkKryoInitialized() {
- if (this.kryo == null) {
- this.kryo = new Kryo();
-
- Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
- instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
- kryo.setInstantiatorStrategy(instantiatorStrategy);
-
- // register Avro types.
- this.kryo.register(GenericData.Array.class, new Serializers.SpecificInstanceCollectionSerializerForArrayList());
- this.kryo.register(Utf8.class);
- this.kryo.register(GenericData.EnumSymbol.class);
- this.kryo.register(GenericData.Fixed.class);
- this.kryo.register(GenericData.StringType.class);
- this.kryo.setAsmEnabled(true);
- this.kryo.register(type);
- }
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return 31 * this.type.hashCode() + this.typeToInstantiate.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof AvroSerializer) {
- @SuppressWarnings("unchecked")
- AvroSerializer<T> avroSerializer = (AvroSerializer<T>) obj;
-
- return avroSerializer.canEqual(this) &&
- type == avroSerializer.type &&
- typeToInstantiate == avroSerializer.typeToInstantiate;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof AvroSerializer;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java
deleted file mode 100644
index 9b3b191..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparator.java
+++ /dev/null
@@ -1,167 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.types.CopyableValue;
-import org.apache.flink.types.NormalizableKey;
-import org.apache.flink.util.InstantiationUtil;
-
-/**
- * Comparator for all Value types that extend Key
- */
-public class CopyableValueComparator<T extends CopyableValue<T> & Comparable<T>> extends TypeComparator<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> type;
-
- private final boolean ascendingComparison;
-
- private transient T reference;
-
- private transient T tempReference;
-
- private final TypeComparator<?>[] comparators = new TypeComparator[] {this};
-
- public CopyableValueComparator(boolean ascending, Class<T> type) {
- this.type = type;
- this.ascendingComparison = ascending;
- this.reference = InstantiationUtil.instantiate(type, CopyableValue.class);
- }
-
- @Override
- public int hash(T record) {
- return record.hashCode();
- }
-
- @Override
- public void setReference(T toCompare) {
- toCompare.copyTo(reference);
- }
-
- @Override
- public boolean equalToReference(T candidate) {
- return candidate.equals(this.reference);
- }
-
- @Override
- public int compareToReference(TypeComparator<T> referencedComparator) {
- T otherRef = ((CopyableValueComparator<T>) referencedComparator).reference;
- int comp = otherRef.compareTo(reference);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public int compare(T first, T second) {
- int comp = first.compareTo(second);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
- if (tempReference == null) {
- tempReference = InstantiationUtil.instantiate(type, CopyableValue.class);
- }
-
- reference.read(firstSource);
- tempReference.read(secondSource);
- int comp = reference.compareTo(tempReference);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public boolean supportsNormalizedKey() {
- return NormalizableKey.class.isAssignableFrom(type);
- }
-
- @Override
- public int getNormalizeKeyLen() {
- NormalizableKey<?> key = (NormalizableKey<?>) reference;
- return key.getMaxNormalizedKeyLen();
- }
-
- @Override
- public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
- return keyBytes < getNormalizeKeyLen();
- }
-
- @Override
- public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
- NormalizableKey<?> key = (NormalizableKey<?>) record;
- key.copyNormalizedKey(target, offset, numBytes);
- }
-
- @Override
- public boolean invertNormalizedKey() {
- return !ascendingComparison;
- }
-
- @Override
- public TypeComparator<T> duplicate() {
- return new CopyableValueComparator<T>(ascendingComparison, type);
- }
-
- @Override
- public int extractKeys(Object record, Object[] target, int index) {
- target[index] = record;
- return 1;
- }
-
- @Override
- public TypeComparator<?>[] getFlatComparators() {
- return comparators;
- }
-
- // --------------------------------------------------------------------------------------------
- // unsupported normalization
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean supportsSerializationWithKeyNormalization() {
- return false;
- }
-
- @Override
- public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- // --------------------------------------------------------------------------------------------
- // serialization
- // --------------------------------------------------------------------------------------------
-
- private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
- // read basic object and the type
- s.defaultReadObject();
-
- this.reference = InstantiationUtil.instantiate(type, CopyableValue.class);
- this.tempReference = null;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java
deleted file mode 100644
index 9e46f27..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueSerializer.java
+++ /dev/null
@@ -1,129 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.types.CopyableValue;
-import org.apache.flink.util.InstantiationUtil;
-
-
-public class CopyableValueSerializer<T extends CopyableValue<T>> extends TypeSerializer<T> {
-
- private static final long serialVersionUID = 1L;
-
-
- private final Class<T> valueClass;
-
- private transient T instance;
-
-
- public CopyableValueSerializer(Class<T> valueClass) {
- this.valueClass = Preconditions.checkNotNull(valueClass);
- }
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public CopyableValueSerializer<T> duplicate() {
- return this;
- }
-
- @Override
- public T createInstance() {
- return InstantiationUtil.instantiate(this.valueClass);
- }
-
- @Override
- public T copy(T from) {
- return copy(from, createInstance());
- }
-
- @Override
- public T copy(T from, T reuse) {
- from.copyTo(reuse);
- return reuse;
- }
-
- @Override
- public int getLength() {
- ensureInstanceInstantiated();
- return instance.getBinaryLength();
- }
-
- @Override
- public void serialize(T value, DataOutputView target) throws IOException {
- value.write(target);
- }
-
- @Override
- public T deserialize(DataInputView source) throws IOException {
- return deserialize(createInstance(), source);
- }
-
- @Override
- public T deserialize(T reuse, DataInputView source) throws IOException {
- reuse.read(source);
- return reuse;
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- ensureInstanceInstantiated();
- instance.copy(source, target);
- }
-
- // --------------------------------------------------------------------------------------------
-
- private void ensureInstanceInstantiated() {
- if (instance == null) {
- instance = createInstance();
- }
- }
-
- @Override
- public int hashCode() {
- return this.valueClass.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof CopyableValueSerializer) {
- @SuppressWarnings("unchecked")
- CopyableValueSerializer<T> copyableValueSerializer = (CopyableValueSerializer<T>) obj;
-
- return copyableValueSerializer.canEqual(this) &&
- valueClass == copyableValueSerializer.valueClass;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof CopyableValueSerializer;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java
deleted file mode 100644
index e48f9fa..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputDecoder.java
+++ /dev/null
@@ -1,229 +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.java.typeutils.runtime;
-
-import java.io.DataInput;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.apache.avro.io.Decoder;
-import org.apache.avro.util.Utf8;
-
-
-public class DataInputDecoder extends Decoder implements java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private transient Utf8 stringDecoder = new Utf8();
-
-
- private transient DataInput in;
-
-
- public void setIn(DataInput in) {
- this.in = in;
- }
-
- // --------------------------------------------------------------------------------------------
- // primitives
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void readNull() {}
-
-
- @Override
- public boolean readBoolean() throws IOException {
- return in.readBoolean();
- }
-
- @Override
- public int readInt() throws IOException {
- return in.readInt();
- }
-
- @Override
- public long readLong() throws IOException {
- return in.readLong();
- }
-
- @Override
- public float readFloat() throws IOException {
- return in.readFloat();
- }
-
- @Override
- public double readDouble() throws IOException {
- return in.readDouble();
- }
-
- @Override
- public int readEnum() throws IOException {
- return readInt();
- }
-
- // --------------------------------------------------------------------------------------------
- // bytes
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void readFixed(byte[] bytes, int start, int length) throws IOException {
- in.readFully(bytes, start, length);
- }
-
- @Override
- public ByteBuffer readBytes(ByteBuffer old) throws IOException {
- int length = readInt();
- ByteBuffer result;
- if (old != null && length <= old.capacity() && old.hasArray()) {
- result = old;
- result.clear();
- } else {
- result = ByteBuffer.allocate(length);
- }
- in.readFully(result.array(), result.arrayOffset() + result.position(), length);
- result.limit(length);
- return result;
- }
-
-
- @Override
- public void skipFixed(int length) throws IOException {
- skipBytes(length);
- }
-
- @Override
- public void skipBytes() throws IOException {
- int num = readInt();
- skipBytes(num);
- }
-
- // --------------------------------------------------------------------------------------------
- // strings
- // --------------------------------------------------------------------------------------------
-
-
- @Override
- public Utf8 readString(Utf8 old) throws IOException {
- int length = readInt();
- Utf8 result = (old != null ? old : new Utf8());
- result.setByteLength(length);
-
- if (length > 0) {
- in.readFully(result.getBytes(), 0, length);
- }
-
- return result;
- }
-
- @Override
- public String readString() throws IOException {
- return readString(stringDecoder).toString();
- }
-
- @Override
- public void skipString() throws IOException {
- int len = readInt();
- skipBytes(len);
- }
-
- // --------------------------------------------------------------------------------------------
- // collection types
- // --------------------------------------------------------------------------------------------
-
- @Override
- public long readArrayStart() throws IOException {
- return readVarLongCount(in);
- }
-
- @Override
- public long arrayNext() throws IOException {
- return readVarLongCount(in);
- }
-
- @Override
- public long skipArray() throws IOException {
- return readVarLongCount(in);
- }
-
- @Override
- public long readMapStart() throws IOException {
- return readVarLongCount(in);
- }
-
- @Override
- public long mapNext() throws IOException {
- return readVarLongCount(in);
- }
-
- @Override
- public long skipMap() throws IOException {
- return readVarLongCount(in);
- }
-
- // --------------------------------------------------------------------------------------------
- // union
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int readIndex() throws IOException {
- return readInt();
- }
-
- // --------------------------------------------------------------------------------------------
- // utils
- // --------------------------------------------------------------------------------------------
-
- private void skipBytes(int num) throws IOException {
- while (num > 0) {
- num -= in.skipBytes(num);
- }
- }
-
- public static long readVarLongCount(DataInput in) throws IOException {
- long value = in.readUnsignedByte();
-
- if ((value & 0x80) == 0) {
- return value;
- }
- else {
- long curr;
- int shift = 7;
- value = value & 0x7f;
- while (((curr = in.readUnsignedByte()) & 0x80) != 0){
- value |= (curr & 0x7f) << shift;
- shift += 7;
- }
- value |= curr << shift;
- return value;
- }
- }
-
- // --------------------------------------------------------------------------------------------
- // serialization
- // --------------------------------------------------------------------------------------------
-
- private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
- // Read in size, and any hidden stuff
- s.defaultReadObject();
-
- this.stringDecoder = new Utf8();
- this.in = null;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java
deleted file mode 100644
index be17d64..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataInputViewStream.java
+++ /dev/null
@@ -1,71 +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.java.typeutils.runtime;
-
-import org.apache.flink.core.memory.DataInputView;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * An input stream that draws its data from a {@link DataInputView}.
- */
-public class DataInputViewStream extends InputStream {
-
- protected DataInputView inputView;
-
- public DataInputViewStream(DataInputView inputView) {
- this.inputView = inputView;
- }
-
- public DataInputView getInputView(){
- return inputView;
- }
-
- @Override
- public int read() throws IOException {
- try {
- return inputView.readUnsignedByte();
- } catch(EOFException ex) {
- return -1;
- }
- }
-
- @Override
- public long skip(long n) throws IOException {
- long counter = n;
- while(counter > Integer.MAX_VALUE) {
- int skippedBytes = inputView.skipBytes(Integer.MAX_VALUE);
-
- if (skippedBytes == 0) {
- return n - counter;
- }
-
- counter -= skippedBytes;
- }
- return n - counter - inputView.skipBytes((int) counter);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- return inputView.read(b, off, len);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java
deleted file mode 100644
index 5c89962..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputEncoder.java
+++ /dev/null
@@ -1,190 +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.java.typeutils.runtime;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import org.apache.avro.io.Encoder;
-import org.apache.avro.util.Utf8;
-
-
-public final class DataOutputEncoder extends Encoder implements java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private transient DataOutput out;
-
-
- public void setOut(DataOutput out) {
- this.out = out;
- }
-
-
- @Override
- public void flush() throws IOException {}
-
- // --------------------------------------------------------------------------------------------
- // primitives
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void writeNull() {}
-
-
- @Override
- public void writeBoolean(boolean b) throws IOException {
- out.writeBoolean(b);
- }
-
- @Override
- public void writeInt(int n) throws IOException {
- out.writeInt(n);
- }
-
- @Override
- public void writeLong(long n) throws IOException {
- out.writeLong(n);
- }
-
- @Override
- public void writeFloat(float f) throws IOException {
- out.writeFloat(f);
- }
-
- @Override
- public void writeDouble(double d) throws IOException {
- out.writeDouble(d);
- }
-
- @Override
- public void writeEnum(int e) throws IOException {
- out.writeInt(e);
- }
-
-
- // --------------------------------------------------------------------------------------------
- // bytes
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void writeFixed(byte[] bytes, int start, int len) throws IOException {
- out.write(bytes, start, len);
- }
-
- @Override
- public void writeBytes(byte[] bytes, int start, int len) throws IOException {
- out.writeInt(len);
- if (len > 0) {
- out.write(bytes, start, len);
- }
- }
-
- @Override
- public void writeBytes(ByteBuffer bytes) throws IOException {
- int num = bytes.remaining();
- out.writeInt(num);
-
- if (num > 0) {
- writeFixed(bytes);
- }
- }
-
- // --------------------------------------------------------------------------------------------
- // strings
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void writeString(String str) throws IOException {
- byte[] bytes = Utf8.getBytesFor(str);
- writeBytes(bytes, 0, bytes.length);
- }
-
- @Override
- public void writeString(Utf8 utf8) throws IOException {
- writeBytes(utf8.getBytes(), 0, utf8.getByteLength());
-
- }
-
- // --------------------------------------------------------------------------------------------
- // collection types
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void writeArrayStart() {}
-
- @Override
- public void setItemCount(long itemCount) throws IOException {
- if (itemCount > 0) {
- writeVarLongCount(out, itemCount);
- }
- }
-
- @Override
- public void startItem() {}
-
- @Override
- public void writeArrayEnd() throws IOException {
- // write a single byte 0, shortcut for a var-length long of 0
- out.write(0);
- }
-
- @Override
- public void writeMapStart() {}
-
- @Override
- public void writeMapEnd() throws IOException {
- // write a single byte 0, shortcut for a var-length long of 0
- out.write(0);
- }
-
- // --------------------------------------------------------------------------------------------
- // union
- // --------------------------------------------------------------------------------------------
-
- @Override
- public void writeIndex(int unionIndex) throws IOException {
- out.writeInt(unionIndex);
- }
-
- // --------------------------------------------------------------------------------------------
- // utils
- // --------------------------------------------------------------------------------------------
-
-
- public static final void writeVarLongCount(DataOutput out, long val) throws IOException {
- if (val < 0) {
- throw new IOException("Illegal count (must be non-negative): " + val);
- }
-
- while ((val & ~0x7FL) != 0) {
- out.write(((int) val) | 0x80);
- val >>>= 7;
- }
- out.write((int) val);
- }
-
- private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
- // Read in size, and any hidden stuff
- s.defaultReadObject();
-
- this.out = null;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java
deleted file mode 100644
index 66f2af6..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/DataOutputViewStream.java
+++ /dev/null
@@ -1,41 +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.java.typeutils.runtime;
-
-import org.apache.flink.core.memory.DataOutputView;
-import java.io.IOException;
-import java.io.OutputStream;
-
-public class DataOutputViewStream extends OutputStream {
- protected DataOutputView outputView;
-
- public DataOutputViewStream(DataOutputView outputView){
- this.outputView = outputView;
- }
-
- @Override
- public void write(int b) throws IOException {
- outputView.writeByte(b);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- outputView.write(b, off, len);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java
deleted file mode 100644
index b4b95f3..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializer.java
+++ /dev/null
@@ -1,193 +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.java.typeutils.runtime;
-
-import static org.apache.flink.api.java.typeutils.Either.Left;
-import static org.apache.flink.api.java.typeutils.Either.Right;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.Either;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-
-/**
- * A {@link TypeSerializer} for the {@ link Either} type of the Java class.
- *
- * @param <L> the Left value type
- * @param <R> the Right value type
- */
-public class EitherSerializer<L, R> extends TypeSerializer<Either<L, R>> {
-
- private static final long serialVersionUID = 1L;
-
- private final TypeSerializer<L> leftSerializer;
-
- private final TypeSerializer<R> rightSerializer;
-
- public EitherSerializer(TypeSerializer<L> leftSerializer, TypeSerializer<R> rightSerializer) {
- this.leftSerializer = leftSerializer;
- this.rightSerializer = rightSerializer;
- }
-
- @Override
- public boolean isImmutableType() {
- return leftSerializer.isImmutableType() && rightSerializer.isImmutableType();
- }
-
- @Override
- public TypeSerializer<Either<L, R>> duplicate() {
- TypeSerializer<L> duplicateLeft = leftSerializer.duplicate();
- TypeSerializer<R> duplicateRight = rightSerializer.duplicate();
-
- if ((leftSerializer != duplicateLeft) || (rightSerializer != duplicateRight)) {
- // stateful
- return new EitherSerializer<L, R>(duplicateLeft, duplicateRight);
- }
- else {
- return this;
- }
- }
-
-
- @Override
- public Either<L, R> createInstance() {
- // We arbitrarily always create a Right value instance.
- return Right(rightSerializer.createInstance());
- }
-
- @Override
- public Either<L, R> copy(Either<L, R> from) {
- if (from.isLeft()) {
- L left = from.left();
- L copyLeft = leftSerializer.copy(left);
- return Left(copyLeft);
- }
- else {
- R right = from.right();
- R copyRight = rightSerializer.copy(right);
- return Right(copyRight);
- }
- }
-
- @Override
- public Either<L, R> copy(Either<L, R> from, Either<L, R> reuse) {
- if (from.isRight()) {
- final R right = from.right();
- if (reuse.isRight()) {
- R copyRight = rightSerializer.copy(right, reuse.right());
- return Right(copyRight);
- }
- else {
- // if the reuse record isn't a right value, we cannot reuse
- R copyRight = rightSerializer.copy(right);
- return Right(copyRight);
- }
- }
- else {
- L left = from.left();
- // reuse record is never a left value because we always create a right instance
- L copyLeft = leftSerializer.copy(left);
- return Left(copyLeft);
- }
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
- @Override
- public void serialize(Either<L, R> record, DataOutputView target) throws IOException {
- if (record.isLeft()) {
- target.writeBoolean(true);
- leftSerializer.serialize(record.left(), target);
- }
- else {
- target.writeBoolean(false);
- rightSerializer.serialize(record.right(), target);
- }
- }
-
- @Override
- public Either<L, R> deserialize(DataInputView source) throws IOException {
- boolean isLeft = source.readBoolean();
- if (isLeft) {
- return Left(leftSerializer.deserialize(source));
- }
- else {
- return Right(rightSerializer.deserialize(source));
- }
- }
-
- @Override
- public Either<L, R> deserialize(Either<L, R> reuse, DataInputView source) throws IOException {
- boolean isLeft = source.readBoolean();
- if (!isLeft) {
- if (reuse.isRight()) {
- return Right(rightSerializer.deserialize(reuse.right(), source));
- }
- else {
- // if the reuse record isn't a right value, we cannot reuse
- return Right(rightSerializer.deserialize(source));
- }
- }
- else {
- // reuse record is never a left value because we always create a right instance
- return Left(leftSerializer.deserialize(source));
- }
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- boolean isLeft = source.readBoolean();
- target.writeBoolean(isLeft);
- if (isLeft) {
- leftSerializer.copy(source, target);
- }
- else {
- rightSerializer.copy(source, target);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EitherSerializer) {
- EitherSerializer<L, R> other = (EitherSerializer<L, R>) obj;
-
- return other.canEqual(this) &&
- leftSerializer.equals(other.leftSerializer) &&
- rightSerializer.equals(other.rightSerializer);
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof EitherSerializer;
- }
-
- @Override
- public int hashCode() {
- return 17 * leftSerializer.hashCode() + rightSerializer.hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java
deleted file mode 100644
index 28fea6a..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/GenericTypeComparator.java
+++ /dev/null
@@ -1,177 +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.java.typeutils.runtime;
-
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.types.NormalizableKey;
-import org.apache.flink.util.InstantiationUtil;
-
-/**
- * TypeComparator for all types that extend Comparable.
- */
-public class GenericTypeComparator<T extends Comparable<T>> extends TypeComparator<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final boolean ascending;
-
- private final Class<T> type;
-
- private TypeSerializer<T> serializer;
-
- private transient T reference;
-
- private transient T tmpReference;
-
- @SuppressWarnings("rawtypes")
- private final TypeComparator[] comparators = new TypeComparator[] {this};
-
- // ------------------------------------------------------------------------
-
- public GenericTypeComparator(boolean ascending, TypeSerializer<T> serializer, Class<T> type) {
- this.ascending = ascending;
- this.serializer = serializer;
- this.type = type;
- }
-
- private GenericTypeComparator(GenericTypeComparator<T> toClone) {
- this.ascending = toClone.ascending;
- this.serializer = toClone.serializer.duplicate();
- this.type = toClone.type;
- }
-
- @Override
- public int hash(T record) {
- return record.hashCode();
- }
-
- @Override
- public void setReference(T toCompare) {
- this.reference = this.serializer.copy(toCompare);
- }
-
- @Override
- public boolean equalToReference(T candidate) {
- return candidate.equals(this.reference);
- }
-
- @Override
- public int compareToReference(TypeComparator<T> referencedComparator) {
- T otherRef = ((GenericTypeComparator<T>) referencedComparator).reference;
- int cmp = otherRef.compareTo(this.reference);
-
- return this.ascending ? cmp : -cmp;
- }
-
- @Override
- public int compare(T first, T second) {
- int cmp = first.compareTo(second);
- return this.ascending ? cmp : -cmp;
- }
-
- @Override
- public int compareSerialized(final DataInputView firstSource, final DataInputView secondSource) throws IOException {
-
- if (this.reference == null) {
- this.reference = this.serializer.createInstance();
- }
-
- if (this.tmpReference == null) {
- this.tmpReference = this.serializer.createInstance();
- }
-
- this.reference = this.serializer.deserialize(this.reference, firstSource);
- this.tmpReference = this.serializer.deserialize(this.tmpReference, secondSource);
-
- int cmp = this.reference.compareTo(this.tmpReference);
- return this.ascending ? cmp : -cmp;
- }
-
- @Override
- public boolean supportsNormalizedKey() {
- return NormalizableKey.class.isAssignableFrom(this.type);
- }
-
- @Override
- public int getNormalizeKeyLen() {
- if (this.reference == null) {
- this.reference = InstantiationUtil.instantiate(this.type);
- }
-
- NormalizableKey<?> key = (NormalizableKey<?>) this.reference;
- return key.getMaxNormalizedKeyLen();
- }
-
- @Override
- public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
- return keyBytes < getNormalizeKeyLen();
- }
-
- @Override
- public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
- NormalizableKey<?> key = (NormalizableKey<?>) record;
- key.copyNormalizedKey(target, offset, numBytes);
- }
-
- @Override
- public boolean invertNormalizedKey() {
- return !ascending;
- }
-
- @Override
- public TypeComparator<T> duplicate() {
- return new GenericTypeComparator<T>(this);
- }
-
- @Override
- public int extractKeys(Object record, Object[] target, int index) {
- target[index] = record;
- return 1;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public TypeComparator[] getFlatComparators() {
- return comparators;
- }
-
- // ------------------------------------------------------------------------
-
- @Override
- public boolean supportsSerializationWithKeyNormalization() {
- return false;
- }
-
- @Override
- public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
- throw new UnsupportedOperationException();
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
deleted file mode 100644
index faf5646..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
+++ /dev/null
@@ -1,87 +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.java.typeutils.runtime;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.KryoException;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.util.InstantiationUtil;
-
-import java.io.IOException;
-
-/**
- * Convenience methods for Kryo
- */
-public class KryoUtils {
-
- /**
- * Tries to copy the given record from using the provided Kryo instance. If this fails, then
- * the record from is copied by serializing it into a byte buffer and deserializing it from
- * there.
- *
- * @param from Element to copy
- * @param kryo Kryo instance to use
- * @param serializer TypeSerializer which is used in case of a Kryo failure
- * @param <T> Type of the element to be copied
- * @return Copied element
- */
- public static <T> T copy(T from, Kryo kryo, TypeSerializer<T> serializer) {
- try {
- return kryo.copy(from);
- } catch (KryoException ke) {
- // Kryo could not copy the object --> try to serialize/deserialize the object
- try {
- byte[] byteArray = InstantiationUtil.serializeToByteArray(serializer, from);
-
- return InstantiationUtil.deserializeFromByteArray(serializer, byteArray);
- } catch (IOException ioe) {
- throw new RuntimeException("Could not copy object by serializing/deserializing" +
- " it.", ioe);
- }
- }
- }
-
- /**
- * Tries to copy the given record from using the provided Kryo instance. If this fails, then
- * the record from is copied by serializing it into a byte buffer and deserializing it from
- * there.
- *
- * @param from Element to copy
- * @param reuse Reuse element for the deserialization
- * @param kryo Kryo instance to use
- * @param serializer TypeSerializer which is used in case of a Kryo failure
- * @param <T> Type of the element to be copied
- * @return Copied element
- */
- public static <T> T copy(T from, T reuse, Kryo kryo, TypeSerializer<T> serializer) {
- try {
- return kryo.copy(from);
- } catch (KryoException ke) {
- // Kryo could not copy the object --> try to serialize/deserialize the object
- try {
- byte[] byteArray = InstantiationUtil.serializeToByteArray(serializer, from);
-
- return InstantiationUtil.deserializeFromByteArray(serializer, reuse, byteArray);
- } catch (IOException ioe) {
- throw new RuntimeException("Could not copy object by serializing/deserializing" +
- " it.", ioe);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java
deleted file mode 100644
index 0f4fe94..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java
+++ /dev/null
@@ -1,141 +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.java.typeutils.runtime;
-
-import com.esotericsoftware.kryo.KryoException;
-import com.esotericsoftware.kryo.io.Input;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class NoFetchingInput extends Input {
- public NoFetchingInput(InputStream inputStream){
- super(inputStream, 8);
- }
-
- @Override
- public boolean eof(){
- throw new UnsupportedOperationException("NoFetchingInput does not support EOF.");
- }
-
- @Override
- public int read() throws KryoException {
- require(1);
- return buffer[position++] & 0xFF;
- }
-
- @Override
- public boolean canReadInt() throws KryoException {
- throw new UnsupportedOperationException("NoFetchingInput cannot prefetch data.");
- }
-
- @Override
- public boolean canReadLong() throws KryoException {
- throw new UnsupportedOperationException("NoFetchingInput cannot prefetch data.");
- }
-
- /**
- * Require makes sure that at least required number of bytes are kept in the buffer. If not, then
- * it will load exactly the difference between required and currently available number of bytes.
- * Thus, it will only load the data which is required and never prefetch data.
- *
- * @param required the number of bytes being available in the buffer
- * @return the number of bytes remaining, which is equal to required
- * @throws KryoException
- */
- @Override
- protected int require(int required) throws KryoException {
- if(required > capacity) {
- throw new KryoException("Buffer too small: capacity: " + capacity + ", " +
- "required: " + required);
- }
-
- position = 0;
- int bytesRead = 0;
- int count;
- while(true){
- count = fill(buffer, bytesRead, required - bytesRead);
-
- if(count == -1){
- throw new KryoException(new EOFException("No more bytes left."));
- }
-
- bytesRead += count;
- if(bytesRead == required){
- break;
- }
- }
- limit = required;
- return required;
- }
-
- @Override
- public int read(byte[] bytes, int offset, int count) throws KryoException {
- if(bytes == null){
- throw new IllegalArgumentException("bytes cannot be null.");
- }
-
- try {
- return inputStream.read(bytes, offset, count);
- }catch(IOException ex){
- throw new KryoException(ex);
- }
- }
-
- @Override
- public void skip(int count) throws KryoException {
- try{
- inputStream.skip(count);
- }catch(IOException ex){
- throw new KryoException(ex);
- }
- }
-
- @Override
- public void readBytes(byte[] bytes, int offset, int count) throws KryoException {
- if(bytes == null){
- throw new IllegalArgumentException("bytes cannot be null.");
- }
-
- try{
- int bytesRead = 0;
- int c;
-
- while(true){
- c = inputStream.read(bytes, offset+bytesRead, count-bytesRead);
-
- if(c == -1){
- throw new KryoException(new EOFException("No more bytes left."));
- }
-
- bytesRead += c;
-
- if(bytesRead == count){
- break;
- }
- }
- }catch(IOException ex){
- throw new KryoException(ex);
- }
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java
deleted file mode 100644
index c0c7797..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java
+++ /dev/null
@@ -1,354 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-import java.util.List;
-
-import org.apache.flink.api.common.typeutils.CompositeTypeComparator;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.types.NullKeyFieldException;
-import org.apache.flink.util.InstantiationUtil;
-
-
-public final class PojoComparator<T> extends CompositeTypeComparator<T> implements java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- // Reflection fields for the comp fields
- private transient Field[] keyFields;
-
- private final TypeComparator<Object>[] comparators;
-
- private final int[] normalizedKeyLengths;
-
- private final int numLeadingNormalizableKeys;
-
- private final int normalizableKeyPrefixLen;
-
- private final boolean invertNormKey;
-
- private TypeSerializer<T> serializer;
-
- private final Class<T> type;
-
- @SuppressWarnings("unchecked")
- public PojoComparator(Field[] keyFields, TypeComparator<?>[] comparators, TypeSerializer<T> serializer, Class<T> type) {
- this.keyFields = keyFields;
- this.comparators = (TypeComparator<Object>[]) comparators;
-
- this.type = type;
- this.serializer = serializer;
-
- // set up auxiliary fields for normalized key support
- this.normalizedKeyLengths = new int[keyFields.length];
- int nKeys = 0;
- int nKeyLen = 0;
- boolean inverted = false;
-
- for (int i = 0; i < this.comparators.length; i++) {
- TypeComparator<?> k = this.comparators[i];
- if(k == null) {
- throw new IllegalArgumentException("One of the passed comparators is null");
- }
- if(keyFields[i] == null) {
- throw new IllegalArgumentException("One of the passed reflection fields is null");
- }
-
- // as long as the leading keys support normalized keys, we can build up the composite key
- if (k.supportsNormalizedKey()) {
- if (i == 0) {
- // the first comparator decides whether we need to invert the key direction
- inverted = k.invertNormalizedKey();
- }
- else if (k.invertNormalizedKey() != inverted) {
- // if a successor does not agree on the invertion direction, it cannot be part of the normalized key
- break;
- }
-
- nKeys++;
- final int len = k.getNormalizeKeyLen();
- if (len < 0) {
- throw new RuntimeException("Comparator " + k.getClass().getName() + " specifies an invalid length for the normalized key: " + len);
- }
- this.normalizedKeyLengths[i] = len;
- nKeyLen += this.normalizedKeyLengths[i];
-
- if (nKeyLen < 0) {
- // overflow, which means we are out of budget for normalized key space anyways
- nKeyLen = Integer.MAX_VALUE;
- break;
- }
- } else {
- break;
- }
- }
- this.numLeadingNormalizableKeys = nKeys;
- this.normalizableKeyPrefixLen = nKeyLen;
- this.invertNormKey = inverted;
- }
-
- @SuppressWarnings("unchecked")
- private PojoComparator(PojoComparator<T> toClone) {
- this.keyFields = toClone.keyFields;
- this.comparators = new TypeComparator[toClone.comparators.length];
-
- for (int i = 0; i < toClone.comparators.length; i++) {
- this.comparators[i] = toClone.comparators[i].duplicate();
- }
-
- this.normalizedKeyLengths = toClone.normalizedKeyLengths;
- this.numLeadingNormalizableKeys = toClone.numLeadingNormalizableKeys;
- this.normalizableKeyPrefixLen = toClone.normalizableKeyPrefixLen;
- this.invertNormKey = toClone.invertNormKey;
-
- this.type = toClone.type;
-
- try {
- this.serializer = (TypeSerializer<T>) InstantiationUtil.deserializeObject(
- InstantiationUtil.serializeObject(toClone.serializer), Thread.currentThread().getContextClassLoader());
- } catch (IOException e) {
- throw new RuntimeException("Cannot copy serializer", e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Cannot copy serializer", e);
- }
- }
-
- private void writeObject(ObjectOutputStream out)
- throws IOException, ClassNotFoundException {
- out.defaultWriteObject();
- out.writeInt(keyFields.length);
- for (Field field: keyFields) {
- out.writeObject(field.getDeclaringClass());
- out.writeUTF(field.getName());
- }
- }
-
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- int numKeyFields = in.readInt();
- keyFields = new Field[numKeyFields];
- for (int i = 0; i < numKeyFields; i++) {
- Class<?> clazz = (Class<?>) in.readObject();
- String fieldName = in.readUTF();
- // try superclasses as well
- while (clazz != null) {
- try {
- Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- keyFields[i] = field;
- break;
- } catch (NoSuchFieldException e) {
- clazz = clazz.getSuperclass();
- }
- }
- if (keyFields[i] == null ) {
- throw new RuntimeException("Class resolved at TaskManager is not compatible with class read during Plan setup."
- + " (" + fieldName + ")");
- }
- }
- }
-
- public Field[] getKeyFields() {
- return this.keyFields;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void getFlatComparator(List<TypeComparator> flatComparators) {
- for(int i = 0; i < comparators.length; i++) {
- if(comparators[i] instanceof CompositeTypeComparator) {
- ((CompositeTypeComparator)comparators[i]).getFlatComparator(flatComparators);
- } else {
- flatComparators.add(comparators[i]);
- }
- }
- }
-
- /**
- * This method is handling the IllegalAccess exceptions of Field.get()
- */
- public final Object accessField(Field field, Object object) {
- try {
- object = field.get(object);
- } catch (NullPointerException npex) {
- throw new NullKeyFieldException("Unable to access field "+field+" on object "+object);
- } catch (IllegalAccessException iaex) {
- throw new RuntimeException("This should not happen since we call setAccesssible(true) in PojoTypeInfo."
- + " fields: " + field + " obj: " + object);
- }
- return object;
- }
-
- @Override
- public int hash(T value) {
- int i = 0;
- int code = 0;
- for (; i < this.keyFields.length; i++) {
- code *= TupleComparatorBase.HASH_SALT[i & 0x1F];
- try {
- code += this.comparators[i].hash(accessField(keyFields[i], value));
- }catch(NullPointerException npe) {
- throw new RuntimeException("A NullPointerException occured while accessing a key field in a POJO. " +
- "Most likely, the value grouped/joined on is null. Field name: "+keyFields[i].getName(), npe);
- }
- }
- return code;
-
- }
-
- @Override
- public void setReference(T toCompare) {
- int i = 0;
- for (; i < this.keyFields.length; i++) {
- this.comparators[i].setReference(accessField(keyFields[i], toCompare));
- }
- }
-
- @Override
- public boolean equalToReference(T candidate) {
- int i = 0;
- for (; i < this.keyFields.length; i++) {
- if (!this.comparators[i].equalToReference(accessField(keyFields[i], candidate))) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int compareToReference(TypeComparator<T> referencedComparator) {
- PojoComparator<T> other = (PojoComparator<T>) referencedComparator;
-
- int i = 0;
- try {
- for (; i < this.keyFields.length; i++) {
- int cmp = this.comparators[i].compareToReference(other.comparators[i]);
- if (cmp != 0) {
- return cmp;
- }
- }
- return 0;
- }
- catch (NullPointerException npex) {
- throw new NullKeyFieldException(this.keyFields[i].toString());
- }
- }
-
- @Override
- public int compare(T first, T second) {
- int i = 0;
- for (; i < keyFields.length; i++) {
- int cmp = comparators[i].compare(accessField(keyFields[i], first), accessField(keyFields[i], second));
- if (cmp != 0) {
- return cmp;
- }
- }
-
- return 0;
- }
-
-
- @Override
- public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
- T first = this.serializer.createInstance();
- T second = this.serializer.createInstance();
-
- first = this.serializer.deserialize(first, firstSource);
- second = this.serializer.deserialize(second, secondSource);
-
- return this.compare(first, second);
- }
-
- @Override
- public boolean supportsNormalizedKey() {
- return this.numLeadingNormalizableKeys > 0;
- }
-
- @Override
- public int getNormalizeKeyLen() {
- return this.normalizableKeyPrefixLen;
- }
-
- @Override
- public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
- return this.numLeadingNormalizableKeys < this.keyFields.length ||
- this.normalizableKeyPrefixLen == Integer.MAX_VALUE ||
- this.normalizableKeyPrefixLen > keyBytes;
- }
-
- @Override
- public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
- int i = 0;
- for (; i < this.numLeadingNormalizableKeys & numBytes > 0; i++)
- {
- int len = this.normalizedKeyLengths[i];
- len = numBytes >= len ? len : numBytes;
- this.comparators[i].putNormalizedKey(accessField(keyFields[i], value), target, offset, len);
- numBytes -= len;
- offset += len;
- }
- }
-
- @Override
- public boolean invertNormalizedKey() {
- return this.invertNormKey;
- }
-
-
- @Override
- public boolean supportsSerializationWithKeyNormalization() {
- return false;
- }
-
- @Override
- public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public PojoComparator<T> duplicate() {
- return new PojoComparator<T>(this);
- }
-
- @Override
- public int extractKeys(Object record, Object[] target, int index) {
- int localIndex = index;
- for (int i = 0; i < comparators.length; i++) {
- localIndex += comparators[i].extractKeys(accessField(keyFields[i], record), target, localIndex);
- }
- return localIndex - index;
- }
-
- // --------------------------------------------------------------------------------------------
-}
-
[37/38] flink git commit: [hotfix] Fix warnings concerning joda-time
in "flink-tests"
Posted by se...@apache.org.
[hotfix] Fix warnings concerning joda-time in "flink-tests"
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/c356ef33
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/c356ef33
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/c356ef33
Branch: refs/heads/master
Commit: c356ef33bc0fdd77296061679699487ab16e8132
Parents: b90542e
Author: Stephan Ewen <se...@apache.org>
Authored: Tue Feb 2 12:10:01 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 17:11:50 2016 +0100
----------------------------------------------------------------------
flink-core/pom.xml | 2 --
flink-tests/pom.xml | 6 ++++++
2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/c356ef33/flink-core/pom.xml
----------------------------------------------------------------------
diff --git a/flink-core/pom.xml b/flink-core/pom.xml
index ba1050c..694f629 100644
--- a/flink-core/pom.xml
+++ b/flink-core/pom.xml
@@ -94,14 +94,12 @@ under the License.
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
- <version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
- <version>1.7</version>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/flink/blob/c356ef33/flink-tests/pom.xml
----------------------------------------------------------------------
diff --git a/flink-tests/pom.xml b/flink-tests/pom.xml
index fe34aea..996f5e0 100644
--- a/flink-tests/pom.xml
+++ b/flink-tests/pom.xml
@@ -164,6 +164,12 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.joda</groupId>
+ <artifactId>joda-convert</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
[27/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java
deleted file mode 100644
index ea24f40..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java
+++ /dev/null
@@ -1,289 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 10 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- */
-public class Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple10() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- */
- public Tuple10(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- }
-
- @Override
- public int getArity() { return 10; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple10)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple10 tuple = (Tuple10) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> copy(){
- return new Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
- return new Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java
deleted file mode 100644
index b58ae6c..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java
+++ /dev/null
@@ -1,304 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 11 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- */
-public class Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple11() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- */
- public Tuple11(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- }
-
- @Override
- public int getArity() { return 11; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple11)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple11 tuple = (Tuple11) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> copy(){
- return new Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
- return new Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java
deleted file mode 100644
index 4e7defb..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java
+++ /dev/null
@@ -1,319 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 12 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- */
-public class Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple12() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- */
- public Tuple12(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- }
-
- @Override
- public int getArity() { return 12; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple12)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple12 tuple = (Tuple12) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> copy(){
- return new Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
- return new Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java
deleted file mode 100644
index 9543912..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java
+++ /dev/null
@@ -1,334 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 13 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- */
-public class Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple13() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- */
- public Tuple13(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- }
-
- @Override
- public int getArity() { return 13; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple13)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple13 tuple = (Tuple13) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> copy(){
- return new Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
- return new Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java
deleted file mode 100644
index 36d508e..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java
+++ /dev/null
@@ -1,349 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 14 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- */
-public class Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple14() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- */
- public Tuple14(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- }
-
- @Override
- public int getArity() { return 14; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple14)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple14 tuple = (Tuple14) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> copy(){
- return new Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
- return new Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java
deleted file mode 100644
index 0d45352..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple15.java
+++ /dev/null
@@ -1,364 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 15 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- */
-public class Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple15() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- */
- public Tuple15(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- }
-
- @Override
- public int getArity() { return 15; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple15)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple15 tuple = (Tuple15) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> copy(){
- return new Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14) {
- return new Tuple15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java
deleted file mode 100644
index 5c57ee7..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple16.java
+++ /dev/null
@@ -1,379 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 16 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- */
-public class Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple16() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- */
- public Tuple16(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- }
-
- @Override
- public int getArity() { return 16; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple16)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple16 tuple = (Tuple16) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> copy(){
- return new Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15) {
- return new Tuple16<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15);
- }
-}
[18/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java
new file mode 100644
index 0000000..258d92c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java
@@ -0,0 +1,153 @@
+/*
+ * 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.java.typeutils.runtime;
+
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.util.InstantiationUtil;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.Writable;
+
+import com.esotericsoftware.kryo.Kryo;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+import java.io.IOException;
+
+public class WritableSerializer<T extends Writable> extends TypeSerializer<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> typeClass;
+
+ private transient Kryo kryo;
+
+ private transient T copyInstance;
+
+ public WritableSerializer(Class<T> typeClass) {
+ this.typeClass = typeClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T createInstance() {
+ if(typeClass == NullWritable.class) {
+ return (T) NullWritable.get();
+ }
+ return InstantiationUtil.instantiate(typeClass);
+ }
+
+
+
+ @Override
+ public T copy(T from) {
+ checkKryoInitialized();
+
+ return KryoUtils.copy(from, kryo, this);
+ }
+
+ @Override
+ public T copy(T from, T reuse) {
+ checkKryoInitialized();
+
+ return KryoUtils.copy(from, reuse, kryo, this);
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+ @Override
+ public void serialize(T record, DataOutputView target) throws IOException {
+ record.write(target);
+ }
+
+ @Override
+ public T deserialize(DataInputView source) throws IOException {
+ return deserialize(createInstance(), source);
+ }
+
+ @Override
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+ reuse.readFields(source);
+ return reuse;
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ ensureInstanceInstantiated();
+ copyInstance.readFields(source);
+ copyInstance.write(target);
+ }
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public WritableSerializer<T> duplicate() {
+ return new WritableSerializer<T>(typeClass);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ private void ensureInstanceInstantiated() {
+ if (copyInstance == null) {
+ copyInstance = createInstance();
+ }
+ }
+
+ private void checkKryoInitialized() {
+ if (this.kryo == null) {
+ this.kryo = new Kryo();
+
+ Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
+ instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+ kryo.setInstantiatorStrategy(instantiatorStrategy);
+
+ this.kryo.setAsmEnabled(true);
+ this.kryo.register(typeClass);
+ }
+ }
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return this.typeClass.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof WritableSerializer) {
+ WritableSerializer<?> other = (WritableSerializer<?>) obj;
+
+ return other.canEqual(this) && typeClass == other.typeClass;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof WritableSerializer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
new file mode 100644
index 0000000..276ffc4
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
@@ -0,0 +1,382 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.KryoException;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.factories.ReflectionSerializerFactory;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+import com.esotericsoftware.kryo.serializers.JavaSerializer;
+import com.google.common.base.Preconditions;
+
+import org.apache.avro.generic.GenericData;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.DataInputViewStream;
+import org.apache.flink.api.java.typeutils.runtime.DataOutputViewStream;
+import org.apache.flink.api.java.typeutils.runtime.NoFetchingInput;
+import org.apache.flink.api.java.typeutils.runtime.kryo.Serializers.SpecificInstanceCollectionSerializerForArrayList;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * A type serializer that serializes its type using the Kryo serialization
+ * framework (https://github.com/EsotericSoftware/kryo).
+ *
+ * This serializer is intended as a fallback serializer for the cases that are
+ * not covered by the basic types, tuples, and POJOs.
+ *
+ * @param <T> The type to be serialized.
+ */
+public class KryoSerializer<T> extends TypeSerializer<T> {
+
+ private static final long serialVersionUID = 3L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(KryoSerializer.class);
+
+ // ------------------------------------------------------------------------
+
+ private final LinkedHashMap<Class<?>, ExecutionConfig.SerializableSerializer<?>> registeredTypesWithSerializers;
+ private final LinkedHashMap<Class<?>, Class<? extends Serializer<?>>> registeredTypesWithSerializerClasses;
+ private final LinkedHashMap<Class<?>, ExecutionConfig.SerializableSerializer<?>> defaultSerializers;
+ private final LinkedHashMap<Class<?>, Class<? extends Serializer<?>>> defaultSerializerClasses;
+ private final LinkedHashSet<Class<?>> registeredTypes;
+
+ private final Class<T> type;
+
+ // ------------------------------------------------------------------------
+ // The fields below are lazily initialized after duplication or deserialization.
+
+ private transient Kryo kryo;
+ private transient T copyInstance;
+
+ private transient DataOutputView previousOut;
+ private transient DataInputView previousIn;
+
+ private transient Input input;
+ private transient Output output;
+
+ // ------------------------------------------------------------------------
+
+ public KryoSerializer(Class<T> type, ExecutionConfig executionConfig){
+ this.type = Preconditions.checkNotNull(type);
+
+ this.defaultSerializers = executionConfig.getDefaultKryoSerializers();
+ this.defaultSerializerClasses = executionConfig.getDefaultKryoSerializerClasses();
+ this.registeredTypesWithSerializers = executionConfig.getRegisteredTypesWithKryoSerializers();
+ this.registeredTypesWithSerializerClasses = executionConfig.getRegisteredTypesWithKryoSerializerClasses();
+ this.registeredTypes = executionConfig.getRegisteredKryoTypes();
+ }
+
+ /**
+ * Copy-constructor that does not copy transient fields. They will be initialized once required.
+ */
+ protected KryoSerializer(KryoSerializer<T> toCopy) {
+ registeredTypesWithSerializers = toCopy.registeredTypesWithSerializers;
+ registeredTypesWithSerializerClasses = toCopy.registeredTypesWithSerializerClasses;
+ defaultSerializers = toCopy.defaultSerializers;
+ defaultSerializerClasses = toCopy.defaultSerializerClasses;
+ registeredTypes = toCopy.registeredTypes;
+
+ type = toCopy.type;
+ if(type == null){
+ throw new NullPointerException("Type class cannot be null.");
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public KryoSerializer<T> duplicate() {
+ return new KryoSerializer<T>(this);
+ }
+
+ @Override
+ public T createInstance() {
+ if(Modifier.isAbstract(type.getModifiers()) || Modifier.isInterface(type.getModifiers()) ) {
+ return null;
+ } else {
+ checkKryoInitialized();
+ try {
+ return kryo.newInstance(type);
+ } catch(Throwable e) {
+ return null;
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T copy(T from) {
+ if (from == null) {
+ return null;
+ }
+ checkKryoInitialized();
+ try {
+ return kryo.copy(from);
+ }
+ catch(KryoException ke) {
+ // kryo was unable to copy it, so we do it through serialization:
+ ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ Output output = new Output(baout);
+
+ kryo.writeObject(output, from);
+
+ output.close();
+
+ ByteArrayInputStream bain = new ByteArrayInputStream(baout.toByteArray());
+ Input input = new Input(bain);
+
+ return (T)kryo.readObject(input, from.getClass());
+ }
+ }
+
+ @Override
+ public T copy(T from, T reuse) {
+ return copy(from);
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+ @Override
+ public void serialize(T record, DataOutputView target) throws IOException {
+ checkKryoInitialized();
+ if (target != previousOut) {
+ DataOutputViewStream outputStream = new DataOutputViewStream(target);
+ output = new Output(outputStream);
+ previousOut = target;
+ }
+
+ // Sanity check: Make sure that the output is cleared/has been flushed by the last call
+ // otherwise data might be written multiple times in case of a previous EOFException
+ if (output.position() != 0) {
+ throw new IllegalStateException("The Kryo Output still contains data from a previous " +
+ "serialize call. It has to be flushed or cleared at the end of the serialize call.");
+ }
+
+ try {
+ kryo.writeClassAndObject(output, record);
+ output.flush();
+ }
+ catch (KryoException ke) {
+ // make sure that the Kryo output buffer is cleared in case that we can recover from
+ // the exception (e.g. EOFException which denotes buffer full)
+ output.clear();
+
+ Throwable cause = ke.getCause();
+ if (cause instanceof EOFException) {
+ throw (EOFException) cause;
+ }
+ else {
+ throw ke;
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T deserialize(DataInputView source) throws IOException {
+ checkKryoInitialized();
+ if (source != previousIn) {
+ DataInputViewStream inputStream = new DataInputViewStream(source);
+ input = new NoFetchingInput(inputStream);
+ previousIn = source;
+ }
+
+ try {
+ return (T) kryo.readClassAndObject(input);
+ } catch (KryoException ke) {
+ Throwable cause = ke.getCause();
+
+ if (cause instanceof EOFException) {
+ throw (EOFException) cause;
+ } else {
+ throw ke;
+ }
+ }
+ }
+
+ @Override
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+ return deserialize(source);
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ checkKryoInitialized();
+ if(this.copyInstance == null){
+ this.copyInstance = createInstance();
+ }
+
+ T tmp = deserialize(copyInstance, source);
+ serialize(tmp, target);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ type,
+ registeredTypes,
+ registeredTypesWithSerializerClasses,
+ defaultSerializerClasses);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof KryoSerializer) {
+ KryoSerializer<?> other = (KryoSerializer<?>) obj;
+
+ // we cannot include the Serializers here because they don't implement the equals method
+ return other.canEqual(this) &&
+ type == other.type &&
+ registeredTypes.equals(other.registeredTypes) &&
+ registeredTypesWithSerializerClasses.equals(other.registeredTypesWithSerializerClasses) &&
+ defaultSerializerClasses.equals(other.defaultSerializerClasses);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof KryoSerializer;
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the Chill Kryo Serializer which is implictly added to the classpath via flink-runtime.
+ * Falls back to the default Kryo serializer if it can't be found.
+ * @return The Kryo serializer instance.
+ */
+ private Kryo getKryoInstance() {
+
+ try {
+ // check if ScalaKryoInstantiator is in class path (coming from Twitter's Chill library).
+ // This will be true if Flink's Scala API is used.
+ Class<?> chillInstantiatorClazz = Class.forName("com.twitter.chill.ScalaKryoInstantiator");
+ Object chillInstantiator = chillInstantiatorClazz.newInstance();
+
+ // obtain a Kryo instance through Twitter Chill
+ Method m = chillInstantiatorClazz.getMethod("newKryo");
+
+ return (Kryo) m.invoke(chillInstantiator);
+ } catch (ClassNotFoundException | InstantiationException | NoSuchMethodException |
+ IllegalAccessException | InvocationTargetException e) {
+
+ LOG.warn("Falling back to default Kryo serializer because Chill serializer couldn't be found.", e);
+
+ Kryo.DefaultInstantiatorStrategy initStrategy = new Kryo.DefaultInstantiatorStrategy();
+ initStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+
+ Kryo kryo = new Kryo();
+ kryo.setInstantiatorStrategy(initStrategy);
+
+ return kryo;
+ }
+ }
+
+ private void checkKryoInitialized() {
+ if (this.kryo == null) {
+ this.kryo = getKryoInstance();
+
+ // disable reference tracking. reference tracking is costly, usually unnecessary, and
+ // inconsistent with Flink's own serialization (which does not do reference tracking)
+ kryo.setReferences(false);
+
+ // Throwable and all subclasses should be serialized via java serialization
+ kryo.addDefaultSerializer(Throwable.class, new JavaSerializer());
+
+ // Add default serializers first, so that they type registrations without a serializer
+ // are registered with a default serializer
+ for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> entry: defaultSerializers.entrySet()) {
+ kryo.addDefaultSerializer(entry.getKey(), entry.getValue().getSerializer());
+ }
+
+ for (Map.Entry<Class<?>, Class<? extends Serializer<?>>> entry: defaultSerializerClasses.entrySet()) {
+ kryo.addDefaultSerializer(entry.getKey(), entry.getValue());
+ }
+
+ // register the type of our class
+ kryo.register(type);
+
+ // register given types. we do this first so that any registration of a
+ // more specific serializer overrides this
+ for (Class<?> type : registeredTypes) {
+ kryo.register(type);
+ }
+
+ // register given serializer classes
+ for (Map.Entry<Class<?>, Class<? extends Serializer<?>>> e : registeredTypesWithSerializerClasses.entrySet()) {
+ Class<?> typeClass = e.getKey();
+ Class<? extends Serializer<?>> serializerClass = e.getValue();
+
+ Serializer<?> serializer =
+ ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, typeClass);
+ kryo.register(typeClass, serializer);
+ }
+
+ // register given serializers
+ for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> e : registeredTypesWithSerializers.entrySet()) {
+ kryo.register(e.getKey(), e.getValue().getSerializer());
+ }
+ // this is needed for Avro but can not be added on demand.
+ kryo.register(GenericData.Array.class, new SpecificInstanceCollectionSerializerForArrayList());
+
+ kryo.setRegistrationRequired(false);
+ kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // For testing
+ // --------------------------------------------------------------------------------------------
+
+ public Kryo getKryo() {
+ checkKryoInitialized();
+ return this.kryo;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java
new file mode 100644
index 0000000..009cb24
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java
@@ -0,0 +1,227 @@
+/*
+ * 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.java.typeutils.runtime.kryo;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.Serializer;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+import com.esotericsoftware.kryo.serializers.CollectionSerializer;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.specific.SpecificRecordBase;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * Class containing utilities for the serializers of the Flink Runtime.
+ *
+ * Most of the serializers are automatically added to the system.
+ *
+ * Note that users can also implement the {@link com.esotericsoftware.kryo.KryoSerializable} interface
+ * to provide custom serialization for their classes.
+ * Also, there is a Java Annotation for adding a default serializer (@DefaultSerializer) to classes.
+ */
+public class Serializers {
+
+ public static void recursivelyRegisterType(TypeInformation<?> typeInfo, ExecutionConfig config, Set<Class<?>> alreadySeen) {
+ if (typeInfo instanceof GenericTypeInfo) {
+ GenericTypeInfo<?> genericTypeInfo = (GenericTypeInfo<?>) typeInfo;
+ Serializers.recursivelyRegisterType(genericTypeInfo.getTypeClass(), config, alreadySeen);
+ }
+ else if (typeInfo instanceof CompositeType) {
+ List<GenericTypeInfo<?>> genericTypesInComposite = new ArrayList<>();
+ getContainedGenericTypes((CompositeType<?>)typeInfo, genericTypesInComposite);
+ for (GenericTypeInfo<?> gt : genericTypesInComposite) {
+ Serializers.recursivelyRegisterType(gt.getTypeClass(), config, alreadySeen);
+ }
+ }
+ else if (typeInfo instanceof ObjectArrayTypeInfo) {
+ ObjectArrayTypeInfo<?, ?> objectArrayTypeInfo = (ObjectArrayTypeInfo<?, ?>) typeInfo;
+ recursivelyRegisterType(objectArrayTypeInfo.getComponentInfo(), config, alreadySeen);
+ }
+ }
+
+ public static void recursivelyRegisterType(Class<?> type, ExecutionConfig config, Set<Class<?>> alreadySeen) {
+ // don't register or remember primitives
+ if (type == null || type.isPrimitive() || type == Object.class) {
+ return;
+ }
+
+ // prevent infinite recursion for recursive types
+ if (!alreadySeen.add(type)) {
+ return;
+ }
+
+ if (type.isArray()) {
+ recursivelyRegisterType(type.getComponentType(), config, alreadySeen);
+ }
+ else {
+ config.registerKryoType(type);
+ checkAndAddSerializerForTypeAvro(config, type);
+
+ Field[] fields = type.getDeclaredFields();
+ for (Field field : fields) {
+ if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers())) {
+ continue;
+ }
+ Type fieldType = field.getGenericType();
+ recursivelyRegisterGenericType(fieldType, config, alreadySeen);
+ }
+ }
+ }
+
+ private static void recursivelyRegisterGenericType(Type fieldType, ExecutionConfig config, Set<Class<?>> alreadySeen) {
+ if (fieldType instanceof ParameterizedType) {
+ // field has generics
+ ParameterizedType parameterizedFieldType = (ParameterizedType) fieldType;
+
+ for (Type t: parameterizedFieldType.getActualTypeArguments()) {
+ if (TypeExtractor.isClassType(t) ) {
+ recursivelyRegisterType(TypeExtractor.typeToClass(t), config, alreadySeen);
+ }
+ }
+
+ recursivelyRegisterGenericType(parameterizedFieldType.getRawType(), config, alreadySeen);
+ }
+ else if (fieldType instanceof GenericArrayType) {
+ GenericArrayType genericArrayType = (GenericArrayType) fieldType;
+ recursivelyRegisterGenericType(genericArrayType.getGenericComponentType(), config, alreadySeen);
+ }
+ else if (fieldType instanceof Class) {
+ Class<?> clazz = (Class<?>) fieldType;
+ recursivelyRegisterType(clazz, config, alreadySeen);
+ }
+ }
+
+ /**
+ * Returns all GenericTypeInfos contained in a composite type.
+ *
+ * @param typeInfo {@link CompositeType}
+ */
+ private static void getContainedGenericTypes(CompositeType<?> typeInfo, List<GenericTypeInfo<?>> target) {
+ for (int i = 0; i < typeInfo.getArity(); i++) {
+ TypeInformation<?> type = typeInfo.getTypeAt(i);
+ if (type instanceof CompositeType) {
+ getContainedGenericTypes((CompositeType<?>) type, target);
+ } else if (type instanceof GenericTypeInfo) {
+ if (!target.contains(type)) {
+ target.add((GenericTypeInfo<?>) type);
+ }
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ private static void checkAndAddSerializerForTypeAvro(ExecutionConfig reg, Class<?> type) {
+ if (GenericData.Record.class.isAssignableFrom(type) || SpecificRecordBase.class.isAssignableFrom(type)) {
+ // Avro POJOs contain java.util.List which have GenericData.Array as their runtime type
+ // because Kryo is not able to serialize them properly, we use this serializer for them
+ reg.registerTypeWithKryoSerializer(GenericData.Array.class, SpecificInstanceCollectionSerializerForArrayList.class);
+
+ // We register this serializer for users who want to use untyped Avro records (GenericData.Record).
+ // Kryo is able to serialize everything in there, except for the Schema.
+ // This serializer is very slow, but using the GenericData.Records of Kryo is in general a bad idea.
+ // we add the serializer as a default serializer because Avro is using a private sub-type at runtime.
+ reg.addDefaultKryoSerializer(Schema.class, AvroSchemaSerializer.class);
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Custom Serializers
+ // --------------------------------------------------------------------------------------------
+
+ @SuppressWarnings("rawtypes")
+ public static class SpecificInstanceCollectionSerializerForArrayList extends SpecificInstanceCollectionSerializer<ArrayList> {
+ private static final long serialVersionUID = 1L;
+
+ public SpecificInstanceCollectionSerializerForArrayList() {
+ super(ArrayList.class);
+ }
+ }
+ /**
+ * Special serializer for Java collections enforcing certain instance types.
+ * Avro is serializing collections with an "GenericData.Array" type. Kryo is not able to handle
+ * this type, so we use ArrayLists.
+ */
+ @SuppressWarnings("rawtypes")
+ public static class SpecificInstanceCollectionSerializer<T extends Collection>
+ extends CollectionSerializer implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private Class<T> type;
+
+ public SpecificInstanceCollectionSerializer(Class<T> type) {
+ this.type = type;
+ }
+
+ @Override
+ protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
+ return kryo.newInstance(this.type);
+ }
+
+ @Override
+ protected Collection createCopy(Kryo kryo, Collection original) {
+ return kryo.newInstance(this.type);
+ }
+ }
+
+ /**
+ * Slow serialization approach for Avro schemas.
+ * This is only used with {{@link org.apache.avro.generic.GenericData.Record}} types.
+ * Having this serializer, we are able to handle avro Records.
+ */
+ public static class AvroSchemaSerializer extends Serializer<Schema> implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void write(Kryo kryo, Output output, Schema object) {
+ String schemaAsString = object.toString(false);
+ output.writeString(schemaAsString);
+ }
+
+ @Override
+ public Schema read(Kryo kryo, Input input, Class<Schema> type) {
+ String schemaAsString = input.readString();
+ // the parser seems to be stateful, to we need a new one for every type.
+ Schema.Parser sParser = new Schema.Parser();
+ return sParser.parse(schemaAsString);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/common/operators/ExpressionKeysTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/operators/ExpressionKeysTest.java b/flink-core/src/test/java/org/apache/flink/api/common/operators/ExpressionKeysTest.java
new file mode 100644
index 0000000..8e65a79
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/common/operators/ExpressionKeysTest.java
@@ -0,0 +1,481 @@
+/*
+ * 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;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import org.apache.flink.api.common.InvalidProgramException;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.tuple.Tuple7;
+import org.apache.flink.api.java.typeutils.PojoTypeExtractionTest.ComplexNestedClass;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.api.common.operators.SelectorFunctionKeysTest.KeySelector1;
+import org.apache.flink.api.common.operators.SelectorFunctionKeysTest.KeySelector3;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+@SuppressWarnings("unused")
+@RunWith(PowerMockRunner.class)
+public class ExpressionKeysTest {
+
+ @Test
+ public void testBasicType() {
+
+ TypeInformation<Long> longType = BasicTypeInfo.LONG_TYPE_INFO;
+ ExpressionKeys<Long> ek = new ExpressionKeys<>("*", longType);
+
+ Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
+ }
+
+ @Test(expected = InvalidProgramException.class)
+ public void testGenericNonKeyType() {
+ // Fail: GenericType cannot be used as key
+ TypeInformation<GenericNonKeyType> genericType = new GenericTypeInfo<>(GenericNonKeyType.class);
+ new ExpressionKeys<>("*", genericType);
+ }
+
+ @Test
+ public void testKeyGenericType() {
+
+ TypeInformation<GenericKeyType> genericType = new GenericTypeInfo<>(GenericKeyType.class);
+ ExpressionKeys<GenericKeyType> ek = new ExpressionKeys<>("*", genericType);
+
+ Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
+ }
+
+ @Test
+ public void testTupleRangeCheck() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+
+ // test private static final int[] rangeCheckFields(int[] fields, int maxAllowedField)
+ Method rangeCheckFieldsMethod = Whitebox.getMethod(Keys.class, "rangeCheckFields", int[].class, int.class);
+
+ // valid indexes
+ rangeCheckFieldsMethod.invoke(null, new int[]{1, 2, 3, 4}, 4);
+
+ // corner case tests
+ rangeCheckFieldsMethod.invoke(null, new int[] {0}, 0);
+
+ Throwable ex = null;
+ try {
+ // throws illegal argument.
+ rangeCheckFieldsMethod.invoke(null, new int[] {5}, 0);
+ } catch(Throwable iae) {
+ ex = iae;
+ }
+ Assert.assertNotNull(ex);
+ }
+
+ @Test
+ public void testStandardTupleKeys() {
+ TupleTypeInfo<Tuple7<String, String, String, String, String, String, String>> typeInfo = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO);
+
+ ExpressionKeys<Tuple7<String, String, String, String, String, String, String>> ek;
+
+ for( int i = 1; i < 8; i++) {
+ int[] ints = new int[i];
+ for( int j = 0; j < i; j++) {
+ ints[j] = j;
+ }
+ int[] inInts = Arrays.copyOf(ints, ints.length); // copy, just to make sure that the code is not cheating by changing the ints.
+ ek = new ExpressionKeys<>(inInts, typeInfo);
+ Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions());
+ Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length);
+
+ ArrayUtils.reverse(ints);
+ inInts = Arrays.copyOf(ints, ints.length);
+ ek = new ExpressionKeys<>(inInts, typeInfo);
+ Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions());
+ Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length);
+ }
+ }
+
+ @Test
+ public void testInvalidTuple() throws Throwable {
+ TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
+ BasicTypeInfo.STRING_TYPE_INFO);
+
+ String[][] tests = new String[][] {
+ new String[] {"f0.f1"}, // nesting into unnested
+ new String[] {"f11"},
+ new String[] {"f-35"},
+ new String[] {"f0.f33"},
+ new String[] {"f1.f33"}
+ };
+ for (String[] test : tests) {
+ Throwable e = null;
+ try {
+ new ExpressionKeys<>(test, typeInfo);
+ } catch (Throwable t) {
+ e = t;
+ }
+ Assert.assertNotNull(e);
+ }
+ }
+
+ @Test(expected = InvalidProgramException.class)
+ public void testTupleNonKeyField() {
+ // selected field is not a key type
+ TypeInformation<Tuple3<String, Long, GenericNonKeyType>> ti = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO,
+ TypeExtractor.getForClass(GenericNonKeyType.class)
+ );
+
+ new ExpressionKeys<>(2, ti);
+ }
+
+ @Test
+ public void testTupleKeyExpansion() {
+ TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
+ BasicTypeInfo.STRING_TYPE_INFO);
+ ExpressionKeys<Tuple3<String, Tuple3<String, String, String>, String>> fpk =
+ new ExpressionKeys<>(0, typeInfo);
+ Assert.assertArrayEquals(new int[] {0}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(1, typeInfo);
+ Assert.assertArrayEquals(new int[] {1,2,3}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(2, typeInfo);
+ Assert.assertArrayEquals(new int[] {4}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(new int[] {0,1,2}, typeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(null, typeInfo, true); // empty case
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>("*", typeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
+
+ // scala style "select all"
+ fpk = new ExpressionKeys<>("_", typeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
+
+ // this was a bug:
+ fpk = new ExpressionKeys<>("f2", typeInfo);
+ Assert.assertArrayEquals(new int[] {4}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(new String[] {"f0","f1.f0","f1.f1", "f1.f2", "f2"}, typeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(new String[] {"f0","f1.f0","f1.f1", "f2"}, typeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,4}, fpk.computeLogicalKeyPositions());
+
+ fpk = new ExpressionKeys<>(new String[] {"f2", "f0"}, typeInfo);
+ Assert.assertArrayEquals(new int[] {4,0}, fpk.computeLogicalKeyPositions());
+
+
+ TupleTypeInfo<Tuple3<String, Tuple3<Tuple3<String, String, String>, String, String>, String>> complexTypeInfo = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ new TupleTypeInfo<Tuple3<Tuple3<String, String, String>, String, String>>(new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
+ BasicTypeInfo.STRING_TYPE_INFO);
+
+ ExpressionKeys<Tuple3<String, Tuple3<Tuple3<String, String, String>, String, String>, String>> complexFpk =
+ new ExpressionKeys<>(0, complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {0}, complexFpk.computeLogicalKeyPositions());
+
+ complexFpk = new ExpressionKeys<>(new int[] {0,1,2}, complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());
+
+ complexFpk = new ExpressionKeys<>("*", complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());
+
+ // scala style select all
+ complexFpk = new ExpressionKeys<>("_", complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());
+
+ complexFpk = new ExpressionKeys<>("f1.f0.*", complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {1,2,3}, complexFpk.computeLogicalKeyPositions());
+
+ complexFpk = new ExpressionKeys<>("f1.f0", complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {1,2,3}, complexFpk.computeLogicalKeyPositions());
+
+ complexFpk = new ExpressionKeys<>("f2", complexTypeInfo);
+ Assert.assertArrayEquals(new int[] {6}, complexFpk.computeLogicalKeyPositions());
+ }
+
+ @Test
+ public void testPojoKeys() {
+ TypeInformation<PojoWithMultiplePojos> ti = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
+ ExpressionKeys<PojoWithMultiplePojos> ek;
+ ek = new ExpressionKeys<>("*", ti);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>("p1.*", ti);
+ Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>("p2.*", ti);
+ Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>("p1", ti);
+ Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>("p2", ti);
+ Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>("i0", ti);
+ Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
+ }
+
+ @Test
+ public void testTupleWithNestedPojo() {
+
+ TypeInformation<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ti =
+ new TupleTypeInfo<>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ TypeExtractor.getForClass(Pojo1.class),
+ TypeExtractor.getForClass(PojoWithMultiplePojos.class)
+ );
+
+ ExpressionKeys<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ek;
+
+ ek = new ExpressionKeys<>(0, ti);
+ Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>(1, ti);
+ Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>(2, ti);
+ Assert.assertArrayEquals(new int[] {3,4,5,6,7}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>(new int[]{}, ti, true);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions());
+
+ ek = new ExpressionKeys<>("*", ti);
+ Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions());
+
+ }
+
+ @Test(expected = InvalidProgramException.class)
+ public void testNonKeyPojoField() {
+ // selected field is not a key type
+ TypeInformation<PojoWithNonKeyField> ti = TypeExtractor.getForClass(PojoWithNonKeyField.class);
+ new ExpressionKeys<>("b", ti);
+ }
+
+ @Test
+ public void testInvalidPojo() throws Throwable {
+ TypeInformation<ComplexNestedClass> ti = TypeExtractor.getForClass(ComplexNestedClass.class);
+
+ String[][] tests = new String[][] {
+ new String[] {"nonexistent"},
+ new String[] {"date.abc"} // nesting into unnested
+ };
+ for (String[] test : tests) {
+ Throwable e = null;
+ try {
+ new ExpressionKeys<>(test, ti);
+ } catch (Throwable t) {
+ e = t;
+ }
+ Assert.assertNotNull(e);
+ }
+ }
+
+ @Test
+ public void testAreCompatible1() throws Keys.IncompatibleKeysException {
+ TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
+
+ ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
+ ExpressionKeys<Pojo1> ek2 = new ExpressionKeys<>("b", t1);
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ Assert.assertTrue(ek2.areCompatible(ek1));
+ }
+
+ @Test
+ public void testAreCompatible2() throws Keys.IncompatibleKeysException {
+ TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
+ TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO
+ );
+
+ ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
+ ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ Assert.assertTrue(ek2.areCompatible(ek1));
+ }
+
+ @Test
+ public void testAreCompatible3() throws Keys.IncompatibleKeysException {
+ TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
+ TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO
+ );
+
+ ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1);
+ ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ Assert.assertTrue(ek2.areCompatible(ek1));
+ }
+
+ @Test
+ public void testAreCompatible4() throws Keys.IncompatibleKeysException {
+ TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
+ TypeInformation<Tuple3<String, Long, Integer>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO,
+ BasicTypeInfo.INT_TYPE_INFO
+ );
+
+ ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1", "i0"}, t1);
+ ExpressionKeys<Tuple3<String, Long, Integer>> ek2 = new ExpressionKeys<>(new int[]{0, 0, 2}, t2);
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ Assert.assertTrue(ek2.areCompatible(ek1));
+ }
+
+ @Test
+ public void testAreCompatible5() throws Keys.IncompatibleKeysException {
+ TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
+ TypeInformation<Tuple2<String, String>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO
+ );
+
+ ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1.b", "p2.a2"}, t1);
+ ExpressionKeys<Tuple2<String, String>> ek2 = new ExpressionKeys<>("*", t2);
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ Assert.assertTrue(ek2.areCompatible(ek1));
+ }
+
+ @Test(expected = Keys.IncompatibleKeysException.class)
+ public void testAreCompatible6() throws Keys.IncompatibleKeysException {
+ TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
+ TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO
+ );
+
+ ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
+ ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(1, t2);
+
+ ek1.areCompatible(ek2);
+ }
+
+ @Test(expected = Keys.IncompatibleKeysException.class)
+ public void testAreCompatible7() throws Keys.IncompatibleKeysException {
+ TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
+ TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO
+ );
+
+ ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>(new String[]{"a", "b"}, t1);
+ ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);
+
+ ek1.areCompatible(ek2);
+ }
+
+ @Test
+ public void testAreCompatible8() throws Keys.IncompatibleKeysException {
+ TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
+ TypeInformation<Pojo2> t2 = TypeExtractor.getForClass(Pojo2.class);
+
+ ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1);
+ Keys<Pojo2> ek2 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector1(),
+ t2,
+ BasicTypeInfo.STRING_TYPE_INFO
+ );
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ }
+
+ @Test
+ public void testAreCompatible9() throws Keys.IncompatibleKeysException {
+ TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO,
+ BasicTypeInfo.INT_TYPE_INFO
+ );
+ TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
+
+ ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new ExpressionKeys<>(new int[]{2,0}, t1);
+ Keys<PojoWithMultiplePojos> ek2 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector3(),
+ t2,
+ new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO)
+ );
+
+ Assert.assertTrue(ek1.areCompatible(ek2));
+ }
+
+ public static class Pojo1 {
+ public String a;
+ public String b;
+ }
+
+ public static class Pojo2 {
+ public String a2;
+ public String b2;
+ }
+
+ public static class PojoWithMultiplePojos {
+ public Pojo1 p1;
+ public Pojo2 p2;
+ public Integer i0;
+ }
+
+ public static class PojoWithNonKeyField {
+ public String a;
+ public GenericNonKeyType b;
+ }
+
+ public static class GenericNonKeyType {
+ private String a;
+ private String b;
+ }
+
+ public static class GenericKeyType implements Comparable<GenericNonKeyType> {
+ private String a;
+ private String b;
+
+ @Override
+ public int compareTo(GenericNonKeyType o) {
+ return 0;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/common/operators/SelectorFunctionKeysTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/common/operators/SelectorFunctionKeysTest.java b/flink-core/src/test/java/org/apache/flink/api/common/operators/SelectorFunctionKeysTest.java
new file mode 100644
index 0000000..ad6fefa
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/common/operators/SelectorFunctionKeysTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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;
+
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.functions.KeySelector;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.api.common.operators.ExpressionKeysTest.PojoWithMultiplePojos;
+import org.apache.flink.api.common.operators.ExpressionKeysTest.Pojo1;
+import org.apache.flink.api.common.operators.ExpressionKeysTest.Pojo2;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SelectorFunctionKeysTest {
+
+ @Test
+ public void testAreCompatible1() throws Keys.IncompatibleKeysException {
+ TypeInformation<Pojo2> t1 = TypeExtractor.getForClass(Pojo2.class);
+ TypeInformation<Tuple2<Integer, String>> t2 =
+ new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
+
+ Keys<Pojo2> k1 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector1(),
+ t1,
+ BasicTypeInfo.STRING_TYPE_INFO
+ );
+ Keys<Tuple2<Integer, String>> k2 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector2(),
+ t2,
+ BasicTypeInfo.STRING_TYPE_INFO
+ );
+
+ Assert.assertTrue(k1.areCompatible(k2));
+ Assert.assertTrue(k2.areCompatible(k1));
+ }
+
+ @Test
+ public void testAreCompatible2() throws Keys.IncompatibleKeysException {
+ TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
+ TypeInformation<Tuple3<Long, Pojo1, Integer>> t2 = new TupleTypeInfo<>(
+ BasicTypeInfo.LONG_TYPE_INFO,
+ TypeExtractor.getForClass(Pojo1.class),
+ BasicTypeInfo.INT_TYPE_INFO);
+ TypeInformation<Tuple2<Integer, String>> kt = new TupleTypeInfo<>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO
+ );
+
+ Keys<PojoWithMultiplePojos> k1 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector3(),
+ t1,
+ kt
+ );
+ Keys<Tuple3<Long, Pojo1, Integer>> k2 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector4(),
+ t2,
+ kt
+ );
+
+ Assert.assertTrue(k1.areCompatible(k2));
+ Assert.assertTrue(k2.areCompatible(k1));
+ }
+
+ @Test
+ public void testAreCompatible3() throws Keys.IncompatibleKeysException {
+ TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
+ TypeInformation<Pojo2> t2 = TypeExtractor.getForClass(Pojo2.class);
+
+ Keys.ExpressionKeys<String> ek1 = new Keys.ExpressionKeys<>("*", t1);
+ Keys<Pojo2> sk2 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector1(),
+ t2,
+ BasicTypeInfo.STRING_TYPE_INFO
+ );
+
+ Assert.assertTrue(sk2.areCompatible(ek1));
+ }
+
+ @Test
+ public void testAreCompatible4() throws Keys.IncompatibleKeysException {
+ TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>(
+ BasicTypeInfo.STRING_TYPE_INFO,
+ BasicTypeInfo.LONG_TYPE_INFO,
+ BasicTypeInfo.INT_TYPE_INFO
+ );
+ TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
+
+ Keys.ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new Keys.ExpressionKeys<>(new int[]{2,0}, t1);
+ Keys<PojoWithMultiplePojos> sk2 = new Keys.SelectorFunctionKeys<>(
+ new KeySelector3(),
+ t2,
+ new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO)
+ );
+
+ Assert.assertTrue(sk2.areCompatible(ek1));
+ }
+
+ @SuppressWarnings("serial")
+ public static class KeySelector1 implements KeySelector<Pojo2, String> {
+
+ @Override
+ public String getKey(Pojo2 v) throws Exception {
+ return v.b2;
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class KeySelector2 implements KeySelector<Tuple2<Integer, String>, String> {
+
+ @Override
+ public String getKey(Tuple2<Integer, String> v) throws Exception {
+ return v.f1;
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class KeySelector3 implements KeySelector<PojoWithMultiplePojos, Tuple2<Integer, String>> {
+
+ @Override
+ public Tuple2<Integer, String> getKey(PojoWithMultiplePojos v) throws Exception {
+ return new Tuple2<>(v.i0, v.p1.b);
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class KeySelector4 implements KeySelector<Tuple3<Long, Pojo1, Integer>, Tuple2<Integer, String>> {
+
+ @Override
+ public Tuple2<Integer, String> getKey(Tuple3<Long, Pojo1, Integer> v) throws Exception {
+ return new Tuple2<>(v.f2, v.f1.a);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java b/flink-core/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
new file mode 100644
index 0000000..b8fe14c
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
@@ -0,0 +1,44 @@
+/*
+ * 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.java.tuple;
+
+import org.apache.flink.types.NullFieldException;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Tuple2Test {
+
+ @Test
+ public void testSwapValues() {
+ Tuple2<String, Integer> toSwap = new Tuple2<>("Test case", 25);
+ Tuple2<Integer, String> swapped = toSwap.swap();
+
+ Assert.assertEquals(swapped.f0, toSwap.f1);
+
+ Assert.assertEquals(swapped.f1, toSwap.f0);
+ }
+
+ @Test(expected = NullFieldException.class)
+ public void testGetFieldNotNull() {
+ Tuple2<String, Integer> tuple = new Tuple2<>("Test case", null);
+
+ Assert.assertEquals("Test case", tuple.getFieldNotNull(0));
+ tuple.getFieldNotNull(1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java
new file mode 100644
index 0000000..cd405bc
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/CompositeTypeTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.java.typeutils;
+
+import static org.junit.Assert.*;
+
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.tuple.Tuple4;
+import org.junit.Test;
+
+public class CompositeTypeTest {
+
+ private final TupleTypeInfo<?> tupleTypeInfo = new TupleTypeInfo<Tuple4<Integer, Integer, Integer, Integer>>(
+ BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO);
+
+
+ private final TupleTypeInfo<Tuple3<Integer, String, Long>> inNestedTuple1 = new TupleTypeInfo<Tuple3<Integer, String, Long>>(
+ BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO);
+
+ private final TupleTypeInfo<Tuple2<Double, Double>> inNestedTuple2 = new TupleTypeInfo<Tuple2<Double, Double>>(
+ BasicTypeInfo.DOUBLE_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO);
+
+ private final TupleTypeInfo<?> nestedTypeInfo = new TupleTypeInfo<Tuple4<Integer, Tuple3<Integer, String, Long>, Integer, Tuple2<Double, Double>>>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ inNestedTuple1,
+ BasicTypeInfo.INT_TYPE_INFO,
+ inNestedTuple2);
+
+ private final TupleTypeInfo<Tuple2<Integer, Tuple2<Integer, Integer>>> inNestedTuple3 = new TupleTypeInfo<Tuple2<Integer, Tuple2<Integer, Integer>>>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ new TupleTypeInfo<Tuple2<Integer, Integer>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO));
+
+ private final TupleTypeInfo<?> deepNestedTupleTypeInfo = new TupleTypeInfo<Tuple3<Integer, Tuple2<Integer, Tuple2<Integer, Integer>>, Integer>>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ inNestedTuple3,
+ BasicTypeInfo.INT_TYPE_INFO );
+
+ private final PojoTypeInfo<?> pojoTypeInfo = ((PojoTypeInfo<?>) TypeExtractor.getForClass
+ (MyPojo.class));
+
+ private final TupleTypeInfo<?> pojoInTupleTypeInfo = new TupleTypeInfo<Tuple2<Integer, MyPojo>>(BasicTypeInfo.INT_TYPE_INFO, pojoTypeInfo);
+
+ @Test
+ public void testGetFlatFields() {
+ assertEquals(0, tupleTypeInfo.getFlatFields("0").get(0).getPosition());
+ assertEquals(1, tupleTypeInfo.getFlatFields("1").get(0).getPosition());
+ assertEquals(2, tupleTypeInfo.getFlatFields("2").get(0).getPosition());
+ assertEquals(3, tupleTypeInfo.getFlatFields("3").get(0).getPosition());
+ assertEquals(0, tupleTypeInfo.getFlatFields("f0").get(0).getPosition());
+ assertEquals(1, tupleTypeInfo.getFlatFields("f1").get(0).getPosition());
+ assertEquals(2, tupleTypeInfo.getFlatFields("f2").get(0).getPosition());
+ assertEquals(3, tupleTypeInfo.getFlatFields("f3").get(0).getPosition());
+
+ assertEquals(0, nestedTypeInfo.getFlatFields("0").get(0).getPosition());
+ assertEquals(1, nestedTypeInfo.getFlatFields("1.0").get(0).getPosition());
+ assertEquals(2, nestedTypeInfo.getFlatFields("1.1").get(0).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("1.2").get(0).getPosition());
+ assertEquals(4, nestedTypeInfo.getFlatFields("2").get(0).getPosition());
+ assertEquals(5, nestedTypeInfo.getFlatFields("3.0").get(0).getPosition());
+ assertEquals(6, nestedTypeInfo.getFlatFields("3.1").get(0).getPosition());
+ assertEquals(4, nestedTypeInfo.getFlatFields("f2").get(0).getPosition());
+ assertEquals(5, nestedTypeInfo.getFlatFields("f3.f0").get(0).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("1").size());
+ assertEquals(1, nestedTypeInfo.getFlatFields("1").get(0).getPosition());
+ assertEquals(2, nestedTypeInfo.getFlatFields("1").get(1).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("1").get(2).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("1.*").size());
+ assertEquals(1, nestedTypeInfo.getFlatFields("1.*").get(0).getPosition());
+ assertEquals(2, nestedTypeInfo.getFlatFields("1.*").get(1).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("1.*").get(2).getPosition());
+ assertEquals(2, nestedTypeInfo.getFlatFields("3").size());
+ assertEquals(5, nestedTypeInfo.getFlatFields("3").get(0).getPosition());
+ assertEquals(6, nestedTypeInfo.getFlatFields("3").get(1).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("f1").size());
+ assertEquals(1, nestedTypeInfo.getFlatFields("f1").get(0).getPosition());
+ assertEquals(2, nestedTypeInfo.getFlatFields("f1").get(1).getPosition());
+ assertEquals(3, nestedTypeInfo.getFlatFields("f1").get(2).getPosition());
+ assertEquals(2, nestedTypeInfo.getFlatFields("f3").size());
+ assertEquals(5, nestedTypeInfo.getFlatFields("f3").get(0).getPosition());
+ assertEquals(6, nestedTypeInfo.getFlatFields("f3").get(1).getPosition());
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO,
+ nestedTypeInfo.getFlatFields("0").get(0).getType());
+ assertEquals(BasicTypeInfo.STRING_TYPE_INFO,
+ nestedTypeInfo.getFlatFields("1.1").get(0).getType());
+ assertEquals(BasicTypeInfo.LONG_TYPE_INFO,
+ nestedTypeInfo.getFlatFields("1").get(2).getType());
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO,
+ nestedTypeInfo.getFlatFields("3").get(1).getType());
+
+ assertEquals(3, deepNestedTupleTypeInfo.getFlatFields("1").size());
+ assertEquals(1, deepNestedTupleTypeInfo.getFlatFields("1").get(0).getPosition());
+ assertEquals(2, deepNestedTupleTypeInfo.getFlatFields("1").get(1).getPosition());
+ assertEquals(3, deepNestedTupleTypeInfo.getFlatFields("1").get(2).getPosition());
+ assertEquals(5, deepNestedTupleTypeInfo.getFlatFields("*").size());
+ assertEquals(0, deepNestedTupleTypeInfo.getFlatFields("*").get(0).getPosition());
+ assertEquals(1, deepNestedTupleTypeInfo.getFlatFields("*").get(1).getPosition());
+ assertEquals(2, deepNestedTupleTypeInfo.getFlatFields("*").get(2).getPosition());
+ assertEquals(3, deepNestedTupleTypeInfo.getFlatFields("*").get(3).getPosition());
+ assertEquals(4, deepNestedTupleTypeInfo.getFlatFields("*").get(4).getPosition());
+
+ assertEquals(0, pojoTypeInfo.getFlatFields("a").get(0).getPosition());
+ assertEquals(1, pojoTypeInfo.getFlatFields("b").get(0).getPosition());
+ assertEquals(2, pojoTypeInfo.getFlatFields("*").size());
+ assertEquals(0, pojoTypeInfo.getFlatFields("*").get(0).getPosition());
+ assertEquals(1, pojoTypeInfo.getFlatFields("*").get(1).getPosition());
+
+ assertEquals(1, pojoInTupleTypeInfo.getFlatFields("f1.a").get(0).getPosition());
+ assertEquals(2, pojoInTupleTypeInfo.getFlatFields("1.b").get(0).getPosition());
+ assertEquals(2, pojoInTupleTypeInfo.getFlatFields("1").size());
+ assertEquals(1, pojoInTupleTypeInfo.getFlatFields("1.*").get(0).getPosition());
+ assertEquals(2, pojoInTupleTypeInfo.getFlatFields("1").get(1).getPosition());
+ assertEquals(2, pojoInTupleTypeInfo.getFlatFields("f1.*").size());
+ assertEquals(1, pojoInTupleTypeInfo.getFlatFields("f1.*").get(0).getPosition());
+ assertEquals(2, pojoInTupleTypeInfo.getFlatFields("f1").get(1).getPosition());
+ assertEquals(3, pojoInTupleTypeInfo.getFlatFields("*").size());
+ assertEquals(0, pojoInTupleTypeInfo.getFlatFields("*").get(0).getPosition());
+ assertEquals(1, pojoInTupleTypeInfo.getFlatFields("*").get(1).getPosition());
+ assertEquals(2, pojoInTupleTypeInfo.getFlatFields("*").get(2).getPosition());
+
+ }
+
+ @Test
+ public void testFieldAtStringRef() {
+
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("0"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("2"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("f1"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleTypeInfo.getTypeAt("f3"));
+
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("0"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("1.0"));
+ assertEquals(BasicTypeInfo.STRING_TYPE_INFO, nestedTypeInfo.getTypeAt("1.1"));
+ assertEquals(BasicTypeInfo.LONG_TYPE_INFO, nestedTypeInfo.getTypeAt("1.2"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("2"));
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, nestedTypeInfo.getTypeAt("3.0"));
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, nestedTypeInfo.getTypeAt("3.1"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, nestedTypeInfo.getTypeAt("f2"));
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, nestedTypeInfo.getTypeAt("f3.f0"));
+ assertEquals(inNestedTuple1, nestedTypeInfo.getTypeAt("1"));
+ assertEquals(inNestedTuple2, nestedTypeInfo.getTypeAt("3"));
+ assertEquals(inNestedTuple1, nestedTypeInfo.getTypeAt("f1"));
+ assertEquals(inNestedTuple2, nestedTypeInfo.getTypeAt("f3"));
+
+ assertEquals(inNestedTuple3, deepNestedTupleTypeInfo.getTypeAt("1"));
+
+ assertEquals(BasicTypeInfo.STRING_TYPE_INFO, pojoTypeInfo.getTypeAt("a"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, pojoTypeInfo.getTypeAt("b"));
+
+ assertEquals(BasicTypeInfo.STRING_TYPE_INFO, pojoInTupleTypeInfo.getTypeAt("f1.a"));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, pojoInTupleTypeInfo.getTypeAt("1.b"));
+ assertEquals(pojoTypeInfo, pojoInTupleTypeInfo.getTypeAt("1"));
+ assertEquals(pojoTypeInfo, pojoInTupleTypeInfo.getTypeAt("f1"));
+
+ }
+
+ public static class MyPojo {
+ public String a;
+ public int b;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java
new file mode 100644
index 0000000..78c10b1
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EitherTypeInfoTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.java.typeutils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.types.Either;
+import org.apache.flink.types.Either.Right;
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+
+public class EitherTypeInfoTest extends TestLogger {
+
+ Either<Integer, String> intEither = Either.Left(1);
+ Either<Integer, String> stringEither = Either.Right("boo");
+ Either<Integer, Tuple2<Double, Long>> tuple2Either = new Right<>(new Tuple2<Double, Long>(42.0, 2l));
+
+ @Test
+ public void testEitherTypeEquality() {
+ EitherTypeInfo<Integer, String> eitherInfo1 = new EitherTypeInfo<Integer, String>(
+ BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
+
+ EitherTypeInfo<Integer, String> eitherInfo2 = new EitherTypeInfo<Integer, String>(
+ BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
+
+ assertEquals(eitherInfo1, eitherInfo2);
+ assertEquals(eitherInfo1.hashCode(), eitherInfo2.hashCode());
+ }
+
+ @Test
+ public void testEitherTypeInEquality() {
+ EitherTypeInfo<Integer, String> eitherInfo1 = new EitherTypeInfo<Integer, String>(
+ BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
+
+ EitherTypeInfo<Integer, Tuple2<Double, Long>> eitherInfo2 = new EitherTypeInfo<Integer, Tuple2<Double, Long>>(
+ BasicTypeInfo.INT_TYPE_INFO, new TupleTypeInfo<Tuple2<Double, Long>>(
+ TypeExtractor.getForClass(Double.class), TypeExtractor.getForClass(String.class)));
+
+ assertNotEquals(eitherInfo1, eitherInfo2);
+ assertNotEquals(eitherInfo1.hashCode(), eitherInfo2.hashCode());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java
new file mode 100644
index 0000000..b200566
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/EnumTypeInfoTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class EnumTypeInfoTest extends TestLogger {
+
+ enum TestEnum {
+ ONE, TWO
+ }
+
+ enum AlternativeEnum {
+ ONE, TWO
+ }
+
+ @Test
+ public void testEnumTypeEquality() {
+ EnumTypeInfo<TestEnum> enumTypeInfo1 = new EnumTypeInfo<TestEnum>(TestEnum.class);
+ EnumTypeInfo<TestEnum> enumTypeInfo2 = new EnumTypeInfo<TestEnum>(TestEnum.class);
+
+ assertEquals(enumTypeInfo1, enumTypeInfo2);
+ assertEquals(enumTypeInfo1.hashCode(), enumTypeInfo2.hashCode());
+ }
+
+ @Test
+ public void testEnumTypeInequality() {
+ EnumTypeInfo<TestEnum> enumTypeInfo1 = new EnumTypeInfo<TestEnum>(TestEnum.class);
+ EnumTypeInfo<AlternativeEnum> enumTypeInfo2 = new EnumTypeInfo<AlternativeEnum>(AlternativeEnum.class);
+
+ assertNotEquals(enumTypeInfo1, enumTypeInfo2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java
new file mode 100644
index 0000000..fad43df
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/GenericTypeInfoTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class GenericTypeInfoTest extends TestLogger {
+
+ static class TestClass {}
+ static class AlternativeClass {}
+
+ @Test
+ public void testGenericTypeInfoEquality() {
+ GenericTypeInfo<TestClass> tpeInfo1 = new GenericTypeInfo<>(TestClass.class);
+ GenericTypeInfo<TestClass> tpeInfo2 = new GenericTypeInfo<>(TestClass.class);
+
+ assertEquals(tpeInfo1, tpeInfo2);
+ assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
+ }
+
+ @Test
+ public void testGenericTypeInfoInequality() {
+ GenericTypeInfo<TestClass> tpeInfo1 = new GenericTypeInfo<>(TestClass.class);
+ GenericTypeInfo<AlternativeClass> tpeInfo2 = new GenericTypeInfo<>(AlternativeClass.class);
+
+ assertNotEquals(tpeInfo1, tpeInfo2);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java
new file mode 100644
index 0000000..ee57475
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/MissingTypeInfoTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MissingTypeInfoTest extends TestLogger {
+ static final String functionName = "foobar";
+ static final InvalidTypesException testException = new InvalidTypesException("Test exception.");
+
+ @Test
+ public void testMissingTypeInfoEquality() {
+ MissingTypeInfo tpeInfo1 = new MissingTypeInfo(functionName, testException);
+ MissingTypeInfo tpeInfo2 = new MissingTypeInfo(functionName, testException);
+
+ assertEquals(tpeInfo1, tpeInfo2);
+ assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
+ }
+
+ @Test
+ public void testMissingTypeInfoInequality() {
+ MissingTypeInfo tpeInfo1 = new MissingTypeInfo(functionName, testException);
+ MissingTypeInfo tpeInfo2 = new MissingTypeInfo("alt" + functionName, testException);
+
+ assertNotEquals(tpeInfo1, tpeInfo2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java
new file mode 100644
index 0000000..f3b39c0
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfoTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.util.TestLogger;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.*;
+
+public class ObjectArrayTypeInfoTest extends TestLogger {
+
+ public static class TestClass{}
+
+ @Test
+ public void testObjectArrayTypeInfoEquality() {
+ ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo1 = ObjectArrayTypeInfo.getInfoFor(
+ TestClass[].class,
+ new GenericTypeInfo<TestClass>(TestClass.class));
+
+ ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo2 = ObjectArrayTypeInfo.getInfoFor(
+ TestClass[].class,
+ new GenericTypeInfo<TestClass>(TestClass.class));
+
+ assertEquals(tpeInfo1, tpeInfo2);
+ assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
+ }
+
+ @Test
+ public void testObjectArrayTypeInfoInequality() {
+ ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo1 = ObjectArrayTypeInfo.getInfoFor(
+ TestClass[].class,
+ new GenericTypeInfo<TestClass>(TestClass.class));
+
+ ObjectArrayTypeInfo<TestClass[], TestClass> tpeInfo2 = ObjectArrayTypeInfo.getInfoFor(
+ TestClass[].class,
+ new PojoTypeInfo<TestClass>(TestClass.class, new ArrayList<PojoField>()));
+
+ assertNotEquals(tpeInfo1, tpeInfo2);
+ }
+}
[36/38] flink git commit: [hotfix] Remove old sysout debug message in
UdfAnalyzerTest
Posted by se...@apache.org.
[hotfix] Remove old sysout debug message in UdfAnalyzerTest
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/b90542e8
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/b90542e8
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/b90542e8
Branch: refs/heads/master
Commit: b90542e80b2f9f5fb8ffe6e6325400b3cdd9301f
Parents: 168532e
Author: Stephan Ewen <se...@apache.org>
Authored: Mon Feb 1 21:46:09 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 17:11:50 2016 +0100
----------------------------------------------------------------------
.../test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/b90542e8/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
index a1ccfe4..dc2d1db 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
@@ -366,7 +366,6 @@ public class UdfAnalyzerTest {
@Test
public void testForwardWithGetMethod() {
- System.out.println("HERE");
compareAnalyzerResultWithAnnotationsSingleInput(MapFunction.class, Map20.class,
"Tuple4<Integer, Integer, Integer, Integer>", "Tuple4<Integer, Integer, Integer, Integer>");
}
[34/38] flink git commit: [FLINK-2348] Fix unstable
IterateExampleITCase.
Posted by se...@apache.org.
[FLINK-2348] Fix unstable IterateExampleITCase.
This deactivates the validation of results, which is not reliably possible under the current model (timeout on feedback).
This test for now only checks that the job executes properly.
Also adds proper logging property files for the examples projects.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/bfff86c8
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/bfff86c8
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/bfff86c8
Branch: refs/heads/master
Commit: bfff86c841f0b873f25367419db0b3dd504a1197
Parents: 6f042e7
Author: Stephan Ewen <se...@apache.org>
Authored: Mon Feb 1 17:09:38 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 16:55:45 2016 +0100
----------------------------------------------------------------------
.../src/main/resources/log4j-test.properties | 23 ----------------
.../src/main/resources/log4j.properties | 23 ++++++++++++++++
.../src/main/resources/logback.xml | 29 ++++++++++++++++++++
.../iteration/IterateExampleITCase.java | 4 ++-
.../src/test/resources/log4j-test.properties | 23 ++++++++++++++++
5 files changed, 78 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/bfff86c8/flink-examples/flink-examples-batch/src/main/resources/log4j-test.properties
----------------------------------------------------------------------
diff --git a/flink-examples/flink-examples-batch/src/main/resources/log4j-test.properties b/flink-examples/flink-examples-batch/src/main/resources/log4j-test.properties
deleted file mode 100644
index 65bd0b8..0000000
--- a/flink-examples/flink-examples-batch/src/main/resources/log4j-test.properties
+++ /dev/null
@@ -1,23 +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.
-################################################################################
-
-log4j.rootLogger=INFO, console
-
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/bfff86c8/flink-examples/flink-examples-streaming/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/flink-examples/flink-examples-streaming/src/main/resources/log4j.properties b/flink-examples/flink-examples-streaming/src/main/resources/log4j.properties
new file mode 100644
index 0000000..da32ea0
--- /dev/null
+++ b/flink-examples/flink-examples-streaming/src/main/resources/log4j.properties
@@ -0,0 +1,23 @@
+################################################################################
+# 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.
+################################################################################
+
+log4j.rootLogger=INFO, console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n
http://git-wip-us.apache.org/repos/asf/flink/blob/bfff86c8/flink-examples/flink-examples-streaming/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/flink-examples/flink-examples-streaming/src/main/resources/logback.xml b/flink-examples/flink-examples-streaming/src/main/resources/logback.xml
new file mode 100644
index 0000000..95f2d04
--- /dev/null
+++ b/flink-examples/flink-examples-streaming/src/main/resources/logback.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT"/>
+ </root>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/bfff86c8/flink-examples/flink-examples-streaming/src/test/java/org/apache/flink/streaming/test/exampleJavaPrograms/iteration/IterateExampleITCase.java
----------------------------------------------------------------------
diff --git a/flink-examples/flink-examples-streaming/src/test/java/org/apache/flink/streaming/test/exampleJavaPrograms/iteration/IterateExampleITCase.java b/flink-examples/flink-examples-streaming/src/test/java/org/apache/flink/streaming/test/exampleJavaPrograms/iteration/IterateExampleITCase.java
index 07d6766..d6e3538 100644
--- a/flink-examples/flink-examples-streaming/src/test/java/org/apache/flink/streaming/test/exampleJavaPrograms/iteration/IterateExampleITCase.java
+++ b/flink-examples/flink-examples-streaming/src/test/java/org/apache/flink/streaming/test/exampleJavaPrograms/iteration/IterateExampleITCase.java
@@ -35,7 +35,9 @@ public class IterateExampleITCase extends StreamingProgramTestBase {
@Override
protected void postSubmit() throws Exception {
- compareResultsByLinesInMemory(IterateExampleData.RESULTS, resultPath);
+ // the example is inherently non-deterministic. The iteration timeout of 5000 ms
+ // is frequently not enough to make the test run stable on CI infrastructure
+ // with very small containers, so we cannot do a validation here
}
@Override
http://git-wip-us.apache.org/repos/asf/flink/blob/bfff86c8/flink-examples/flink-examples-streaming/src/test/resources/log4j-test.properties
----------------------------------------------------------------------
diff --git a/flink-examples/flink-examples-streaming/src/test/resources/log4j-test.properties b/flink-examples/flink-examples-streaming/src/test/resources/log4j-test.properties
new file mode 100644
index 0000000..555f17e
--- /dev/null
+++ b/flink-examples/flink-examples-streaming/src/test/resources/log4j-test.properties
@@ -0,0 +1,23 @@
+################################################################################
+# 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.
+################################################################################
+
+log4j.rootLogger=OFF, console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n
\ No newline at end of file
[26/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java
deleted file mode 100644
index 70da5bb..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple17.java
+++ /dev/null
@@ -1,394 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 17 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- */
-public class Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple17() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- */
- public Tuple17(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- }
-
- @Override
- public int getArity() { return 17; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple17)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple17 tuple = (Tuple17) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> copy(){
- return new Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16) {
- return new Tuple17<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java
deleted file mode 100644
index c221ee6..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple18.java
+++ /dev/null
@@ -1,409 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 18 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- */
-public class Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple18() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- */
- public Tuple18(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- }
-
- @Override
- public int getArity() { return 18; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple18)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple18 tuple = (Tuple18) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> copy(){
- return new Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17) {
- return new Tuple18<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java
deleted file mode 100644
index 3d4d262..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple19.java
+++ /dev/null
@@ -1,424 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 19 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- */
-public class Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple19() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- */
- public Tuple19(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- }
-
- @Override
- public int getArity() { return 19; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple19)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple19 tuple = (Tuple19) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> copy(){
- return new Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18) {
- return new Tuple19<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java
deleted file mode 100644
index 4ec930c..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple2.java
+++ /dev/null
@@ -1,177 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 2 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- */
-public class Tuple2<T0, T1> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple2() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- */
- public Tuple2(T0 value0, T1 value1) {
- this.f0 = value0;
- this.f1 = value1;
- }
-
- @Override
- public int getArity() { return 2; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- */
- public void setFields(T0 value0, T1 value1) {
- this.f0 = value0;
- this.f1 = value1;
- }
-
- /**
- * Returns a shallow copy of the tuple with swapped values.
- *
- * @return shallow copy of the tuple with swapped values
- */
- public Tuple2<T1, T0> swap() {
- return new Tuple2<T1, T0>(f1, f0);
- }
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple2)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple2 tuple = (Tuple2) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple2<T0,T1> copy(){
- return new Tuple2<T0,T1>(this.f0,
- this.f1);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1> Tuple2<T0,T1> of(T0 value0, T1 value1) {
- return new Tuple2<T0,T1>(value0, value1);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java
deleted file mode 100644
index 8116121..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple20.java
+++ /dev/null
@@ -1,439 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 20 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- * @param <T19> The type of field 19
- */
-public class Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
- /** Field 19 of the tuple. */
- public T19 f19;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple20() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- */
- public Tuple20(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- }
-
- @Override
- public int getArity() { return 20; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- case 19: return (T) this.f19;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- case 19:
- this.f19 = (T19) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + "," + StringUtils.arrayAwareToString(this.f19)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple20)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple20 tuple = (Tuple20) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- result = 31 * result + (f19 != null ? f19.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> copy(){
- return new Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18,
- this.f19);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19) {
- return new Tuple20<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java
deleted file mode 100644
index 6a1aeab..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple21.java
+++ /dev/null
@@ -1,454 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 21 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- * @param <T19> The type of field 19
- * @param <T20> The type of field 20
- */
-public class Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
- /** Field 19 of the tuple. */
- public T19 f19;
- /** Field 20 of the tuple. */
- public T20 f20;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple21() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- */
- public Tuple21(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- }
-
- @Override
- public int getArity() { return 21; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- case 19: return (T) this.f19;
- case 20: return (T) this.f20;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- case 19:
- this.f19 = (T19) value;
- break;
- case 20:
- this.f20 = (T20) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + "," + StringUtils.arrayAwareToString(this.f19)
- + "," + StringUtils.arrayAwareToString(this.f20)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple21)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple21 tuple = (Tuple21) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
- if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- result = 31 * result + (f19 != null ? f19.hashCode() : 0);
- result = 31 * result + (f20 != null ? f20.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> copy(){
- return new Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18,
- this.f19,
- this.f20);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20) {
- return new Tuple21<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20);
- }
-}
[33/38] flink git commit: [FLINK-3049] [api breaking] Move 'Either'
type to 'flink-core / org.apache.flink.types'
Posted by se...@apache.org.
[FLINK-3049] [api breaking] Move 'Either' type to 'flink-core / org.apache.flink.types'
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/54743866
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/54743866
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/54743866
Branch: refs/heads/master
Commit: 54743866e86cbe7689ae1dcf001deb559629747b
Parents: 360f02b
Author: Stephan Ewen <se...@apache.org>
Authored: Sun Jan 31 23:27:36 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 16:55:44 2016 +0100
----------------------------------------------------------------------
.../java/org/apache/flink/types/Either.java | 185 +++++++++++++++++++
1 file changed, 185 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/54743866/flink-core/src/main/java/org/apache/flink/types/Either.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/Either.java b/flink-core/src/main/java/org/apache/flink/types/Either.java
new file mode 100644
index 0000000..361802b
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/types/Either.java
@@ -0,0 +1,185 @@
+/*
+ * 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.types;
+
+/**
+ * This type represents a value of one two possible types, Left or Right (a
+ * disjoint union), inspired by Scala's Either type.
+ *
+ * @param <L>
+ * the type of Left
+ * @param <R>
+ * the type of Right
+ */
+public abstract class Either<L, R> {
+
+ /**
+ * Create a Left value of Either
+ */
+ public static <L, R> Either<L, R> Left(L value) {
+ return new Left<L, R>(value);
+ }
+
+ /**
+ * Create a Right value of Either
+ */
+ public static <L, R> Either<L, R> Right(R value) {
+ return new Right<L, R>(value);
+ }
+
+ /**
+ * Retrieve the Left value of Either.
+ *
+ * @return the Left value
+ * @throws IllegalStateException
+ * if called on a Right
+ */
+ public abstract L left() throws IllegalStateException;
+
+ /**
+ * Retrieve the Right value of Either.
+ *
+ * @return the Right value
+ * @throws IllegalStateException
+ * if called on a Left
+ */
+ public abstract R right() throws IllegalStateException;
+
+ /**
+ *
+ * @return true if this is a Left value, false if this is a Right value
+ */
+ public final boolean isLeft() {
+ return getClass() == Left.class;
+ }
+
+ /**
+ *
+ * @return true if this is a Right value, false if this is a Left value
+ */
+ public final boolean isRight() {
+ return getClass() == Right.class;
+ }
+
+ /**
+ * A left value of {@link Either}
+ *
+ * @param <L>
+ * the type of Left
+ * @param <R>
+ * the type of Right
+ */
+ public static class Left<L, R> extends Either<L, R> {
+ private final L value;
+
+ public Left(L value) {
+ this.value = java.util.Objects.requireNonNull(value);
+ }
+
+ @Override
+ public L left() {
+ return value;
+ }
+
+ @Override
+ public R right() {
+ throw new IllegalStateException("Cannot retrieve Right value on a Left");
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object instanceof Left<?, ?>) {
+ final Left<?, ?> other = (Left<?, ?>) object;
+ return value.equals(other.value);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Left(" + value.toString() + ")";
+ }
+
+ /**
+ * Creates a left value of {@link Either}
+ *
+ */
+ public static <L, R> Left<L, R> of(L left) {
+ return new Left<L, R>(left);
+ }
+ }
+
+ /**
+ * A right value of {@link Either}
+ *
+ * @param <L>
+ * the type of Left
+ * @param <R>
+ * the type of Right
+ */
+ public static class Right<L, R> extends Either<L, R> {
+ private final R value;
+
+ public Right(R value) {
+ this.value = java.util.Objects.requireNonNull(value);
+ }
+
+ @Override
+ public L left() {
+ throw new IllegalStateException("Cannot retrieve Left value on a Right");
+ }
+
+ @Override
+ public R right() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object instanceof Right<?, ?>) {
+ final Right<?, ?> other = (Right<?, ?>) object;
+ return value.equals(other.value);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Right(" + value.toString() + ")";
+ }
+
+ /**
+ * Creates a right value of {@link Either}
+ *
+ */
+ public static <L, R> Right<L, R> of(R right) {
+ return new Right<L, R>(right);
+ }
+ }
+}
[15/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java
new file mode 100644
index 0000000..4a579c8
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/ValueTypeInfoTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.types.Record;
+import org.apache.flink.types.Value;
+import org.apache.flink.util.TestLogger;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.*;
+
+public class ValueTypeInfoTest extends TestLogger {
+
+ public static class TestClass implements Value {
+ private static final long serialVersionUID = -492760806806568285L;
+
+ @Override
+ public void write(DataOutputView out) throws IOException {
+
+ }
+
+ @Override
+ public void read(DataInputView in) throws IOException {
+
+ }
+ }
+
+ public static class AlternativeClass implements Value {
+
+ private static final long serialVersionUID = -163437084575260172L;
+
+ @Override
+ public void write(DataOutputView out) throws IOException {
+
+ }
+
+ @Override
+ public void read(DataInputView in) throws IOException {
+
+ }
+ }
+
+ @Test
+ public void testValueTypeInfoEquality() {
+ ValueTypeInfo<TestClass> tpeInfo1 = new ValueTypeInfo<>(TestClass.class);
+ ValueTypeInfo<TestClass> tpeInfo2 = new ValueTypeInfo<>(TestClass.class);
+
+ assertEquals(tpeInfo1, tpeInfo2);
+ assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
+ }
+
+ @Test
+ public void testValueTyepInfoInequality() {
+ ValueTypeInfo<TestClass> tpeInfo1 = new ValueTypeInfo<>(TestClass.class);
+ ValueTypeInfo<AlternativeClass> tpeInfo2 = new ValueTypeInfo<>(AlternativeClass.class);
+
+ assertNotEquals(tpeInfo1, tpeInfo2);
+ }
+
+ @Test
+ public void testValueTypeEqualsWithNull() throws Exception {
+ ValueTypeInfo<Record> tpeInfo = new ValueTypeInfo<>(Record.class);
+
+ Assert.assertFalse(tpeInfo.equals(null));
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java
new file mode 100644
index 0000000..2ab0021
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/WritableTypeInfoTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.util.TestLogger;
+import org.apache.hadoop.io.Writable;
+import org.junit.Test;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import static org.junit.Assert.*;
+
+public class WritableTypeInfoTest extends TestLogger {
+
+ public static class TestClass implements Writable {
+ @Override
+ public void write(DataOutput dataOutput) throws IOException {
+
+ }
+
+ @Override
+ public void readFields(DataInput dataInput) throws IOException {
+
+ }
+ }
+
+ public static class AlternateClass implements Writable {
+ @Override
+ public void write(DataOutput dataOutput) throws IOException {
+
+ }
+
+ @Override
+ public void readFields(DataInput dataInput) throws IOException {
+
+ }
+ }
+
+
+ @Test
+ public void testWritableTypeInfoEquality() {
+ WritableTypeInfo<TestClass> tpeInfo1 = new WritableTypeInfo<>(TestClass.class);
+ WritableTypeInfo<TestClass> tpeInfo2 = new WritableTypeInfo<>(TestClass.class);
+
+ assertEquals(tpeInfo1, tpeInfo2);
+ assertEquals(tpeInfo1.hashCode(), tpeInfo2.hashCode());
+ }
+
+ @Test
+ public void testWritableTypeInfoInequality() {
+ WritableTypeInfo<TestClass> tpeInfo1 = new WritableTypeInfo<>(TestClass.class);
+ WritableTypeInfo<AlternateClass> tpeInfo2 = new WritableTypeInfo<>(AlternateClass.class);
+
+ assertNotEquals(tpeInfo1, tpeInfo2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java
new file mode 100644
index 0000000..307a3d2
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericArraySerializerTest.java
@@ -0,0 +1,187 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Random;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.GenericArraySerializer;
+import org.apache.flink.api.common.typeutils.base.StringSerializer;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.Book;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.BookAuthor;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject1;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject2;
+import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.SimpleTypes;
+import org.apache.flink.util.StringUtils;
+
+public abstract class AbstractGenericArraySerializerTest {
+
+ private final Random rnd = new Random(349712539451944123L);
+
+
+ @Test
+ public void testString() {
+ String[] arr1 = new String[] {"abc", "",
+ StringUtils.getRandomString(new Random(289347567856686223L), 10, 100),
+ StringUtils.getRandomString(new Random(289347567856686223L), 15, 50),
+ StringUtils.getRandomString(new Random(289347567856686223L), 30, 170),
+ StringUtils.getRandomString(new Random(289347567856686223L), 14, 15),
+ ""};
+
+ String[] arr2 = new String[] {"foo", "",
+ StringUtils.getRandomString(new Random(289347567856686223L), 10, 100),
+ StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000),
+ StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000),
+ StringUtils.getRandomString(new Random(289347567856686223L), 100*1024, 105*1024),
+ "bar"};
+
+ // run tests with the string serializer as the component serializer
+ runTests(String.class, new StringSerializer(), arr1, arr2);
+
+ // run the tests with the generic serializer as the component serializer
+ runTests(arr1, arr2);
+ }
+
+ @Test
+ public void testSimpleTypesObjects() {
+ SimpleTypes a = new SimpleTypes();
+ SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+
+ runTests(new SimpleTypes[] {a, b, c}, new SimpleTypes[] {d, e, f, g});
+ }
+
+ @Test
+ public void testCompositeObject() {
+ ComplexNestedObject1 o1 = new ComplexNestedObject1(5626435);
+ ComplexNestedObject1 o2 = new ComplexNestedObject1(76923);
+ ComplexNestedObject1 o3 = new ComplexNestedObject1(-1100);
+ ComplexNestedObject1 o4 = new ComplexNestedObject1(0);
+ ComplexNestedObject1 o5 = new ComplexNestedObject1(44);
+
+ runTests(new ComplexNestedObject1[] {o1, o2}, new ComplexNestedObject1[] {o3}, new ComplexNestedObject1[] {o4, o5});
+ }
+
+ @Test
+ public void testNestedObjects() {
+ ComplexNestedObject2 o1 = new ComplexNestedObject2(rnd);
+ ComplexNestedObject2 o2 = new ComplexNestedObject2();
+ ComplexNestedObject2 o3 = new ComplexNestedObject2(rnd);
+ ComplexNestedObject2 o4 = new ComplexNestedObject2(rnd);
+
+ runTests( new ComplexNestedObject2[] {o1, o2, o3},
+ new ComplexNestedObject2[] {},
+ new ComplexNestedObject2[] {},
+ new ComplexNestedObject2[] {o4},
+ new ComplexNestedObject2[] {});
+ }
+
+ @Test
+ public void testBeanStyleObjects() {
+ {
+ Book b1 = new Book(976243875L, "The Serialization Odysse", 42);
+ Book b2 = new Book(0L, "Debugging byte streams", 1337);
+ Book b3 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
+ Book b4 = new Book(Long.MAX_VALUE, "The joy of bits and bytes", 0xDEADBEEF);
+ Book b5 = new Book(Long.MIN_VALUE, "Winnign a prize for creative test strings", 0xBADF00);
+ Book b6 = new Book(-2L, "Distributed Systems", 0xABCDEF0123456789L);
+
+ runTests( new Book[] {b1, b2},
+ new Book[] {},
+ new Book[] {},
+ new Book[] {},
+ new Book[] {},
+ new Book[] {b3, b4, b5, b6});
+ }
+
+ // object with collection
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ list.add("A");
+ list.add("B");
+ list.add("C");
+ list.add("D");
+ list.add("E");
+
+ BookAuthor b1 = new BookAuthor(976243875L, list, "Arno Nym");
+
+ ArrayList<String> list2 = new ArrayList<String>();
+ BookAuthor b2 = new BookAuthor(987654321L, list2, "The Saurus");
+
+ runTests(new BookAuthor[] {b1, b2});
+ }
+ }
+
+ @SafeVarargs
+ private final <T> void runTests(T[]... instances) {
+ try {
+ @SuppressWarnings("unchecked")
+ Class<T> type = (Class<T>) instances[0][0].getClass();
+ TypeSerializer<T> serializer = createComponentSerializer(type);
+ runTests(type, serializer, instances);
+ }
+ catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @SafeVarargs
+ private final <T> void runTests(Class<T> type, TypeSerializer<T> componentSerializer, T[]... instances) {
+ try {
+ if (type == null || componentSerializer == null || instances == null || instances.length == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ @SuppressWarnings("unchecked")
+ Class<T[]> arrayClass = (Class<T[]>) (Class<?>) Array.newInstance(type, 0).getClass();
+
+ GenericArraySerializer<T> serializer = createSerializer(type, componentSerializer);
+ SerializerTestInstance<T[]> test = new SerializerTestInstance<T[]>(serializer, arrayClass, -1, instances);
+ test.testAll();
+ }
+ catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ private <T> GenericArraySerializer<T> createSerializer(Class<T> type, TypeSerializer<T> componentSerializer) {
+ return new GenericArraySerializer<T>(type, componentSerializer);
+ }
+
+ abstract protected <T> TypeSerializer<T> createComponentSerializer(Class<T> type);
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java
new file mode 100644
index 0000000..ef168d8
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeComparatorTest.java
@@ -0,0 +1,376 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+abstract public class AbstractGenericTypeComparatorTest {
+
+ @Test
+ public void testString() {
+ runTests(new String[]{
+ "",
+ "Lorem Ipsum Dolor Omit Longer",
+ "aaaa",
+ "abcd",
+ "abce",
+ "abdd",
+ "accd",
+ "bbcd"
+ });
+ }
+
+ @Test
+ public void testSimpleTypesObjects() {
+ runTests(
+ new SimpleTypes(0, 1, (byte) 2, "", (short) 3, 4.0),
+ new SimpleTypes(1, 1, (byte) 2, "", (short) 3, 4.0),
+ new SimpleTypes(1, 2, (byte) 2, "", (short) 3, 4.0),
+ new SimpleTypes(1, 2, (byte) 3, "", (short) 3, 4.0),
+ new SimpleTypes(1, 2, (byte) 3, "a", (short) 3, 4.0),
+ new SimpleTypes(1, 2, (byte) 3, "b", (short) 3, 4.0),
+ new SimpleTypes(1, 2, (byte) 3, "b", (short) 4, 4.0),
+ new SimpleTypes(1, 2, (byte) 3, "b", (short) 4, 6.0)
+ );
+ }
+
+ @Test
+ public void testCompositeObject() {
+ ComplexNestedObject1 o1 = new ComplexNestedObject1(-1100);
+ ComplexNestedObject1 o2 = new ComplexNestedObject1(0);
+ ComplexNestedObject1 o3 = new ComplexNestedObject1(44);
+ ComplexNestedObject1 o4 = new ComplexNestedObject1(76923, "A");
+ ComplexNestedObject1 o5 = new ComplexNestedObject1(5626435, "A somewhat random collection");
+
+ runTests(o1, o2, o3, o4, o5);
+ }
+
+ @Test
+ public void testBeanStyleObjects() {
+ {
+ Book b111 = new Book(-1L, "A Low level interfaces", 0xC);
+ Book b122 = new Book(-1L, "Low level interfaces", 0xC);
+ Book b123 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
+
+ Book b2 = new Book(0L, "Debugging byte streams", 1337);
+ Book b3 = new Book(976243875L, "The Serialization Odysse", 42);
+
+ runTests(b111, b122, b123, b2, b3);
+ }
+
+ {
+ BookAuthor b1 = new BookAuthor(976243875L, new ArrayList<String>(), "Arno Nym");
+
+ ArrayList<String> list = new ArrayList<String>();
+ list.add("A");
+ list.add("B");
+ list.add("C");
+ list.add("D");
+ list.add("E");
+
+ BookAuthor b2 = new BookAuthor(976243875L, list, "The Saurus");
+
+ runTests(b1, b2);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ private <T> void runTests(T... sortedTestData) {
+ ComparatorTestInstance<T> testBase = new ComparatorTestInstance<T>(sortedTestData);
+ testBase.testAll();
+ }
+
+ abstract protected <T> TypeSerializer<T> createSerializer(Class<T> type);
+
+ // ------------------------------------------------------------------------
+ // test instance
+ // ------------------------------------------------------------------------
+
+ private class ComparatorTestInstance<T> extends ComparatorTestBase<T> {
+
+ private final T[] testData;
+
+ private final Class<T> type;
+
+ @SuppressWarnings("unchecked")
+ public ComparatorTestInstance(T[] testData) {
+ if (testData == null || testData.length == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ this.testData = testData;
+ this.type = (Class<T>) testData[0].getClass();
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ protected TypeComparator<T> createComparator(boolean ascending) {
+ return new GenericTypeComparator(ascending, AbstractGenericTypeComparatorTest.this.createSerializer(this
+ .type), this.type);
+ }
+
+ @Override
+ protected TypeSerializer<T> createSerializer() {
+ return AbstractGenericTypeComparatorTest.this.createSerializer(this.type);
+ }
+
+ @Override
+ protected T[] getSortedTestData() {
+ return this.testData;
+ }
+
+ public void testAll() {
+ testDuplicate();
+ testEquality();
+ testEqualityWithReference();
+ testInequality();
+ testInequalityWithReference();
+ testNormalizedKeysEqualsFullLength();
+ testNormalizedKeysEqualsHalfLength();
+ testNormalizedKeysGreatSmallFullLength();
+ testNormalizedKeysGreatSmallAscDescHalfLength();
+ testNormalizedKeyReadWriter();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // test objects
+ // ------------------------------------------------------------------------
+
+ public static final class SimpleTypes implements Comparable<SimpleTypes> {
+
+ private final int iVal;
+ private final long lVal;
+ private final byte bVal;
+ private final String sVal;
+ private final short rVal;
+ private final double dVal;
+
+ public SimpleTypes() {
+ this(0, 0, (byte) 0, "", (short) 0, 0);
+ }
+
+ public SimpleTypes(int iVal, long lVal, byte bVal, String sVal, short rVal, double dVal) {
+ this.iVal = iVal;
+ this.lVal = lVal;
+ this.bVal = bVal;
+ this.sVal = sVal;
+ this.rVal = rVal;
+ this.dVal = dVal;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("(%d, %d, %d, %s, %d, %f)", iVal, lVal, bVal, sVal, rVal, dVal);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == SimpleTypes.class) {
+ SimpleTypes other = (SimpleTypes) obj;
+
+ return other.iVal == this.iVal &&
+ other.lVal == this.lVal &&
+ other.bVal == this.bVal &&
+ other.sVal.equals(this.sVal) &&
+ other.rVal == this.rVal &&
+ other.dVal == this.dVal;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(SimpleTypes o) {
+ int cmp = (this.iVal < o.iVal ? -1 : (this.iVal == o.iVal ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = (this.lVal < o.lVal ? -1 : (this.lVal == o.lVal ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = (this.bVal < o.bVal ? -1 : (this.bVal == o.bVal ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = this.sVal.compareTo(o.sVal);
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = (this.rVal < o.rVal ? -1 : (this.rVal == o.rVal ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ return (this.dVal < o.dVal ? -1 : (this.dVal == o.dVal ? 0 : 1));
+ }
+ }
+
+ public static class ComplexNestedObject1 implements Comparable<ComplexNestedObject1> {
+
+ private double doubleValue;
+
+ private List<String> stringList;
+
+ public ComplexNestedObject1() {
+ }
+
+ public ComplexNestedObject1(double value, String... listElements) {
+ this.doubleValue = value;
+
+ this.stringList = new ArrayList<String>();
+ for (String str : listElements) {
+ this.stringList.add(str);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == ComplexNestedObject1.class) {
+ ComplexNestedObject1 other = (ComplexNestedObject1) obj;
+ return other.doubleValue == this.doubleValue && this.stringList.equals(other.stringList);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(ComplexNestedObject1 o) {
+ int cmp = (this.doubleValue < o.doubleValue ? -1 : (this.doubleValue == o.doubleValue ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ int size = this.stringList.size();
+ int otherSize = o.stringList.size();
+
+ cmp = (size < otherSize ? -1 : (size == otherSize ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ for (int i = 0; i < size; i++) {
+ cmp = this.stringList.get(i).compareTo(o.stringList.get(i));
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+
+ return 0;
+ }
+ }
+
+ public static class Book implements Comparable<Book> {
+
+ private long bookId;
+ private String title;
+ private long authorId;
+
+ public Book() {
+ }
+
+ public Book(long bookId, String title, long authorId) {
+ this.bookId = bookId;
+ this.title = title;
+ this.authorId = authorId;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == Book.class) {
+ Book other = (Book) obj;
+ return other.bookId == this.bookId && other.authorId == this.authorId && this.title.equals(other.title);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(Book o) {
+ int cmp = (this.bookId < o.bookId ? -1 : (this.bookId == o.bookId ? 0 : 1));
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ cmp = title.compareTo(o.title);
+ if (cmp != 0) {
+ return cmp;
+ }
+
+ return (this.authorId < o.authorId ? -1 : (this.authorId == o.authorId ? 0 : 1));
+ }
+ }
+
+ public static class BookAuthor implements Comparable<BookAuthor> {
+
+ private long authorId;
+ private List<String> bookTitles;
+ private String authorName;
+
+ public BookAuthor() {
+ }
+
+ public BookAuthor(long authorId, List<String> bookTitles, String authorName) {
+ this.authorId = authorId;
+ this.bookTitles = bookTitles;
+ this.authorName = authorName;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == BookAuthor.class) {
+ BookAuthor other = (BookAuthor) obj;
+ return other.authorName.equals(this.authorName) && other.authorId == this.authorId &&
+ other.bookTitles.equals(this.bookTitles);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(BookAuthor o) {
+ int cmp = (this.authorId < o.authorId ? -1 : (this.authorId == o.authorId ? 0 : 1));
+ if (cmp != 0) return cmp;
+
+ int size = this.bookTitles.size();
+ int oSize = o.bookTitles.size();
+ cmp = (size < oSize ? -1 : (size == oSize ? 0 : 1));
+ if (cmp != 0) return cmp;
+
+ for (int i = 0; i < size; i++) {
+ cmp = this.bookTitles.get(i).compareTo(o.bookTitles.get(i));
+ if (cmp != 0) return cmp;
+ }
+
+ return this.authorName.compareTo(o.authorName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java
new file mode 100644
index 0000000..059c78d
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AbstractGenericTypeSerializerTest.java
@@ -0,0 +1,364 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.util.StringUtils;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * A test for the {@link AvroSerializer}.
+ */
+abstract public class AbstractGenericTypeSerializerTest {
+
+ private final Random rnd = new Random(349712539451944123L);
+
+ @Test
+ public void testString() {
+ runTests("abc", "",
+ StringUtils.getRandomString(new Random(289347567856686223L), 10, 100),
+ StringUtils.getRandomString(new Random(289347567856686223L), 1000, 5000),
+ StringUtils.getRandomString(new Random(289347567856686223L), 30000, 35000),
+ StringUtils.getRandomString(new Random(289347567856686223L), 100 * 1024, 105 * 1024));
+ }
+
+ @Test
+ public void testSimpleTypesObjects() {
+ SimpleTypes a = new SimpleTypes();
+ SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+ SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
+ StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
+
+ runTests(a, b, c, d, e, f, g);
+ }
+
+ @Test
+ public void testCompositeObject() {
+ ComplexNestedObject1 o1 = new ComplexNestedObject1(5626435);
+ ComplexNestedObject1 o2 = new ComplexNestedObject1(76923);
+ ComplexNestedObject1 o3 = new ComplexNestedObject1(-1100);
+ ComplexNestedObject1 o4 = new ComplexNestedObject1(0);
+ ComplexNestedObject1 o5 = new ComplexNestedObject1(44);
+
+ runTests(o1, o2, o3, o4, o5);
+ }
+
+ @Test
+ public void testNestedObjects() {
+ ComplexNestedObject2 o1 = new ComplexNestedObject2(rnd);
+ ComplexNestedObject2 o2 = new ComplexNestedObject2();
+ ComplexNestedObject2 o3 = new ComplexNestedObject2(rnd);
+ ComplexNestedObject2 o4 = new ComplexNestedObject2(rnd);
+
+ runTests(o1, o2, o3, o4);
+ }
+
+ @Test
+ public void testBeanStyleObjects() {
+ {
+ Book b1 = new Book(976243875L, "The Serialization Odysse", 42);
+ Book b2 = new Book(0L, "Debugging byte streams", 1337);
+ Book b3 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
+
+ runTests(b1, b2, b3);
+ }
+
+ // object with collection
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ list.add("A");
+ list.add("B");
+ list.add("C");
+ list.add("D");
+ list.add("E");
+
+ BookAuthor b1 = new BookAuthor(976243875L, list, "Arno Nym");
+
+ ArrayList<String> list2 = new ArrayList<String>();
+ BookAuthor b2 = new BookAuthor(987654321L, list2, "The Saurus");
+
+ runTests(b1, b2);
+ }
+ }
+
+ @Test
+ public void testNestedInterfaces() {
+ {
+
+ SimpleWithNestedInterfaces s1 = new SimpleWithNestedInterfaces("Hello", 1);
+ SimpleWithNestedInterfaces s2 = new SimpleWithNestedInterfaces("Ciao", 2);
+ SimpleWithNestedInterfaces s3 = new SimpleWithNestedInterfaces("Foo", 3);
+
+ runTests(s1, s2, s3);
+ }
+
+ // object with collection
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ list.add("A");
+ list.add("B");
+ list.add("C");
+ list.add("D");
+ list.add("E");
+
+ BookAuthor b1 = new BookAuthor(976243875L, list, "Arno Nym");
+
+ ArrayList<String> list2 = new ArrayList<String>();
+ BookAuthor b2 = new BookAuthor(987654321L, list2, "The Saurus");
+
+ runTests(b1, b2);
+ }
+ }
+
+ protected final <T> void runTests(T... instances) {
+ if (instances == null || instances.length == 0) {
+ throw new IllegalArgumentException();
+ }
+
+ @SuppressWarnings("unchecked")
+ Class<T> clazz = (Class<T>) instances[0].getClass();
+
+ TypeSerializer<T> serializer = createSerializer(clazz);
+ SerializerTestInstance<T> test = new SerializerTestInstance<T>(serializer, clazz, -1, instances);
+ test.testAll();
+ }
+
+ abstract protected <T> TypeSerializer<T> createSerializer(Class<T> type);
+
+
+ // --------------------------------------------------------------------------------------------
+ // Test Objects
+ // --------------------------------------------------------------------------------------------
+
+ public static final class SimpleWithNestedInterfaces {
+ Map<String, Integer> map1;
+ List<String> list;
+
+ public SimpleWithNestedInterfaces() {
+ map1 = new HashMap<String, Integer>();
+ list = new ArrayList<String>();
+ }
+
+
+ public SimpleWithNestedInterfaces(String str, Integer i) {
+ map1 = new HashMap<String, Integer>();
+ map1.put(str, i);
+ list = new ArrayList<String>();
+ list.add(str);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) { return true; }
+ if (o == null || getClass() != o.getClass()) { return false; }
+
+ SimpleWithNestedInterfaces that = (SimpleWithNestedInterfaces) o;
+
+ if (!list.equals(that.list)) { return false; }
+ if (!map1.equals(that.map1)) { return false; }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = map1.hashCode();
+ result = 31 * result + list.hashCode();
+ return result;
+ }
+ }
+
+ public static final class SimpleTypes {
+
+ private final int iVal;
+ private final long lVal;
+ private final byte bVal;
+ private final String sVal;
+ private final short rVal;
+ private final double dVal;
+
+
+ public SimpleTypes() {
+ this(0, 0, (byte) 0, "", (short) 0, 0);
+ }
+
+ public SimpleTypes(int iVal, long lVal, byte bVal, String sVal, short rVal, double dVal) {
+ this.iVal = iVal;
+ this.lVal = lVal;
+ this.bVal = bVal;
+ this.sVal = sVal;
+ this.rVal = rVal;
+ this.dVal = dVal;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == SimpleTypes.class) {
+ SimpleTypes other = (SimpleTypes) obj;
+
+ return other.iVal == this.iVal &&
+ other.lVal == this.lVal &&
+ other.bVal == this.bVal &&
+ other.sVal.equals(this.sVal) &&
+ other.rVal == this.rVal &&
+ other.dVal == this.dVal;
+
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("(%d, %d, %d, %s, %d, %f)", iVal, lVal, bVal, sVal, rVal, dVal);
+ }
+ }
+
+ public static class ComplexNestedObject1 {
+
+ private double doubleValue;
+
+ private List<String> stringList;
+
+ public ComplexNestedObject1() {
+ }
+
+ public ComplexNestedObject1(int offInit) {
+ this.doubleValue = 6293485.6723 + offInit;
+
+ this.stringList = new ArrayList<String>();
+ this.stringList.add("A" + offInit);
+ this.stringList.add("somewhat" + offInit);
+ this.stringList.add("random" + offInit);
+ this.stringList.add("collection" + offInit);
+ this.stringList.add("of" + offInit);
+ this.stringList.add("strings" + offInit);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == ComplexNestedObject1.class) {
+ ComplexNestedObject1 other = (ComplexNestedObject1) obj;
+ return other.doubleValue == this.doubleValue && this.stringList.equals(other.stringList);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public static class ComplexNestedObject2 {
+
+ private long longValue;
+
+ private Map<String, ComplexNestedObject1> theMap = new HashMap<String, ComplexNestedObject1>();
+
+ public ComplexNestedObject2() {
+ }
+
+ public ComplexNestedObject2(Random rnd) {
+ this.longValue = rnd.nextLong();
+
+ this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
+ this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
+ this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
+ this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
+ this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
+ this.theMap.put(String.valueOf(rnd.nextLong()), new ComplexNestedObject1(rnd.nextInt()));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == ComplexNestedObject2.class) {
+ ComplexNestedObject2 other = (ComplexNestedObject2) obj;
+ return other.longValue == this.longValue && this.theMap.equals(other.theMap);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public static class Book {
+
+ private long bookId;
+ private String title;
+ private long authorId;
+
+ public Book() {
+ }
+
+ public Book(long bookId, String title, long authorId) {
+ this.bookId = bookId;
+ this.title = title;
+ this.authorId = authorId;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == Book.class) {
+ Book other = (Book) obj;
+ return other.bookId == this.bookId && other.authorId == this.authorId && this.title.equals(other.title);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public static class BookAuthor {
+
+ private long authorId;
+ private List<String> bookTitles;
+ private String authorName;
+
+ public BookAuthor() {
+ }
+
+ public BookAuthor(long authorId, List<String> bookTitles, String authorName) {
+ this.authorId = authorId;
+ this.bookTitles = bookTitles;
+ this.authorName = authorName;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj.getClass() == BookAuthor.class) {
+ BookAuthor other = (BookAuthor) obj;
+ return other.authorName.equals(this.authorName) && other.authorId == this.authorId &&
+ other.bookTitles.equals(this.bookTitles);
+ } else {
+ return false;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java
new file mode 100644
index 0000000..5b08e52
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericArraySerializerTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+public class AvroGenericArraySerializerTest extends AbstractGenericArraySerializerTest {
+ @Override
+ protected <T> TypeSerializer<T> createComponentSerializer(Class<T> type) {
+ return new AvroSerializer<T>(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java
new file mode 100644
index 0000000..19fac43
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+public class AvroGenericTypeComparatorTest extends AbstractGenericTypeComparatorTest {
+ @Override
+ protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
+ return new AvroSerializer<T>(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java
new file mode 100644
index 0000000..df1ff60
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java
@@ -0,0 +1,29 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+public class AvroGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
+
+ @Override
+ protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
+ return new AvroSerializer<T>(type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java
new file mode 100644
index 0000000..8a89410
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java
@@ -0,0 +1,189 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.avro.reflect.Nullable;
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.junit.Test;
+
+public class AvroSerializerEmptyArrayTest {
+
+ @Test
+ public void testBookSerialization() {
+ try {
+ Book b = new Book(123, "This is a test book", 26382648);
+ AvroSerializer<Book> serializer = new AvroSerializer<Book>(Book.class);
+ SerializerTestInstance<Book> test = new SerializerTestInstance<Book>(serializer, Book.class, -1, b);
+ test.testAll();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSerialization() {
+ try {
+ List<String> titles = new ArrayList<String>();
+
+ List<Book> books = new ArrayList<Book>();
+ books.add(new Book(123, "This is a test book", 1));
+ books.add(new Book(24234234, "This is a test book", 1));
+ books.add(new Book(1234324, "This is a test book", 3));
+
+ BookAuthor a = new BookAuthor(1, titles, "Test Author");
+ a.books = books;
+ a.bookType = BookAuthor.BookType.journal;
+
+ AvroSerializer<BookAuthor> serializer = new AvroSerializer<BookAuthor>(BookAuthor.class);
+
+ SerializerTestInstance<BookAuthor> test = new SerializerTestInstance<BookAuthor>(serializer, BookAuthor.class, -1, a);
+ test.testAll();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ public static class Book {
+
+ long bookId;
+ @Nullable
+ String title;
+ long authorId;
+
+ public Book() {}
+
+ public Book(long bookId, String title, long authorId) {
+ this.bookId = bookId;
+ this.title = title;
+ this.authorId = authorId;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (authorId ^ (authorId >>> 32));
+ result = prime * result + (int) (bookId ^ (bookId >>> 32));
+ result = prime * result + ((title == null) ? 0 : title.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Book other = (Book) obj;
+ if (authorId != other.authorId)
+ return false;
+ if (bookId != other.bookId)
+ return false;
+ if (title == null) {
+ if (other.title != null)
+ return false;
+ } else if (!title.equals(other.title))
+ return false;
+ return true;
+ }
+ }
+
+ public static class BookAuthor {
+
+ enum BookType {
+ book,
+ article,
+ journal
+ }
+
+ long authorId;
+
+ @Nullable
+ List<String> bookTitles;
+
+ @Nullable
+ List<Book> books;
+
+ String authorName;
+
+ BookType bookType;
+
+ public BookAuthor() {}
+
+ public BookAuthor(long authorId, List<String> bookTitles, String authorName) {
+ this.authorId = authorId;
+ this.bookTitles = bookTitles;
+ this.authorName = authorName;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (authorId ^ (authorId >>> 32));
+ result = prime * result + ((authorName == null) ? 0 : authorName.hashCode());
+ result = prime * result + ((bookTitles == null) ? 0 : bookTitles.hashCode());
+ result = prime * result + ((bookType == null) ? 0 : bookType.hashCode());
+ result = prime * result + ((books == null) ? 0 : books.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BookAuthor other = (BookAuthor) obj;
+ if (authorId != other.authorId)
+ return false;
+ if (authorName == null) {
+ if (other.authorName != null)
+ return false;
+ } else if (!authorName.equals(other.authorName))
+ return false;
+ if (bookTitles == null) {
+ if (other.bookTitles != null)
+ return false;
+ } else if (!bookTitles.equals(other.bookTitles))
+ return false;
+ if (bookType != other.bookType)
+ return false;
+ if (books == null) {
+ if (other.books != null)
+ return false;
+ } else if (!books.equals(other.books))
+ return false;
+ return true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java
new file mode 100644
index 0000000..b317275
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.types.StringValue;
+
+public class CopyableValueComparatorTest extends ComparatorTestBase<StringValue> {
+
+ StringValue[] data = new StringValue[]{
+ new StringValue(""),
+ new StringValue("Lorem Ipsum Dolor Omit Longer"),
+ new StringValue("aaaa"),
+ new StringValue("abcd"),
+ new StringValue("abce"),
+ new StringValue("abdd"),
+ new StringValue("accd"),
+ new StringValue("bbcd")
+ };
+
+ @Override
+ protected TypeComparator<StringValue> createComparator(boolean ascending) {
+ return new CopyableValueComparator<StringValue>(ascending, StringValue.class);
+ }
+
+ @Override
+ protected TypeSerializer<StringValue> createSerializer() {
+ return new CopyableValueSerializer<StringValue>(StringValue.class);
+ }
+
+ @Override
+ protected StringValue[] getSortedTestData() {
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
new file mode 100644
index 0000000..d636d5e
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.apache.flink.types.Either.Left;
+import static org.apache.flink.types.Either.Right;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.types.Either;
+import org.apache.flink.api.java.typeutils.EitherTypeInfo;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.junit.Test;
+
+public class EitherSerializerTest {
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testStringDoubleEither() {
+
+ Either<String, Double>[] testData = new Either[] {
+ Left("banana"),
+ Left(""),
+ Right(32.0),
+ Right(Double.MIN_VALUE),
+ Right(Double.MAX_VALUE)};
+
+ EitherTypeInfo<String, Double> eitherTypeInfo = (EitherTypeInfo<String, Double>) new EitherTypeInfo<String, Double>(
+ BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO);
+ EitherSerializer<String, Double> eitherSerializer =
+ (EitherSerializer<String, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig());
+ SerializerTestInstance<Either<String, Double>> testInstance =
+ new EitherSerializerTestInstance<Either<String, Double>>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData);
+ testInstance.testAll();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testEitherWithTuple() {
+
+ Either<Tuple2<Long, Long>, Double>[] testData = new Either[] {
+ Either.Left(new Tuple2<>(2l, 9l)),
+ new Left<>(new Tuple2<>(Long.MIN_VALUE, Long.MAX_VALUE)),
+ new Right<>(32.0),
+ Right(Double.MIN_VALUE),
+ Right(Double.MAX_VALUE)};
+
+ EitherTypeInfo<Tuple2<Long, Long>, Double> eitherTypeInfo = (EitherTypeInfo<Tuple2<Long, Long>, Double>)
+ new EitherTypeInfo<Tuple2<Long, Long>, Double>(
+ new TupleTypeInfo<Tuple2<Long, Long>>(BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO),
+ BasicTypeInfo.DOUBLE_TYPE_INFO);
+ EitherSerializer<Tuple2<Long, Long>, Double> eitherSerializer =
+ (EitherSerializer<Tuple2<Long, Long>, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig());
+ SerializerTestInstance<Either<Tuple2<Long, Long>, Double>> testInstance =
+ new EitherSerializerTestInstance<Either<Tuple2<Long, Long>, Double>>(
+ eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData);
+ testInstance.testAll();
+ }
+
+ /**
+ * {@link org.apache.flink.api.common.typeutils.SerializerTestBase#testInstantiate()}
+ * checks that the type of the created instance is the same as the type class parameter.
+ * Since we arbitrarily create always create a Left instance we override this test.
+ */
+ private class EitherSerializerTestInstance<T> extends SerializerTestInstance<T> {
+
+ public EitherSerializerTestInstance(TypeSerializer<T> serializer,
+ Class<T> typeClass, int length, T[] testData) {
+ super(serializer, typeClass, length, testData);
+ }
+
+ @Override
+ @Test
+ public void testInstantiate() {
+ try {
+ TypeSerializer<T> serializer = getSerializer();
+
+ T instance = serializer.createInstance();
+ assertNotNull("The created instance must not be null.", instance);
+
+ Class<T> type = getTypeClass();
+ assertNotNull("The test is corrupt: type class is null.", type);
+ }
+ catch (Exception e) {
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ fail("Exception in test: " + e.getMessage());
+ }
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java
new file mode 100644
index 0000000..06330d3
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.GenericPairComparator;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.DoubleComparator;
+import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
+import org.apache.flink.api.common.typeutils.base.IntComparator;
+import org.apache.flink.api.common.typeutils.base.IntSerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.tuple.Tuple4;
+import org.apache.flink.api.java.typeutils.runtime.tuple.base.TuplePairComparatorTestBase;
+
+public class GenericPairComparatorTest extends TuplePairComparatorTestBase<Tuple3<Integer, String, Double>, Tuple4<Integer, Float, Long, Double>> {
+
+ @SuppressWarnings("unchecked")
+ private Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
+ new Tuple3<Integer, String, Double>(4, "hello", 20.0),
+ new Tuple3<Integer, String, Double>(4, "world", 23.2),
+ new Tuple3<Integer, String, Double>(5, "hello", 18.0),
+ new Tuple3<Integer, String, Double>(5, "world", 19.2),
+ new Tuple3<Integer, String, Double>(6, "hello", 16.0),
+ new Tuple3<Integer, String, Double>(6, "world", 17.2),
+ new Tuple3<Integer, String, Double>(7, "hello", 14.0),
+ new Tuple3<Integer, String, Double>(7, "world", 15.2)
+ };
+
+ @SuppressWarnings("unchecked")
+ private Tuple4<Integer, Float, Long, Double>[] dataIDL = new Tuple4[]{
+ new Tuple4<Integer, Float, Long, Double>(4, 0.11f, 14L, 20.0),
+ new Tuple4<Integer, Float, Long, Double>(4, 0.221f, 15L, 23.2),
+ new Tuple4<Integer, Float, Long, Double>(5, 0.33f, 15L, 18.0),
+ new Tuple4<Integer, Float, Long, Double>(5, 0.44f, 20L, 19.2),
+ new Tuple4<Integer, Float, Long, Double>(6, 0.55f, 20L, 16.0),
+ new Tuple4<Integer, Float, Long, Double>(6, 0.66f, 29L, 17.2),
+ new Tuple4<Integer, Float, Long, Double>(7, 0.77f, 29L, 14.0),
+ new Tuple4<Integer, Float, Long, Double>(7, 0.88f, 34L, 15.2)
+ };
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ protected GenericPairComparator<Tuple3<Integer, String, Double>, Tuple4<Integer, Float, Long, Double>> createComparator(boolean ascending) {
+ int[] fields1 = new int[]{0, 2};
+ int[] fields2 = new int[]{0, 3};
+ TypeComparator[] comps1 = new TypeComparator[]{
+ new IntComparator(ascending),
+ new DoubleComparator(ascending)
+ };
+ TypeComparator[] comps2 = new TypeComparator[]{
+ new IntComparator(ascending),
+ new DoubleComparator(ascending)
+ };
+ TypeSerializer[] sers1 = new TypeSerializer[]{
+ IntSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE
+ };
+ TypeSerializer[] sers2= new TypeSerializer[]{
+ IntSerializer.INSTANCE,
+ DoubleSerializer.INSTANCE
+ };
+ TypeComparator<Tuple3<Integer, String, Double>> comp1 = new TupleComparator<Tuple3<Integer, String, Double>>(fields1, comps1, sers1);
+ TypeComparator<Tuple4<Integer, Float, Long, Double>> comp2 = new TupleComparator<Tuple4<Integer, Float, Long, Double>>(fields2, comps2, sers2);
+ return new GenericPairComparator<Tuple3<Integer, String, Double>, Tuple4<Integer, Float, Long, Double>>(comp1, comp2);
+ }
+
+ @Override
+ protected Tuple2<Tuple3<Integer, String, Double>[], Tuple4<Integer, Float, Long, Double>[]> getSortedTestData() {
+ return new Tuple2<Tuple3<Integer, String, Double>[], Tuple4<Integer, Float, Long, Double>[]>(dataISD, dataIDL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java
new file mode 100644
index 0000000..1c97816
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.SerializerTestInstance;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.api.java.typeutils.TypeInfoParser;
+import org.junit.Test;
+
+
+/**
+ * A serialization test for multidimensional arrays.
+ */
+public class MultidimensionalArraySerializerTest {
+
+ @Test
+ public void testStringArray() {
+ String[][] array = new String[][]{{null,"b"},{"c","d"},{"e","f"},{"g","h"},null};
+ TypeInformation<String[][]> ti = TypeExtractor.getForClass(String[][].class);
+
+ SerializerTestInstance<String[][]> testInstance = new SerializerTestInstance<String[][]>(ti.createSerializer(new ExecutionConfig()), String[][].class, -1, array);
+ testInstance.testAll();
+ }
+
+ @Test
+ public void testPrimitiveArray() {
+ int[][] array = new int[][]{{12,1},{48,42},{23,80},{484,849},{987,4}};
+ TypeInformation<int[][]> ti = TypeExtractor.getForClass(int[][].class);
+
+ SerializerTestInstance<int[][]> testInstance = new SerializerTestInstance<int[][]>(ti.createSerializer(new ExecutionConfig()), int[][].class, -1, array);
+ testInstance.testAll();
+ }
+
+ public static class MyPojo {
+ public String field1;
+ public int field2;
+
+ public MyPojo(String field1, int field2) {
+ this.field1 = field1;
+ this.field2 = field2;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof MyPojo)) {
+ return false;
+ }
+ MyPojo other = (MyPojo) obj;
+ return ((field1 == null && other.field1 == null) || (field1 != null && field1.equals(other.field1)))
+ && field2 == other.field2;
+ }
+ }
+
+ @Test
+ public void testObjectArrays() {
+ Integer[][] array = new Integer[][]{{0,1}, null, {null, 42}};
+ TypeInformation<Integer[][]> ti = TypeExtractor.getForClass(Integer[][].class);
+
+ SerializerTestInstance<Integer[][]> testInstance = new SerializerTestInstance<Integer[][]>(ti.createSerializer(new ExecutionConfig()), Integer[][].class, -1, array);
+ testInstance.testAll();
+
+ MyPojo[][] array2 = new MyPojo[][]{{new MyPojo(null, 42), new MyPojo("test2", -1)}, {null, null}, null};
+ TypeInformation<MyPojo[][]> ti2 = TypeExtractor.getForClass(MyPojo[][].class);
+
+ SerializerTestInstance<MyPojo[][]> testInstance2 = new SerializerTestInstance<MyPojo[][]>(ti2.createSerializer(new ExecutionConfig()), MyPojo[][].class, -1, array2);
+ testInstance2.testAll();
+ }
+
+ public static class MyGenericPojo<T> {
+ public T[][] field;
+
+ public MyGenericPojo() {
+ // nothing to do
+ }
+
+ public MyGenericPojo(T[][] field) {
+ this.field = field;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof MyGenericPojo)) {
+ return false;
+ }
+ MyGenericPojo<?> other = (MyGenericPojo<?>) obj;
+ return (field == null && other.field == null) || (field != null && field.length == other.field.length);
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericObjectArrays() {
+ MyGenericPojo<String>[][] array = (MyGenericPojo<String>[][]) new MyGenericPojo[][]{
+ { new MyGenericPojo<String>(new String[][]{{"a", "b"},{"c", "d"}}), null}
+ };
+ TypeInformation ti = TypeInfoParser.parse("org.apache.flink.api.java.typeutils.runtime.MultidimensionalArraySerializerTest$MyGenericPojo<field=String[][]>[][]");
+
+ SerializerTestInstance testInstance = new SerializerTestInstance(ti.createSerializer(new ExecutionConfig()), MyGenericPojo[][].class, -1, (Object) array);
+ testInstance.testAll();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java
new file mode 100644
index 0000000..26b03c6
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.util.Arrays;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.junit.Assert;
+
+
+public class PojoComparatorTest extends ComparatorTestBase<PojoContainingTuple> {
+ TypeInformation<PojoContainingTuple> type = TypeExtractor.getForClass(PojoContainingTuple.class);
+
+ PojoContainingTuple[] data = new PojoContainingTuple[]{
+ new PojoContainingTuple(1, 1L, 1L),
+ new PojoContainingTuple(2, 2L, 2L),
+ new PojoContainingTuple(8519, 85190L, 85190L),
+ new PojoContainingTuple(8520, 85191L, 85191L),
+ };
+
+ @Override
+ protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) {
+ Assert.assertTrue(type instanceof CompositeType);
+ CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type;
+ ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType);
+ boolean[] orders = new boolean[keys.getNumberOfKeyFields()];
+ Arrays.fill(orders, ascending);
+ return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig());
+ }
+
+ @Override
+ protected TypeSerializer<PojoContainingTuple> createSerializer() {
+ return type.createSerializer(new ExecutionConfig());
+ }
+
+ @Override
+ protected PojoContainingTuple[] getSortedTestData() {
+ return data;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java
new file mode 100644
index 0000000..ca17ee0
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java
@@ -0,0 +1,44 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+
+/**
+ * This file belongs to the PojoComparatorTest test
+ *
+ */
+public class PojoContainingTuple {
+ public int someInt;
+ public String someString = "abc";
+ public Tuple2<Long, Long> theTuple;
+ public PojoContainingTuple() {}
+ public PojoContainingTuple(int i, long l1, long l2) {
+ someInt = i;
+ theTuple = new Tuple2<Long, Long>(l1, l2);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(obj instanceof PojoContainingTuple) {
+ PojoContainingTuple other = (PojoContainingTuple) obj;
+ return someInt == other.someInt && theTuple.equals(other.theTuple);
+ }
+ return false;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java
new file mode 100644
index 0000000..d405412
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+
+public class PojoGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
+
+ @Override
+ protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
+ TypeInformation<T> typeInfo = TypeExtractor.getForClass(type);
+ return typeInfo.createSerializer(new ExecutionConfig());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java
new file mode 100644
index 0000000..260f7e9
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.SerializerTestBase;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.operators.Keys.IncompatibleKeysException;
+import org.apache.flink.api.java.tuple.Tuple1;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.PojoTypeInfo;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.base.Objects;
+
+/**
+ * A test for the {@link PojoSerializer}.
+ */
+public class PojoSerializerTest extends SerializerTestBase<PojoSerializerTest.TestUserClass> {
+ private TypeInformation<TestUserClass> type = TypeExtractor.getForClass(TestUserClass.class);
+
+ @Override
+ protected TypeSerializer<TestUserClass> createSerializer() {
+ TypeSerializer<TestUserClass> serializer = type.createSerializer(new ExecutionConfig());
+ assert(serializer instanceof PojoSerializer);
+ return serializer;
+ }
+
+ @Override
+ protected int getLength() {
+ return -1;
+ }
+
+ @Override
+ protected Class<TestUserClass> getTypeClass() {
+ return TestUserClass.class;
+ }
+
+ @Override
+ protected TestUserClass[] getTestData() {
+ Random rnd = new Random(874597969123412341L);
+
+ return new TestUserClass[]{
+ new TestUserClass(rnd.nextInt(), "foo", rnd.nextDouble(), new int[]{1, 2, 3}, new Date(),
+ new NestedTestUserClass(rnd.nextInt(), "foo@boo", rnd.nextDouble(), new int[]{10, 11, 12})),
+ new TestUserClass(rnd.nextInt(), "bar", rnd.nextDouble(), new int[]{4, 5, 6}, null,
+ new NestedTestUserClass(rnd.nextInt(), "bar@bas", rnd.nextDouble(), new int[]{20, 21, 22})),
+ new TestUserClass(rnd.nextInt(), null, rnd.nextDouble(), null, null, null),
+ new TestUserClass(rnd.nextInt(), "bar", rnd.nextDouble(), new int[]{4, 5, 6}, new Date(),
+ new NestedTestUserClass(rnd.nextInt(), "bar@bas", rnd.nextDouble(), new int[]{20, 21, 22}))
+ };
+
+ }
+
+ // User code class for testing the serializer
+ public static class TestUserClass {
+ public int dumm1;
+ public String dumm2;
+ public double dumm3;
+ public int[] dumm4;
+ public Date dumm5;
+
+ public NestedTestUserClass nestedClass;
+
+ public TestUserClass() {
+ }
+
+ public TestUserClass(int dumm1, String dumm2, double dumm3, int[] dumm4, Date dumm5, NestedTestUserClass nestedClass) {
+ this.dumm1 = dumm1;
+ this.dumm2 = dumm2;
+ this.dumm3 = dumm3;
+ this.dumm4 = dumm4;
+ this.dumm5 = dumm5;
+ this.nestedClass = nestedClass;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(dumm1, dumm2, dumm3, dumm4, nestedClass);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof TestUserClass)) {
+ return false;
+ }
+ TestUserClass otherTUC = (TestUserClass) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if ((dumm2 == null && otherTUC.dumm2 != null)
+ || (dumm2 != null && !dumm2.equals(otherTUC.dumm2))) {
+ return false;
+ }
+ if (dumm3 != otherTUC.dumm3) {
+ return false;
+ }
+ if ((dumm4 != null && otherTUC.dumm4 == null)
+ || (dumm4 == null && otherTUC.dumm4 != null)
+ || (dumm4 != null && otherTUC.dumm4 != null && dumm4.length != otherTUC.dumm4.length)) {
+ return false;
+ }
+ if (dumm4 != null && otherTUC.dumm4 != null) {
+ for (int i = 0; i < dumm4.length; i++) {
+ if (dumm4[i] != otherTUC.dumm4[i]) {
+ return false;
+ }
+ }
+ }
+
+ if ((nestedClass == null && otherTUC.nestedClass != null)
+ || (nestedClass != null && !nestedClass.equals(otherTUC.nestedClass))) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public static class NestedTestUserClass {
+ public int dumm1;
+ public String dumm2;
+ public double dumm3;
+ public int[] dumm4;
+
+ public NestedTestUserClass() {
+ }
+
+ public NestedTestUserClass(int dumm1, String dumm2, double dumm3, int[] dumm4) {
+ this.dumm1 = dumm1;
+ this.dumm2 = dumm2;
+ this.dumm3 = dumm3;
+ this.dumm4 = dumm4;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(dumm1, dumm2, dumm3, dumm4);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof NestedTestUserClass)) {
+ return false;
+ }
+ NestedTestUserClass otherTUC = (NestedTestUserClass) other;
+ if (dumm1 != otherTUC.dumm1) {
+ return false;
+ }
+ if (!dumm2.equals(otherTUC.dumm2)) {
+ return false;
+ }
+ if (dumm3 != otherTUC.dumm3) {
+ return false;
+ }
+ if (dumm4.length != otherTUC.dumm4.length) {
+ return false;
+ }
+ for (int i = 0; i < dumm4.length; i++) {
+ if (dumm4[i] != otherTUC.dumm4[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * This tests if the hashes returned by the pojo and tuple comparators are the same
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testTuplePojoTestEquality() {
+
+ // test with a simple, string-key first.
+ PojoTypeInfo<TestUserClass> pType = (PojoTypeInfo<TestUserClass>) type;
+ List<FlatFieldDescriptor> result = new ArrayList<FlatFieldDescriptor>();
+ pType.getFlatFields("nestedClass.dumm2", 0, result);
+ int[] fields = new int[1]; // see below
+ fields[0] = result.get(0).getPosition();
+ TypeComparator<TestUserClass> pojoComp = pType.createComparator( fields, new boolean[]{true}, 0, new ExecutionConfig());
+
+ TestUserClass pojoTestRecord = new TestUserClass(0, "abc", 3d, new int[] {1,2,3}, new Date(), new NestedTestUserClass(1, "haha", 4d, new int[] {5,4,3}));
+ int pHash = pojoComp.hash(pojoTestRecord);
+
+ Tuple1<String> tupleTest = new Tuple1<String>("haha");
+ TupleTypeInfo<Tuple1<String>> tType = (TupleTypeInfo<Tuple1<String>>)TypeExtractor.getForObject(tupleTest);
+ TypeComparator<Tuple1<String>> tupleComp = tType.createComparator(new int[] {0}, new boolean[] {true}, 0, new ExecutionConfig());
+
+ int tHash = tupleComp.hash(tupleTest);
+
+ Assert.assertTrue("The hashing for tuples and pojos must be the same, so that they are mixable", pHash == tHash);
+
+ Tuple3<Integer, String, Double> multiTupleTest = new Tuple3<Integer, String, Double>(1, "haha", 4d); // its important here to use the same values.
+ TupleTypeInfo<Tuple3<Integer, String, Double>> multiTupleType = (TupleTypeInfo<Tuple3<Integer, String, Double>>)TypeExtractor.getForObject(multiTupleTest);
+
+ ExpressionKeys fieldKey = new ExpressionKeys(new int[]{1,0,2}, multiTupleType);
+ ExpressionKeys expressKey = new ExpressionKeys(new String[] {"nestedClass.dumm2", "nestedClass.dumm1", "nestedClass.dumm3"}, pType);
+ try {
+ Assert.assertTrue("Expecting the keys to be compatible", fieldKey.areCompatible(expressKey));
+ } catch (IncompatibleKeysException e) {
+ e.printStackTrace();
+ Assert.fail("Keys must be compatible: "+e.getMessage());
+ }
+ TypeComparator<TestUserClass> multiPojoComp = pType.createComparator( expressKey.computeLogicalKeyPositions(), new boolean[]{true, true, true}, 0, new ExecutionConfig());
+ int multiPojoHash = multiPojoComp.hash(pojoTestRecord);
+
+
+ // pojo order is: dumm2 (str), dumm1 (int), dumm3 (double).
+ TypeComparator<Tuple3<Integer, String, Double>> multiTupleComp = multiTupleType.createComparator(fieldKey.computeLogicalKeyPositions(), new boolean[] {true, true,true}, 0, new ExecutionConfig());
+ int multiTupleHash = multiTupleComp.hash(multiTupleTest);
+
+ Assert.assertTrue("The hashing for tuples and pojos must be the same, so that they are mixable. Also for those with multiple key fields", multiPojoHash == multiTupleHash);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java
new file mode 100644
index 0000000..40c5c8c
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.junit.Assert;
+
+import java.util.Arrays;
+
+
+public class PojoSubclassComparatorTest extends ComparatorTestBase<PojoContainingTuple> {
+ TypeInformation<PojoContainingTuple> type = TypeExtractor.getForClass(PojoContainingTuple.class);
+
+ PojoContainingTuple[] data = new PojoContainingTuple[]{
+ new Subclass(1, 1L, 1L, 17L),
+ new Subclass(2, 2L, 2L, 42L),
+ new Subclass(8519, 85190L, 85190L, 117L),
+ new Subclass(8520, 85191L, 85191L, 93L),
+ };
+
+ @Override
+ protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) {
+ Assert.assertTrue(type instanceof CompositeType);
+ CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type;
+ ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType);
+ boolean[] orders = new boolean[keys.getNumberOfKeyFields()];
+ Arrays.fill(orders, ascending);
+ return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig());
+ }
+
+ @Override
+ protected TypeSerializer<PojoContainingTuple> createSerializer() {
+ return type.createSerializer(new ExecutionConfig());
+ }
+
+ @Override
+ protected PojoContainingTuple[] getSortedTestData() {
+ return data;
+ }
+
+ public static class Subclass extends PojoContainingTuple {
+
+ public long additionalField;
+
+ public Subclass() {
+ }
+
+ public Subclass(int i, long l1, long l2, long additionalField) {
+ super(i, l1, l2);
+ this.additionalField = additionalField;
+ }
+ }
+}
[38/38] flink git commit: [FLINK-3314] [streaming] Fix case where
early cancel messages do not properly cancel a stream operator.
Posted by se...@apache.org.
[FLINK-3314] [streaming] Fix case where early cancel messages do not properly cancel a stream operator.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/8fc7e7af
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/8fc7e7af
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/8fc7e7af
Branch: refs/heads/master
Commit: 8fc7e7af2c7decb8e531b76e3edcc2601f73fe9d
Parents: c356ef3
Author: Stephan Ewen <se...@apache.org>
Authored: Tue Feb 2 12:44:42 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 17:11:50 2016 +0100
----------------------------------------------------------------------
.../streaming/runtime/tasks/StreamTask.java | 20 +-
.../streaming/runtime/tasks/StreamTaskTest.java | 254 +++++++++++++++++++
2 files changed, 273 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/8fc7e7af/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
index 9ab6c10..c9624fc 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
@@ -146,6 +146,9 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
/** Flag to mark the task "in operation", in which case check
* needs to be initialized to true, so that early cancel() before invoke() behaves correctly */
private volatile boolean isRunning;
+
+ /** Flag to mark this task as canceled */
+ private volatile boolean canceled;
private long recoveryTimestamp;
@@ -191,6 +194,11 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
// task specific initialization
init();
+ // save the work of reloadig state, etc, if the task is already canceled
+ if (canceled) {
+ throw new CancelTaskException();
+ }
+
// -------- Invoke --------
LOG.debug("Invoking {}", getName());
@@ -205,7 +213,12 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
openAllOperators();
}
- // let the task do its work
+ // final check to exit early before starting to run
+ if (canceled) {
+ throw new CancelTaskException();
+ }
+
+ // let the task do its work
isRunning = true;
run();
isRunning = false;
@@ -290,6 +303,7 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
@Override
public final void cancel() throws Exception {
isRunning = false;
+ canceled = true;
cancelTask();
}
@@ -297,6 +311,10 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
return isRunning;
}
+ public final boolean isCanceled() {
+ return canceled;
+ }
+
private void openAllOperators() throws Exception {
for (StreamOperator<?> operator : operatorChain.getAllOperators()) {
if (operator != null) {
http://git-wip-us.apache.org/repos/asf/flink/blob/8fc7e7af/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java b/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
new file mode 100644
index 0000000..c18d150
--- /dev/null
+++ b/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
@@ -0,0 +1,254 @@
+/*
+ * 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.streaming.runtime.tasks;
+
+import akka.actor.ActorRef;
+
+import org.apache.flink.api.common.ApplicationID;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.blob.BlobKey;
+import org.apache.flink.runtime.broadcast.BroadcastVariableManager;
+import org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor;
+import org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor;
+import org.apache.flink.runtime.deployment.TaskDeploymentDescriptor;
+import org.apache.flink.runtime.execution.ExecutionState;
+import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+import org.apache.flink.runtime.filecache.FileCache;
+import org.apache.flink.runtime.instance.ActorGateway;
+import org.apache.flink.runtime.io.disk.iomanager.IOManager;
+import org.apache.flink.runtime.io.network.NetworkEnvironment;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionConsumableNotifier;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionManager;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
+import org.apache.flink.runtime.memory.MemoryManager;
+import org.apache.flink.runtime.taskmanager.Task;
+import org.apache.flink.runtime.taskmanager.TaskManagerRuntimeInfo;
+import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.api.graph.StreamConfig;
+import org.apache.flink.streaming.api.operators.Output;
+import org.apache.flink.streaming.api.operators.StreamSource;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.util.ExceptionUtils;
+
+import org.junit.Test;
+
+import scala.concurrent.ExecutionContext;
+import scala.concurrent.Future;
+import scala.concurrent.duration.FiniteDuration;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class StreamTaskTest {
+
+ /**
+ * This test checks that cancel calls that are issued before the operator is
+ * instantiated still lead to proper canceling.
+ */
+ @Test
+ public void testEarlyCanceling() {
+ try {
+ StreamConfig cfg = new StreamConfig(new Configuration());
+ cfg.setStreamOperator(new SlowlyDeserializingOperator());
+
+ Task task = createTask(SourceStreamTask.class, cfg);
+ task.startTaskThread();
+
+ // wait until the task thread reached state RUNNING
+ while (task.getExecutionState() == ExecutionState.CREATED ||
+ task.getExecutionState() == ExecutionState.DEPLOYING)
+ {
+ Thread.sleep(5);
+ }
+
+ // make sure the task is really running
+ if (task.getExecutionState() != ExecutionState.RUNNING) {
+ fail("Task entered state " + task.getExecutionState() + " with error "
+ + ExceptionUtils.stringifyException(task.getFailureCause()));
+ }
+
+ // send a cancel. because the operator takes a long time to deserialize, this should
+ // hit the task before the operator is deserialized
+ task.cancelExecution();
+
+ // the task should reach state canceled eventually
+ assertTrue(task.getExecutionState() == ExecutionState.CANCELING ||
+ task.getExecutionState() == ExecutionState.CANCELED);
+
+ task.getExecutingThread().join(60000);
+
+ assertFalse("Task did not cancel", task.getExecutingThread().isAlive());
+ assertEquals(ExecutionState.CANCELED, task.getExecutionState());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Test Utilities
+ // ------------------------------------------------------------------------
+
+ private Task createTask(Class<? extends AbstractInvokable> invokable, StreamConfig taskConfig) {
+ LibraryCacheManager libCache = mock(LibraryCacheManager.class);
+ when(libCache.getClassLoader(any(JobID.class))).thenReturn(getClass().getClassLoader());
+
+ ResultPartitionManager partitionManager = mock(ResultPartitionManager.class);
+ ResultPartitionConsumableNotifier consumableNotifier = mock(ResultPartitionConsumableNotifier.class);
+ NetworkEnvironment network = mock(NetworkEnvironment.class);
+ when(network.getPartitionManager()).thenReturn(partitionManager);
+ when(network.getPartitionConsumableNotifier()).thenReturn(consumableNotifier);
+ when(network.getDefaultIOMode()).thenReturn(IOManager.IOMode.SYNC);
+
+ TaskDeploymentDescriptor tdd = new TaskDeploymentDescriptor(
+ new ApplicationID(), new JobID(), new JobVertexID(), new ExecutionAttemptID(),
+ "Test Task", 0, 1, 0,
+ new Configuration(),
+ taskConfig.getConfiguration(),
+ invokable.getName(),
+ Collections.<ResultPartitionDeploymentDescriptor>emptyList(),
+ Collections.<InputGateDeploymentDescriptor>emptyList(),
+ Collections.<BlobKey>emptyList(),
+ Collections.<URL>emptyList(),
+ 0);
+
+ return new Task(
+ tdd,
+ mock(MemoryManager.class),
+ mock(IOManager.class),
+ network,
+ mock(BroadcastVariableManager.class),
+ new DummyGateway(),
+ new DummyGateway(),
+ new FiniteDuration(60, TimeUnit.SECONDS),
+ libCache,
+ mock(FileCache.class),
+ new TaskManagerRuntimeInfo("localhost", new Configuration()));
+ }
+
+ // ------------------------------------------------------------------------
+ // Test operators
+ // ------------------------------------------------------------------------
+
+ public static class SlowlyDeserializingOperator extends StreamSource<Long> {
+ private static final long serialVersionUID = 1L;
+
+ private volatile boolean canceled = false;
+
+ public SlowlyDeserializingOperator() {
+ super(new MockSourceFunction());
+ }
+
+ @Override
+ public void run(Object lockingObject, Output<StreamRecord<Long>> collector) throws Exception {
+ while (!canceled) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ignored) {}
+ }
+ }
+
+ @Override
+ public void cancel() {
+ canceled = true;
+ }
+
+ // slow deserialization
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+
+ long delay = 500;
+ long deadline = System.currentTimeMillis() + delay;
+ do {
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException ignored) {}
+ } while ((delay = deadline - System.currentTimeMillis()) > 0);
+ }
+ }
+
+ private static class MockSourceFunction implements SourceFunction<Long> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void run(SourceContext<Long> ctx) {}
+
+ @Override
+ public void cancel() {}
+ }
+
+ // ------------------------------------------------------------------------
+ // Test JobManager/TaskManager gateways
+ // ------------------------------------------------------------------------
+
+ private static class DummyGateway implements ActorGateway {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Future<Object> ask(Object message, FiniteDuration timeout) {
+ return null;
+ }
+
+ @Override
+ public void tell(Object message) {}
+
+ @Override
+ public void tell(Object message, ActorGateway sender) {}
+
+ @Override
+ public void forward(Object message, ActorGateway sender) {}
+
+ @Override
+ public Future<Object> retry(Object message, int numberRetries, FiniteDuration timeout, ExecutionContext executionContext) {
+ return null;
+ }
+
+ @Override
+ public String path() {
+ return null;
+ }
+
+ @Override
+ public ActorRef actor() {
+ return null;
+ }
+
+ @Override
+ public UUID leaderSessionID() {
+ return null;
+ }
+ }
+}
[08/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java
deleted file mode 100644
index de24956..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java
+++ /dev/null
@@ -1,592 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-
-
-public final class PojoSerializer<T> extends TypeSerializer<T> {
-
- // Flags for the header
- private static byte IS_NULL = 1;
- private static byte NO_SUBCLASS = 2;
- private static byte IS_SUBCLASS = 4;
- private static byte IS_TAGGED_SUBCLASS = 8;
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> clazz;
-
- private final TypeSerializer<Object>[] fieldSerializers;
-
- private final int numFields;
-
- private final Map<Class<?>, Integer> registeredClasses;
-
- private final TypeSerializer<?>[] registeredSerializers;
-
- private final ExecutionConfig executionConfig;
-
- private transient Map<Class<?>, TypeSerializer<?>> subclassSerializerCache;
- private transient ClassLoader cl;
- // We need to handle these ourselves in writeObject()/readObject()
- private transient Field[] fields;
-
- @SuppressWarnings("unchecked")
- public PojoSerializer(
- Class<T> clazz,
- TypeSerializer<?>[] fieldSerializers,
- Field[] fields,
- ExecutionConfig executionConfig) {
-
- this.clazz = Preconditions.checkNotNull(clazz);
- this.fieldSerializers = (TypeSerializer<Object>[]) Preconditions.checkNotNull(fieldSerializers);
- this.fields = Preconditions.checkNotNull(fields);
- this.numFields = fieldSerializers.length;
- this.executionConfig = Preconditions.checkNotNull(executionConfig);
-
- LinkedHashSet<Class<?>> registeredPojoTypes = executionConfig.getRegisteredPojoTypes();
-
- for (int i = 0; i < numFields; i++) {
- this.fields[i].setAccessible(true);
- }
-
- cl = Thread.currentThread().getContextClassLoader();
-
- subclassSerializerCache = new HashMap<Class<?>, TypeSerializer<?>>();
-
- // We only want those classes that are not our own class and are actually sub-classes.
- List<Class<?>> cleanedTaggedClasses = new ArrayList<Class<?>>(registeredPojoTypes.size());
- for (Class<?> registeredClass: registeredPojoTypes) {
- if (registeredClass.equals(clazz)) {
- continue;
- }
- if (!clazz.isAssignableFrom(registeredClass)) {
- continue;
- }
- cleanedTaggedClasses.add(registeredClass);
-
- }
- this.registeredClasses = new LinkedHashMap<Class<?>, Integer>(cleanedTaggedClasses.size());
- registeredSerializers = new TypeSerializer[cleanedTaggedClasses.size()];
-
- int id = 0;
- for (Class<?> registeredClass: cleanedTaggedClasses) {
- this.registeredClasses.put(registeredClass, id);
- TypeInformation<?> typeInfo = TypeExtractor.createTypeInfo(registeredClass);
- registeredSerializers[id] = typeInfo.createSerializer(executionConfig);
-
- id++;
- }
- }
-
- private void writeObject(ObjectOutputStream out)
- throws IOException, ClassNotFoundException {
- out.defaultWriteObject();
- out.writeInt(fields.length);
- for (Field field: fields) {
- out.writeObject(field.getDeclaringClass());
- out.writeUTF(field.getName());
- }
- }
-
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- int numFields = in.readInt();
- fields = new Field[numFields];
- for (int i = 0; i < numFields; i++) {
- Class<?> clazz = (Class<?>)in.readObject();
- String fieldName = in.readUTF();
- fields[i] = null;
- // try superclasses as well
- while (clazz != null) {
- try {
- fields[i] = clazz.getDeclaredField(fieldName);
- fields[i].setAccessible(true);
- break;
- } catch (NoSuchFieldException e) {
- clazz = clazz.getSuperclass();
- }
- }
- if (fields[i] == null) {
- throw new RuntimeException("Class resolved at TaskManager is not compatible with class read during Plan setup."
- + " (" + fieldName + ")");
- }
- }
-
- cl = Thread.currentThread().getContextClassLoader();
- subclassSerializerCache = new HashMap<Class<?>, TypeSerializer<?>>();
- }
-
- private TypeSerializer<?> getSubclassSerializer(Class<?> subclass) {
- TypeSerializer<?> result = subclassSerializerCache.get(subclass);
- if (result == null) {
-
- TypeInformation<?> typeInfo = TypeExtractor.createTypeInfo(subclass);
- result = typeInfo.createSerializer(executionConfig);
- if (result instanceof PojoSerializer) {
- PojoSerializer<?> subclassSerializer = (PojoSerializer<?>) result;
- subclassSerializer.copyBaseFieldOrder(this);
- }
- subclassSerializerCache.put(subclass, result);
-
- }
- return result;
- }
-
- @SuppressWarnings("unused")
- private boolean hasField(Field f) {
- for (Field field: fields) {
- if (f.equals(field)) {
- return true;
- }
- }
- return false;
- }
-
- private void copyBaseFieldOrder(PojoSerializer<?> baseSerializer) {
- // do nothing for now, but in the future, adapt subclass serializer to have same
- // ordering as base class serializer so that binary comparison on base class fields
- // can work
- }
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public PojoSerializer<T> duplicate() {
- boolean stateful = false;
- TypeSerializer<?>[] duplicateFieldSerializers = new TypeSerializer[fieldSerializers.length];
-
- for (int i = 0; i < fieldSerializers.length; i++) {
- duplicateFieldSerializers[i] = fieldSerializers[i].duplicate();
- if (duplicateFieldSerializers[i] != fieldSerializers[i]) {
- // at least one of them is stateful
- stateful = true;
- }
- }
-
- if (stateful) {
- return new PojoSerializer<T>(clazz, duplicateFieldSerializers, fields, executionConfig);
- } else {
- return this;
- }
- }
-
-
- @Override
- public T createInstance() {
- if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
- return null;
- }
- try {
- T t = clazz.newInstance();
- initializeFields(t);
- return t;
- }
- catch (Exception e) {
- throw new RuntimeException("Cannot instantiate class.", e);
- }
- }
-
- protected void initializeFields(T t) {
- for (int i = 0; i < numFields; i++) {
- try {
- fields[i].set(t, fieldSerializers[i].createInstance());
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Cannot initialize fields.", e);
- }
- }
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public T copy(T from) {
- if (from == null) {
- return null;
- }
-
- Class<?> actualType = from.getClass();
- if (actualType == clazz) {
- T target;
- try {
- target = (T) from.getClass().newInstance();
- }
- catch (Throwable t) {
- throw new RuntimeException("Cannot instantiate class.", t);
- }
- // no subclass
- try {
- for (int i = 0; i < numFields; i++) {
- Object value = fields[i].get(from);
- if (value != null) {
- Object copy = fieldSerializers[i].copy(value);
- fields[i].set(target, copy);
- }
- else {
- fields[i].set(target, null);
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields before.");
-
- }
- return target;
- } else {
- // subclass
- TypeSerializer subclassSerializer = getSubclassSerializer(actualType);
- return (T) subclassSerializer.copy(from);
- }
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public T copy(T from, T reuse) {
- if (from == null) {
- return null;
- }
-
- Class<?> actualType = from.getClass();
- if (reuse == null || actualType != reuse.getClass()) {
- // cannot reuse, do a non-reuse copy
- return copy(from);
- }
-
- if (actualType == clazz) {
- try {
- for (int i = 0; i < numFields; i++) {
- Object value = fields[i].get(from);
- if (value != null) {
- Object reuseValue = fields[i].get(reuse);
- Object copy;
- if(reuseValue != null) {
- copy = fieldSerializers[i].copy(value, reuseValue);
- }
- else {
- copy = fieldSerializers[i].copy(value);
- }
- fields[i].set(reuse, copy);
- }
- else {
- fields[i].set(reuse, null);
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields" + "before.");
- }
- } else {
- TypeSerializer subclassSerializer = getSubclassSerializer(actualType);
- reuse = (T) subclassSerializer.copy(from, reuse);
- }
-
- return reuse;
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public void serialize(T value, DataOutputView target) throws IOException {
- int flags = 0;
- // handle null values
- if (value == null) {
- flags |= IS_NULL;
- target.writeByte(flags);
- return;
- }
-
- Integer subclassTag = -1;
- Class<?> actualClass = value.getClass();
- TypeSerializer subclassSerializer = null;
- if (clazz != actualClass) {
- subclassTag = registeredClasses.get(actualClass);
- if (subclassTag != null) {
- flags |= IS_TAGGED_SUBCLASS;
- subclassSerializer = registeredSerializers[subclassTag];
- } else {
- flags |= IS_SUBCLASS;
- subclassSerializer = getSubclassSerializer(actualClass);
- }
- } else {
- flags |= NO_SUBCLASS;
- }
-
- target.writeByte(flags);
-
- if ((flags & IS_SUBCLASS) != 0) {
- target.writeUTF(actualClass.getName());
- } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
- target.writeByte(subclassTag);
- }
-
-
- if ((flags & NO_SUBCLASS) != 0) {
- try {
- for (int i = 0; i < numFields; i++) {
- Object o = fields[i].get(value);
- if (o == null) {
- target.writeBoolean(true); // null field handling
- } else {
- target.writeBoolean(false);
- fieldSerializers[i].serialize(o, target);
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields" + "before.");
-
- }
- } else {
- // subclass
- if (subclassSerializer != null) {
- subclassSerializer.serialize(value, target);
- }
- }
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public T deserialize(DataInputView source) throws IOException {
- int flags = source.readByte();
- if((flags & IS_NULL) != 0) {
- return null;
- }
-
- T target;
-
- Class<?> actualSubclass = null;
- TypeSerializer subclassSerializer = null;
-
- if ((flags & IS_SUBCLASS) != 0) {
- String subclassName = source.readUTF();
- try {
- actualSubclass = Class.forName(subclassName, true, cl);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Cannot instantiate class.", e);
- }
- subclassSerializer = getSubclassSerializer(actualSubclass);
- target = (T) subclassSerializer.createInstance();
- // also initialize fields for which the subclass serializer is not responsible
- initializeFields(target);
- } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
-
- int subclassTag = source.readByte();
- subclassSerializer = registeredSerializers[subclassTag];
- target = (T) subclassSerializer.createInstance();
- // also initialize fields for which the subclass serializer is not responsible
- initializeFields(target);
- } else {
- target = createInstance();
- }
-
- if ((flags & NO_SUBCLASS) != 0) {
- try {
- for (int i = 0; i < numFields; i++) {
- boolean isNull = source.readBoolean();
- if (isNull) {
- fields[i].set(target, null);
- } else {
- Object field = fieldSerializers[i].deserialize(source);
- fields[i].set(target, field);
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields" + "before.");
-
- }
- } else {
- if (subclassSerializer != null) {
- target = (T) subclassSerializer.deserialize(target, source);
- }
- }
- return target;
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public T deserialize(T reuse, DataInputView source) throws IOException {
-
- // handle null values
- int flags = source.readByte();
- if((flags & IS_NULL) != 0) {
- return null;
- }
-
- Class<?> subclass = null;
- TypeSerializer subclassSerializer = null;
- if ((flags & IS_SUBCLASS) != 0) {
- String subclassName = source.readUTF();
- try {
- subclass = Class.forName(subclassName, true, cl);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Cannot instantiate class.", e);
- }
- subclassSerializer = getSubclassSerializer(subclass);
-
- if (reuse == null || subclass != reuse.getClass()) {
- // cannot reuse
- reuse = (T) subclassSerializer.createInstance();
- // also initialize fields for which the subclass serializer is not responsible
- initializeFields(reuse);
- }
- } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
- int subclassTag = source.readByte();
- subclassSerializer = registeredSerializers[subclassTag];
-
- if (reuse == null || ((PojoSerializer)subclassSerializer).clazz != reuse.getClass()) {
- // cannot reuse
- reuse = (T) subclassSerializer.createInstance();
- // also initialize fields for which the subclass serializer is not responsible
- initializeFields(reuse);
- }
- } else {
- if (reuse == null || clazz != reuse.getClass()) {
- reuse = createInstance();
- }
- }
-
- if ((flags & NO_SUBCLASS) != 0) {
- try {
- for (int i = 0; i < numFields; i++) {
- boolean isNull = source.readBoolean();
- if (isNull) {
- fields[i].set(reuse, null);
- } else {
- Object field;
-
- Object reuseField = fields[i].get(reuse);
- if(reuseField != null) {
- field = fieldSerializers[i].deserialize(reuseField, source);
- }
- else {
- field = fieldSerializers[i].deserialize(source);
- }
-
- fields[i].set(reuse, field);
- }
- }
- } catch (IllegalAccessException e) {
- throw new RuntimeException(
- "Error during POJO copy, this should not happen since we check the fields before.");
- }
- } else {
- if (subclassSerializer != null) {
- reuse = (T) subclassSerializer.deserialize(reuse, source);
- }
- }
-
- return reuse;
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- // copy the flags
- int flags = source.readByte();
- target.writeByte(flags);
-
- if ((flags & IS_NULL) != 0) {
- // is a null value, nothing further to copy
- return;
- }
-
- TypeSerializer<?> subclassSerializer = null;
- if ((flags & IS_SUBCLASS) != 0) {
- String className = source.readUTF();
- target.writeUTF(className);
- try {
- Class<?> subclass = Class.forName(className, true, Thread.currentThread()
- .getContextClassLoader());
- subclassSerializer = getSubclassSerializer(subclass);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Cannot instantiate class.", e);
- }
- } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
- int subclassTag = source.readByte();
- target.writeByte(subclassTag);
- subclassSerializer = registeredSerializers[subclassTag];
- }
-
- if ((flags & NO_SUBCLASS) != 0) {
- for (int i = 0; i < numFields; i++) {
- boolean isNull = source.readBoolean();
- target.writeBoolean(isNull);
- if (!isNull) {
- fieldSerializers[i].copy(source, target);
- }
- }
- } else {
- if (subclassSerializer != null) {
- subclassSerializer.copy(source, target);
- }
- }
- }
-
- @Override
- public int hashCode() {
- return 31 * (31 * Arrays.hashCode(fieldSerializers) + Arrays.hashCode(registeredSerializers)) +
- Objects.hash(clazz, numFields, registeredClasses);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof PojoSerializer) {
- PojoSerializer<?> other = (PojoSerializer<?>) obj;
-
- return other.canEqual(this) &&
- clazz == other.clazz &&
- Arrays.equals(fieldSerializers, other.fieldSerializers) &&
- Arrays.equals(registeredSerializers, other.registeredSerializers) &&
- numFields == other.numFields &&
- registeredClasses.equals(other.registeredClasses);
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof PojoSerializer;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java
deleted file mode 100644
index 4b734a7..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java
+++ /dev/null
@@ -1,75 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeComparatorFactory;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.util.InstantiationUtil;
-
-public final class RuntimeComparatorFactory<T> implements TypeComparatorFactory<T>, java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
-
- private static final String CONFIG_KEY = "SER_DATA";
-
- private TypeComparator<T> comparator;
-
-
- public RuntimeComparatorFactory() {}
-
- public RuntimeComparatorFactory(TypeComparator<T> comparator) {
- this.comparator = comparator;
- }
-
- @Override
- public void writeParametersToConfig(Configuration config) {
- try {
- InstantiationUtil.writeObjectToConfig(comparator, config, CONFIG_KEY);
- }
- catch (Exception e) {
- throw new RuntimeException("Could not serialize comparator into the configuration.", e);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void readParametersFromConfig(Configuration config, ClassLoader cl) throws ClassNotFoundException {
- try {
- comparator = (TypeComparator<T>) InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY, cl);
- }
- catch (ClassNotFoundException e) {
- throw e;
- }
- catch (Exception e) {
- throw new RuntimeException("Could not serialize serializer into the configuration.", e);
- }
- }
-
- @Override
- public TypeComparator<T> createComparator() {
- if (comparator != null) {
- return comparator;
- } else {
- throw new RuntimeException("ComparatorFactory has not been initialized from configuration.");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java
deleted file mode 100644
index 31e28f7..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java
+++ /dev/null
@@ -1,44 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.GenericPairComparator;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypePairComparator;
-import org.apache.flink.api.common.typeutils.TypePairComparatorFactory;
-
-public final class RuntimePairComparatorFactory<T1, T2>
- implements TypePairComparatorFactory<T1, T2>, java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public TypePairComparator<T1, T2> createComparator12(
- TypeComparator<T1> comparator1,
- TypeComparator<T2> comparator2) {
- return new GenericPairComparator<T1, T2>(comparator1, comparator2);
- }
-
- @Override
- public TypePairComparator<T2, T1> createComparator21(
- TypeComparator<T1> comparator1,
- TypeComparator<T2> comparator2) {
- return new GenericPairComparator<T2, T1>(comparator2, comparator1);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java
deleted file mode 100644
index 96aff73..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java
+++ /dev/null
@@ -1,124 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.TypeSerializerFactory;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.util.InstantiationUtil;
-
-public final class RuntimeSerializerFactory<T> implements TypeSerializerFactory<T>, java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
-
- private static final String CONFIG_KEY_SER = "SER_DATA";
-
- private static final String CONFIG_KEY_CLASS = "CLASS_DATA";
-
-
- private TypeSerializer<T> serializer;
-
- private boolean firstSerializer = true;
-
- private Class<T> clazz;
-
- // Because we read the class from the TaskConfig and instantiate ourselves
- public RuntimeSerializerFactory() {}
-
- public RuntimeSerializerFactory(TypeSerializer<T> serializer, Class<T> clazz) {
- if (serializer == null || clazz == null) {
- throw new NullPointerException();
- }
-
- this.clazz = clazz;
- this.serializer = serializer;
- }
-
-
- @Override
- public void writeParametersToConfig(Configuration config) {
- try {
- InstantiationUtil.writeObjectToConfig(clazz, config, CONFIG_KEY_CLASS);
- InstantiationUtil.writeObjectToConfig(serializer, config, CONFIG_KEY_SER);
- }
- catch (Exception e) {
- throw new RuntimeException("Could not serialize serializer into the configuration.", e);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void readParametersFromConfig(Configuration config, ClassLoader cl) throws ClassNotFoundException {
- if (config == null || cl == null) {
- throw new NullPointerException();
- }
-
- try {
- this.clazz = (Class<T>) InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY_CLASS, cl);
- this.serializer = (TypeSerializer<T>) InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY_SER, cl);
- firstSerializer = true;
- }
- catch (ClassNotFoundException e) {
- throw e;
- }
- catch (Exception e) {
- throw new RuntimeException("Could not load deserializer from the configuration.", e);
- }
- }
-
- @Override
- public TypeSerializer<T> getSerializer() {
- if (this.serializer != null) {
- if (firstSerializer) {
- firstSerializer = false;
- return this.serializer;
- } else {
- return this.serializer.duplicate();
- }
- } else {
- throw new RuntimeException("SerializerFactory has not been initialized from configuration.");
- }
- }
-
- @Override
- public Class<T> getDataType() {
- return clazz;
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return clazz.hashCode() ^ serializer.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj != null && obj instanceof RuntimeSerializerFactory) {
- RuntimeSerializerFactory<?> other = (RuntimeSerializerFactory<?>) obj;
-
- return this.clazz == other.clazz &&
- this.serializer.equals(other.serializer);
- } else {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java
deleted file mode 100644
index a06ff1a..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java
+++ /dev/null
@@ -1,121 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple0;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-
-public class Tuple0Serializer extends TupleSerializer<Tuple0> {
-
- private static final long serialVersionUID = 1278813169022975971L;
-
- public static final Tuple0Serializer INSTANCE = new Tuple0Serializer();
-
- // ------------------------------------------------------------------------
-
- private Tuple0Serializer() {
- super(Tuple0.class, new TypeSerializer<?>[0]);
- }
-
- // ------------------------------------------------------------------------
-
- @Override
- public Tuple0Serializer duplicate() {
- return this;
- }
-
- @Override
- public Tuple0 createInstance() {
- return Tuple0.INSTANCE;
- }
-
- @Override
- public Tuple0 createInstance(Object[] fields) {
- if (fields == null || fields.length == 0) {
- return Tuple0.INSTANCE;
- }
-
- throw new UnsupportedOperationException(
- "Tuple0 cannot take any data, as it has zero fields.");
- }
-
- @Override
- public Tuple0 copy(Tuple0 from) {
- return from;
- }
-
- @Override
- public Tuple0 copy(Tuple0 from, Tuple0 reuse) {
- return reuse;
- }
-
- @Override
- public int getLength() {
- return 1;
- }
-
- @Override
- public void serialize(Tuple0 record, DataOutputView target) throws IOException {
- target.writeByte(42);
- }
-
- @Override
- public Tuple0 deserialize(DataInputView source) throws IOException {
- source.readByte();
- return Tuple0.INSTANCE;
- }
-
- @Override
- public Tuple0 deserialize(Tuple0 reuse, DataInputView source) throws IOException {
- source.readByte();
- return reuse;
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- target.writeByte(source.readByte());
- }
-
- // ------------------------------------------------------------------------
-
-
- @Override
- public int hashCode() {
- return Tuple0Serializer.class.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Tuple0Serializer) {
- Tuple0Serializer other = (Tuple0Serializer) obj;
-
- return other.canEqual(this);
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof Tuple0Serializer;
- }
-
- @Override
- public String toString() {
- return "Tuple0Serializer";
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java
deleted file mode 100644
index 875ecc2..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java
+++ /dev/null
@@ -1,157 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.types.KeyFieldOutOfBoundsException;
-import org.apache.flink.types.NullFieldException;
-import org.apache.flink.types.NullKeyFieldException;
-
-
-public final class TupleComparator<T extends Tuple> extends TupleComparatorBase<T> {
-
- private static final long serialVersionUID = 1L;
-
- public TupleComparator(int[] keyPositions, TypeComparator<?>[] comparators, TypeSerializer<?>[] serializers) {
- super(keyPositions, comparators, serializers);
- }
-
- private TupleComparator(TupleComparator<T> toClone) {
- super(toClone);
- }
-
- // --------------------------------------------------------------------------------------------
- // Comparator Methods
- // --------------------------------------------------------------------------------------------
-
- @SuppressWarnings("unchecked")
- @Override
- public int hash(T value) {
- int i = 0;
- try {
- int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
- for (i = 1; i < this.keyPositions.length; i++) {
- code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
- code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
- }
- return code;
- }
- catch (NullFieldException nfex) {
- throw new NullKeyFieldException(nfex);
- }
- catch (IndexOutOfBoundsException iobex) {
- throw new KeyFieldOutOfBoundsException(keyPositions[i]);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void setReference(T toCompare) {
- int i = 0;
- try {
- for (; i < this.keyPositions.length; i++) {
- this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
- }
- }
- catch (NullFieldException nfex) {
- throw new NullKeyFieldException(nfex);
- }
- catch (IndexOutOfBoundsException iobex) {
- throw new KeyFieldOutOfBoundsException(keyPositions[i]);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean equalToReference(T candidate) {
- int i = 0;
- try {
- for (; i < this.keyPositions.length; i++) {
- if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
- return false;
- }
- }
- return true;
- }
- catch (NullFieldException nfex) {
- throw new NullKeyFieldException(nfex);
- }
- catch (IndexOutOfBoundsException iobex) {
- throw new KeyFieldOutOfBoundsException(keyPositions[i]);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public int compare(T first, T second) {
- int i = 0;
- try {
- for (; i < keyPositions.length; i++) {
- int keyPos = keyPositions[i];
- int cmp = comparators[i].compare(first.getFieldNotNull(keyPos), second.getFieldNotNull(keyPos));
-
- if (cmp != 0) {
- return cmp;
- }
- }
- return 0;
- }
- catch (NullFieldException nfex) {
- throw new NullKeyFieldException(nfex);
- }
- catch (IndexOutOfBoundsException iobex) {
- throw new KeyFieldOutOfBoundsException(keyPositions[i]);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
- int i = 0;
- try {
- for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
- int len = this.normalizedKeyLengths[i];
- len = numBytes >= len ? len : numBytes;
- this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
- numBytes -= len;
- offset += len;
- }
- } catch (NullFieldException nfex) {
- throw new NullKeyFieldException(nfex);
- } catch (NullPointerException npex) {
- throw new NullKeyFieldException(this.keyPositions[i]);
- }
- }
-
- @Override
- public int extractKeys(Object record, Object[] target, int index) {
- int localIndex = index;
- for(int i = 0; i < comparators.length; i++) {
- localIndex += comparators[i].extractKeys(((Tuple) record).getField(keyPositions[i]), target, localIndex);
- }
- return localIndex - index;
- }
-
- public TypeComparator<T> duplicate() {
- return new TupleComparator<T>(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java
deleted file mode 100644
index 28169e5..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java
+++ /dev/null
@@ -1,279 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.flink.api.common.typeutils.CompositeTypeComparator;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.types.KeyFieldOutOfBoundsException;
-import org.apache.flink.types.NullKeyFieldException;
-
-
-public abstract class TupleComparatorBase<T> extends CompositeTypeComparator<T> implements java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /** key positions describe which fields are keys in what order */
- protected int[] keyPositions;
-
- /** comparators for the key fields, in the same order as the key fields */
- @SuppressWarnings("rawtypes")
- protected TypeComparator[] comparators;
-
- protected int[] normalizedKeyLengths;
-
- protected int numLeadingNormalizableKeys;
-
- protected int normalizableKeyPrefixLen;
-
- protected boolean invertNormKey;
-
-
- /** serializers to deserialize the first n fields for comparison */
- @SuppressWarnings("rawtypes")
- protected TypeSerializer[] serializers;
-
- // cache for the deserialized field objects
- protected transient Object[] deserializedFields1;
- protected transient Object[] deserializedFields2;
-
-
- @SuppressWarnings("unchecked")
- public TupleComparatorBase(int[] keyPositions, TypeComparator<?>[] comparators, TypeSerializer<?>[] serializers) {
- // set the default utils
- this.keyPositions = keyPositions;
- this.comparators = (TypeComparator<Object>[]) comparators;
- this.serializers = (TypeSerializer<Object>[]) serializers;
-
- // set up auxiliary fields for normalized key support
- this.normalizedKeyLengths = new int[keyPositions.length];
- int nKeys = 0;
- int nKeyLen = 0;
- boolean inverted = false;
-
- for (int i = 0; i < this.keyPositions.length; i++) {
- TypeComparator<?> k = this.comparators[i];
-
- // as long as the leading keys support normalized keys, we can build up the composite key
- if (k.supportsNormalizedKey()) {
- if (i == 0) {
- // the first comparator decides whether we need to invert the key direction
- inverted = k.invertNormalizedKey();
- }
- else if (k.invertNormalizedKey() != inverted) {
- // if a successor does not agree on the inversion direction, it cannot be part of the normalized key
- break;
- }
-
- nKeys++;
- final int len = k.getNormalizeKeyLen();
- if (len < 0) {
- throw new RuntimeException("Comparator " + k.getClass().getName() + " specifies an invalid length for the normalized key: " + len);
- }
- this.normalizedKeyLengths[i] = len;
- nKeyLen += len;
-
- if (nKeyLen < 0) {
- // overflow, which means we are out of budget for normalized key space anyways
- nKeyLen = Integer.MAX_VALUE;
- break;
- }
- } else {
- break;
- }
- }
- this.numLeadingNormalizableKeys = nKeys;
- this.normalizableKeyPrefixLen = nKeyLen;
- this.invertNormKey = inverted;
- }
-
- protected TupleComparatorBase(TupleComparatorBase<T> toClone) {
- privateDuplicate(toClone);
- }
-
- // We need this because we cannot call the cloning constructor from the
- // ScalaTupleComparator
- protected void privateDuplicate(TupleComparatorBase<T> toClone) {
- // copy fields and serializer factories
- this.keyPositions = toClone.keyPositions;
-
- this.serializers = new TypeSerializer[toClone.serializers.length];
- for (int i = 0; i < toClone.serializers.length; i++) {
- this.serializers[i] = toClone.serializers[i].duplicate();
- }
-
- this.comparators = new TypeComparator[toClone.comparators.length];
- for (int i = 0; i < toClone.comparators.length; i++) {
- this.comparators[i] = toClone.comparators[i].duplicate();
- }
-
- this.normalizedKeyLengths = toClone.normalizedKeyLengths;
- this.numLeadingNormalizableKeys = toClone.numLeadingNormalizableKeys;
- this.normalizableKeyPrefixLen = toClone.normalizableKeyPrefixLen;
- this.invertNormKey = toClone.invertNormKey;
- }
-
- // --------------------------------------------------------------------------------------------
- // Comparator Methods
- // --------------------------------------------------------------------------------------------
-
- protected int[] getKeyPositions() {
- return this.keyPositions;
- }
-
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void getFlatComparator(List<TypeComparator> flatComparators) {
- for(int i = 0; i < comparators.length; i++) {
- if(comparators[i] instanceof CompositeTypeComparator) {
- ((CompositeTypeComparator)comparators[i]).getFlatComparator(flatComparators);
- } else {
- flatComparators.add(comparators[i]);
- }
- }
- }
- // --------------------------------------------------------------------------------------------
- // Comparator Methods
- // --------------------------------------------------------------------------------------------
-
-
- @Override
- public int compareToReference(TypeComparator<T> referencedComparator) {
- TupleComparatorBase<T> other = (TupleComparatorBase<T>) referencedComparator;
-
- int i = 0;
- try {
- for (; i < this.keyPositions.length; i++) {
- @SuppressWarnings("unchecked")
- int cmp = this.comparators[i].compareToReference(other.comparators[i]);
- if (cmp != 0) {
- return cmp;
- }
- }
- return 0;
- }
- catch (NullPointerException npex) {
- throw new NullKeyFieldException(keyPositions[i]);
- }
- catch (IndexOutOfBoundsException iobex) {
- throw new KeyFieldOutOfBoundsException(keyPositions[i]);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
- if (deserializedFields1 == null) {
- instantiateDeserializationUtils();
- }
-
- int i = 0;
- try {
- for (; i < serializers.length; i++) {
- deserializedFields1[i] = serializers[i].deserialize(deserializedFields1[i], firstSource);
- deserializedFields2[i] = serializers[i].deserialize(deserializedFields2[i], secondSource);
- }
-
- for (i = 0; i < keyPositions.length; i++) {
- int keyPos = keyPositions[i];
- int cmp = comparators[i].compare(deserializedFields1[keyPos], deserializedFields2[keyPos]);
- if (cmp != 0) {
- return cmp;
- }
- }
-
- return 0;
- } catch (NullPointerException npex) {
- throw new NullKeyFieldException(keyPositions[i]);
- } catch (IndexOutOfBoundsException iobex) {
- throw new KeyFieldOutOfBoundsException(keyPositions[i], iobex);
- }
- }
-
- @Override
- public boolean supportsNormalizedKey() {
- return this.numLeadingNormalizableKeys > 0;
- }
-
- @Override
- public int getNormalizeKeyLen() {
- return this.normalizableKeyPrefixLen;
- }
-
- @Override
- public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
- return this.numLeadingNormalizableKeys < this.keyPositions.length ||
- this.normalizableKeyPrefixLen == Integer.MAX_VALUE ||
- this.normalizableKeyPrefixLen > keyBytes;
- }
-
- @Override
- public boolean invertNormalizedKey() {
- return this.invertNormKey;
- }
-
-
- @Override
- public boolean supportsSerializationWithKeyNormalization() {
- return false;
- }
-
- @Override
- public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- // --------------------------------------------------------------------------------------------
-
- protected final void instantiateDeserializationUtils() {
- this.deserializedFields1 = new Object[this.serializers.length];
- this.deserializedFields2 = new Object[this.serializers.length];
-
- for (int i = 0; i < this.serializers.length; i++) {
- this.deserializedFields1[i] = this.serializers[i].createInstance();
- this.deserializedFields2[i] = this.serializers[i].createInstance();
- }
- }
-
- // --------------------------------------------------------------------------------------------
-
- /**
- * A sequence of prime numbers to be used for salting the computed hash values.
- * Based on some empirical evidence, we are using a 32-element subsequence of the
- * OEIS sequence #A068652 (numbers such that every cyclic permutation is a prime).
- *
- * @see <a href="http://en.wikipedia.org/wiki/List_of_prime_numbers">http://en.wikipedia.org/wiki/List_of_prime_numbers</a>
- * @see <a href="http://oeis.org/A068652">http://oeis.org/A068652</a>
- */
- public static final int[] HASH_SALT = new int[] {
- 73 , 79 , 97 , 113 , 131 , 197 , 199 , 311 ,
- 337 , 373 , 719 , 733 , 919 , 971 , 991 , 1193 ,
- 1931 , 3119 , 3779 , 7793 , 7937 , 9311 , 9377 , 11939 ,
- 19391, 19937, 37199, 39119, 71993, 91193, 93719, 93911 };
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java
deleted file mode 100644
index 0897063..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java
+++ /dev/null
@@ -1,158 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.types.NullFieldException;
-
-
-public class TupleSerializer<T extends Tuple> extends TupleSerializerBase<T> {
-
- private static final long serialVersionUID = 1L;
-
- public TupleSerializer(Class<T> tupleClass, TypeSerializer<?>[] fieldSerializers) {
- super(tupleClass, fieldSerializers);
- }
-
- @Override
- public TupleSerializer<T> duplicate() {
- boolean stateful = false;
- TypeSerializer<?>[] duplicateFieldSerializers = new TypeSerializer<?>[fieldSerializers.length];
-
- for (int i = 0; i < fieldSerializers.length; i++) {
- duplicateFieldSerializers[i] = fieldSerializers[i].duplicate();
- if (duplicateFieldSerializers[i] != fieldSerializers[i]) {
- // at least one of them is stateful
- stateful = true;
- }
- }
-
- if (stateful) {
- return new TupleSerializer<T>(tupleClass, duplicateFieldSerializers);
- } else {
- return this;
- }
- }
-
- @Override
- public T createInstance() {
- try {
- T t = tupleClass.newInstance();
-
- for (int i = 0; i < arity; i++) {
- t.setField(fieldSerializers[i].createInstance(), i);
- }
-
- return t;
- }
- catch (Exception e) {
- throw new RuntimeException("Cannot instantiate tuple.", e);
- }
- }
-
- @Override
- public T createInstance(Object[] fields) {
-
- try {
- T t = tupleClass.newInstance();
-
- for (int i = 0; i < arity; i++) {
- t.setField(fields[i], i);
- }
-
- return t;
- }
- catch (Exception e) {
- throw new RuntimeException("Cannot instantiate tuple.", e);
- }
- }
-
- @Override
- public T createOrReuseInstance(Object[] fields, T reuse) {
- for (int i = 0; i < arity; i++) {
- reuse.setField(fields[i], i);
- }
- return reuse;
- }
-
- @Override
- public T copy(T from) {
- T target = instantiateRaw();
- for (int i = 0; i < arity; i++) {
- Object copy = fieldSerializers[i].copy(from.getField(i));
- target.setField(copy, i);
- }
- return target;
- }
-
- @Override
- public T copy(T from, T reuse) {
- for (int i = 0; i < arity; i++) {
- Object copy = fieldSerializers[i].copy(from.getField(i), reuse.getField(i));
- reuse.setField(copy, i);
- }
-
- return reuse;
- }
-
- @Override
- public void serialize(T value, DataOutputView target) throws IOException {
- for (int i = 0; i < arity; i++) {
- Object o = value.getField(i);
- try {
- fieldSerializers[i].serialize(o, target);
- } catch (NullPointerException npex) {
- throw new NullFieldException(i, npex);
- }
- }
- }
-
- @Override
- public T deserialize(DataInputView source) throws IOException {
- T tuple = instantiateRaw();
- for (int i = 0; i < arity; i++) {
- Object field = fieldSerializers[i].deserialize(source);
- tuple.setField(field, i);
- }
- return tuple;
- }
-
- @Override
- public T deserialize(T reuse, DataInputView source) throws IOException {
- for (int i = 0; i < arity; i++) {
- Object field = fieldSerializers[i].deserialize(reuse.getField(i), source);
- reuse.setField(field, i);
- }
- return reuse;
- }
-
- private T instantiateRaw() {
- try {
- return tupleClass.newInstance();
- }
- catch (Exception e) {
- throw new RuntimeException("Cannot instantiate tuple.", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java
deleted file mode 100644
index fc657a1..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java
+++ /dev/null
@@ -1,102 +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.java.typeutils.runtime;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Objects;
-
-
-public abstract class TupleSerializerBase<T> extends TypeSerializer<T> {
-
- private static final long serialVersionUID = 1L;
-
- protected final Class<T> tupleClass;
-
- protected final TypeSerializer<Object>[] fieldSerializers;
-
- protected final int arity;
-
- @SuppressWarnings("unchecked")
- public TupleSerializerBase(Class<T> tupleClass, TypeSerializer<?>[] fieldSerializers) {
- this.tupleClass = Preconditions.checkNotNull(tupleClass);
- this.fieldSerializers = (TypeSerializer<Object>[]) Preconditions.checkNotNull(fieldSerializers);
- this.arity = fieldSerializers.length;
- }
-
- public Class<T> getTupleClass() {
- return this.tupleClass;
- }
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
- public int getArity() {
- return arity;
- }
-
- // We use this in the Aggregate and Distinct Operators to create instances
- // of immutable Typles (i.e. Scala Tuples)
- public abstract T createInstance(Object[] fields);
-
- public abstract T createOrReuseInstance(Object[] fields, T reuse);
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- for (int i = 0; i < arity; i++) {
- fieldSerializers[i].copy(source, target);
- }
- }
-
- @Override
- public int hashCode() {
- return 31 * Arrays.hashCode(fieldSerializers) + Objects.hash(tupleClass, arity);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TupleSerializerBase) {
- TupleSerializerBase<?> other = (TupleSerializerBase<?>) obj;
-
- return other.canEqual(this) &&
- tupleClass == other.tupleClass &&
- Arrays.equals(fieldSerializers, other.fieldSerializers) &&
- arity == other.arity;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof TupleSerializerBase;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java
deleted file mode 100644
index 4b9629a..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java
+++ /dev/null
@@ -1,183 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.types.NormalizableKey;
-import org.apache.flink.types.Value;
-import org.apache.flink.util.InstantiationUtil;
-
-import com.esotericsoftware.kryo.Kryo;
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-/**
- * Comparator for all Value types that extend Key
- */
-public class ValueComparator<T extends Value & Comparable<T>> extends TypeComparator<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> type;
-
- private final boolean ascendingComparison;
-
- private transient T reference;
-
- private transient T tempReference;
-
- private transient Kryo kryo;
-
- @SuppressWarnings("rawtypes")
- private final TypeComparator[] comparators = new TypeComparator[] {this};
-
- public ValueComparator(boolean ascending, Class<T> type) {
- this.type = type;
- this.ascendingComparison = ascending;
- }
-
- @Override
- public int hash(T record) {
- return record.hashCode();
- }
-
- @Override
- public void setReference(T toCompare) {
- checkKryoInitialized();
-
- reference = KryoUtils.copy(toCompare, kryo, new ValueSerializer<T>(type));
- }
-
- @Override
- public boolean equalToReference(T candidate) {
- return candidate.equals(this.reference);
- }
-
- @Override
- public int compareToReference(TypeComparator<T> referencedComparator) {
- T otherRef = ((ValueComparator<T>) referencedComparator).reference;
- int comp = otherRef.compareTo(reference);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public int compare(T first, T second) {
- int comp = first.compareTo(second);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
- if (reference == null) {
- reference = InstantiationUtil.instantiate(type, Value.class);
- }
- if (tempReference == null) {
- tempReference = InstantiationUtil.instantiate(type, Value.class);
- }
-
- reference.read(firstSource);
- tempReference.read(secondSource);
- int comp = reference.compareTo(tempReference);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public boolean supportsNormalizedKey() {
- return NormalizableKey.class.isAssignableFrom(type);
- }
-
- @Override
- public int getNormalizeKeyLen() {
- if (reference == null) {
- reference = InstantiationUtil.instantiate(type, Value.class);
- }
-
- NormalizableKey<?> key = (NormalizableKey<?>) reference;
- return key.getMaxNormalizedKeyLen();
- }
-
- @Override
- public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
- return keyBytes < getNormalizeKeyLen();
- }
-
- @Override
- public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
- NormalizableKey<?> key = (NormalizableKey<?>) record;
- key.copyNormalizedKey(target, offset, numBytes);
- }
-
- @Override
- public boolean invertNormalizedKey() {
- return !ascendingComparison;
- }
-
- @Override
- public TypeComparator<T> duplicate() {
- return new ValueComparator<T>(ascendingComparison, type);
- }
-
- private void checkKryoInitialized() {
- if (this.kryo == null) {
- this.kryo = new Kryo();
-
- Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
- instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
- kryo.setInstantiatorStrategy(instantiatorStrategy);
-
- this.kryo.setAsmEnabled(true);
- this.kryo.register(type);
- }
- }
-
- @Override
- public int extractKeys(Object record, Object[] target, int index) {
- target[index] = record;
- return 1;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public TypeComparator[] getFlatComparators() {
- return comparators;
- }
-
- // --------------------------------------------------------------------------------------------
- // unsupported normalization
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean supportsSerializationWithKeyNormalization() {
- return false;
- }
-
- @Override
- public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
- throw new UnsupportedOperationException();
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java
deleted file mode 100644
index 9329866..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java
+++ /dev/null
@@ -1,152 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import com.google.common.base.Preconditions;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.types.Value;
-import org.apache.flink.util.InstantiationUtil;
-
-import com.esotericsoftware.kryo.Kryo;
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-/**
- * Serializer for {@link Value} types. Uses the value's serialization methods, and uses
- * Kryo for deep object copies.
- *
- * @param <T> The type serialized.
- */
-public class ValueSerializer<T extends Value> extends TypeSerializer<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> type;
-
- private transient Kryo kryo;
-
- private transient T copyInstance;
-
- // --------------------------------------------------------------------------------------------
-
- public ValueSerializer(Class<T> type) {
- this.type = Preconditions.checkNotNull(type);
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public ValueSerializer<T> duplicate() {
- return new ValueSerializer<T>(type);
- }
-
- @Override
- public T createInstance() {
- return InstantiationUtil.instantiate(this.type);
- }
-
- @Override
- public T copy(T from) {
- checkKryoInitialized();
-
- return KryoUtils.copy(from, kryo, this);
- }
-
- @Override
- public T copy(T from, T reuse) {
- checkKryoInitialized();
-
- return KryoUtils.copy(from, reuse, kryo, this);
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
- @Override
- public void serialize(T value, DataOutputView target) throws IOException {
- value.write(target);
- }
-
- @Override
- public T deserialize(DataInputView source) throws IOException {
- return deserialize(createInstance(), source);
- }
-
- @Override
- public T deserialize(T reuse, DataInputView source) throws IOException {
- reuse.read(source);
- return reuse;
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- if (this.copyInstance == null) {
- this.copyInstance = InstantiationUtil.instantiate(type);
- }
-
- this.copyInstance.read(source);
- this.copyInstance.write(target);
- }
-
- private void checkKryoInitialized() {
- if (this.kryo == null) {
- this.kryo = new Kryo();
-
- Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
- instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
- kryo.setInstantiatorStrategy(instantiatorStrategy);
-
- this.kryo.setAsmEnabled(true);
- this.kryo.register(type);
- }
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return this.type.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ValueSerializer) {
- ValueSerializer<?> other = (ValueSerializer<?>) obj;
-
- return other.canEqual(this) && type == other.type;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof ValueSerializer;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java
deleted file mode 100644
index a03369a..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java
+++ /dev/null
@@ -1,189 +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.java.typeutils.runtime;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.types.NormalizableKey;
-import org.apache.flink.util.InstantiationUtil;
-import org.apache.hadoop.io.Writable;
-
-import com.esotericsoftware.kryo.Kryo;
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-public class WritableComparator<T extends Writable & Comparable<T>> extends TypeComparator<T> {
-
- private static final long serialVersionUID = 1L;
-
- private Class<T> type;
-
- private final boolean ascendingComparison;
-
- private transient T reference;
-
- private transient T tempReference;
-
- private transient Kryo kryo;
-
- @SuppressWarnings("rawtypes")
- private final TypeComparator[] comparators = new TypeComparator[] {this};
-
- public WritableComparator(boolean ascending, Class<T> type) {
- this.type = type;
- this.ascendingComparison = ascending;
- }
-
- @Override
- public int hash(T record) {
- return record.hashCode();
- }
-
- @Override
- public void setReference(T toCompare) {
- checkKryoInitialized();
-
- reference = KryoUtils.copy(toCompare, kryo, new WritableSerializer<T>(type));
- }
-
- @Override
- public boolean equalToReference(T candidate) {
- return candidate.equals(reference);
- }
-
- @Override
- public int compareToReference(TypeComparator<T> referencedComparator) {
- T otherRef = ((WritableComparator<T>) referencedComparator).reference;
- int comp = otherRef.compareTo(reference);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public int compare(T first, T second) {
- int comp = first.compareTo(second);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
- ensureReferenceInstantiated();
- ensureTempReferenceInstantiated();
-
- reference.readFields(firstSource);
- tempReference.readFields(secondSource);
-
- int comp = reference.compareTo(tempReference);
- return ascendingComparison ? comp : -comp;
- }
-
- @Override
- public boolean supportsNormalizedKey() {
- return NormalizableKey.class.isAssignableFrom(type);
- }
-
- @Override
- public int getNormalizeKeyLen() {
- ensureReferenceInstantiated();
-
- NormalizableKey<?> key = (NormalizableKey<?>) reference;
- return key.getMaxNormalizedKeyLen();
- }
-
- @Override
- public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
- return keyBytes < getNormalizeKeyLen();
- }
-
- @Override
- public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
- NormalizableKey<?> key = (NormalizableKey<?>) record;
- key.copyNormalizedKey(target, offset, numBytes);
- }
-
- @Override
- public boolean invertNormalizedKey() {
- return !ascendingComparison;
- }
-
- @Override
- public TypeComparator<T> duplicate() {
- return new WritableComparator<T>(ascendingComparison, type);
- }
-
- @Override
- public int extractKeys(Object record, Object[] target, int index) {
- target[index] = record;
- return 1;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public TypeComparator[] getFlatComparators() {
- return comparators;
- }
-
- // --------------------------------------------------------------------------------------------
- // unsupported normalization
- // --------------------------------------------------------------------------------------------
-
- @Override
- public boolean supportsSerializationWithKeyNormalization() {
- return false;
- }
-
- @Override
- public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- // --------------------------------------------------------------------------------------------
-
- private void checkKryoInitialized() {
- if (this.kryo == null) {
- this.kryo = new Kryo();
-
- Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
- instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
- kryo.setInstantiatorStrategy(instantiatorStrategy);
-
- this.kryo.setAsmEnabled(true);
- this.kryo.register(type);
- }
- }
-
- private void ensureReferenceInstantiated() {
- if (reference == null) {
- reference = InstantiationUtil.instantiate(type, Writable.class);
- }
- }
-
- private void ensureTempReferenceInstantiated() {
- if (tempReference == null) {
- tempReference = InstantiationUtil.instantiate(type, Writable.class);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java
deleted file mode 100644
index 258d92c..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializer.java
+++ /dev/null
@@ -1,153 +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.java.typeutils.runtime;
-
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.util.InstantiationUtil;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.io.Writable;
-
-import com.esotericsoftware.kryo.Kryo;
-import org.objenesis.strategy.StdInstantiatorStrategy;
-
-import java.io.IOException;
-
-public class WritableSerializer<T extends Writable> extends TypeSerializer<T> {
-
- private static final long serialVersionUID = 1L;
-
- private final Class<T> typeClass;
-
- private transient Kryo kryo;
-
- private transient T copyInstance;
-
- public WritableSerializer(Class<T> typeClass) {
- this.typeClass = typeClass;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T createInstance() {
- if(typeClass == NullWritable.class) {
- return (T) NullWritable.get();
- }
- return InstantiationUtil.instantiate(typeClass);
- }
-
-
-
- @Override
- public T copy(T from) {
- checkKryoInitialized();
-
- return KryoUtils.copy(from, kryo, this);
- }
-
- @Override
- public T copy(T from, T reuse) {
- checkKryoInitialized();
-
- return KryoUtils.copy(from, reuse, kryo, this);
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
- @Override
- public void serialize(T record, DataOutputView target) throws IOException {
- record.write(target);
- }
-
- @Override
- public T deserialize(DataInputView source) throws IOException {
- return deserialize(createInstance(), source);
- }
-
- @Override
- public T deserialize(T reuse, DataInputView source) throws IOException {
- reuse.readFields(source);
- return reuse;
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- ensureInstanceInstantiated();
- copyInstance.readFields(source);
- copyInstance.write(target);
- }
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public WritableSerializer<T> duplicate() {
- return new WritableSerializer<T>(typeClass);
- }
-
- // --------------------------------------------------------------------------------------------
-
- private void ensureInstanceInstantiated() {
- if (copyInstance == null) {
- copyInstance = createInstance();
- }
- }
-
- private void checkKryoInitialized() {
- if (this.kryo == null) {
- this.kryo = new Kryo();
-
- Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
- instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
- kryo.setInstantiatorStrategy(instantiatorStrategy);
-
- this.kryo.setAsmEnabled(true);
- this.kryo.register(typeClass);
- }
- }
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return this.typeClass.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof WritableSerializer) {
- WritableSerializer<?> other = (WritableSerializer<?>) obj;
-
- return other.canEqual(this) && typeClass == other.typeClass;
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof WritableSerializer;
- }
-}
[10/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
deleted file mode 100644
index b8f2075..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
+++ /dev/null
@@ -1,1687 +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.java.typeutils;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.avro.specific.SpecificRecordBase;
-import org.apache.commons.lang3.ClassUtils;
-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.FlatMapFunction;
-import org.apache.flink.api.common.functions.FoldFunction;
-import org.apache.flink.api.common.functions.Function;
-import org.apache.flink.api.common.functions.GroupCombineFunction;
-import org.apache.flink.api.common.functions.GroupReduceFunction;
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.api.common.functions.JoinFunction;
-import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.functions.MapPartitionFunction;
-import org.apache.flink.api.common.functions.Partitioner;
-import org.apache.flink.api.common.functions.util.FunctionUtils;
-import org.apache.flink.api.common.io.InputFormat;
-import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.api.java.tuple.Tuple0;
-import org.apache.flink.types.Value;
-import org.apache.flink.util.Collector;
-import org.apache.hadoop.io.Writable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-
-/**
- * A utility for reflection analysis on classes, to determine the return type of implementations of transformation
- * functions.
- */
-public class TypeExtractor {
-
- /*
- * NOTE: Most methods of the TypeExtractor work with a so-called "typeHierarchy".
- * The type hierarchy describes all types (Classes, ParameterizedTypes, TypeVariables etc. ) and intermediate
- * types from a given type of a function or type (e.g. MyMapper, Tuple2) until a current type
- * (depends on the method, e.g. MyPojoFieldType).
- *
- * Thus, it fully qualifies types until tuple/POJO field level.
- *
- * A typical typeHierarchy could look like:
- *
- * UDF: MyMapFunction.class
- * top-level UDF: MyMapFunctionBase.class
- * RichMapFunction: RichMapFunction.class
- * MapFunction: MapFunction.class
- * Function's OUT: Tuple1<MyPojo>
- * user-defined POJO: MyPojo.class
- * user-defined top-level POJO: MyPojoBase.class
- * POJO field: Tuple1<String>
- * Field type: String.class
- *
- */
-
- private static final Logger LOG = LoggerFactory.getLogger(TypeExtractor.class);
-
- protected TypeExtractor() {
- // only create instances for special use cases
- }
-
- // --------------------------------------------------------------------------------------------
- // Function specific methods
- // --------------------------------------------------------------------------------------------
-
- public static <IN, OUT> TypeInformation<OUT> getMapReturnTypes(MapFunction<IN, OUT> mapInterface, TypeInformation<IN> inType) {
- return getMapReturnTypes(mapInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getMapReturnTypes(MapFunction<IN, OUT> mapInterface, TypeInformation<IN> inType,
- String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) mapInterface, MapFunction.class, false, false, inType, functionName, allowMissing);
- }
-
-
- public static <IN, OUT> TypeInformation<OUT> getFlatMapReturnTypes(FlatMapFunction<IN, OUT> flatMapInterface, TypeInformation<IN> inType) {
- return getFlatMapReturnTypes(flatMapInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getFlatMapReturnTypes(FlatMapFunction<IN, OUT> flatMapInterface, TypeInformation<IN> inType,
- String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) flatMapInterface, FlatMapFunction.class, false, true, inType, functionName, allowMissing);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getFoldReturnTypes(FoldFunction<IN, OUT> foldInterface, TypeInformation<IN> inType)
- {
- return getFoldReturnTypes(foldInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getFoldReturnTypes(FoldFunction<IN, OUT> foldInterface, TypeInformation<IN> inType, String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) foldInterface, FoldFunction.class, false, false, inType, functionName, allowMissing);
- }
-
-
- public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType) {
- return getMapPartitionReturnTypes(mapPartitionInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType,
- String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) mapPartitionInterface, MapPartitionFunction.class, true, true, inType, functionName, allowMissing);
- }
-
-
- public static <IN, OUT> TypeInformation<OUT> getGroupReduceReturnTypes(GroupReduceFunction<IN, OUT> groupReduceInterface, TypeInformation<IN> inType) {
- return getGroupReduceReturnTypes(groupReduceInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getGroupReduceReturnTypes(GroupReduceFunction<IN, OUT> groupReduceInterface, TypeInformation<IN> inType,
- String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) groupReduceInterface, GroupReduceFunction.class, true, true, inType, functionName, allowMissing);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getGroupCombineReturnTypes(GroupCombineFunction<IN, OUT> combineInterface, TypeInformation<IN> inType) {
- return getGroupCombineReturnTypes(combineInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getGroupCombineReturnTypes(GroupCombineFunction<IN, OUT> combineInterface, TypeInformation<IN> inType,
- String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) combineInterface, GroupCombineFunction.class, true, true, inType, functionName, allowMissing);
- }
-
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getFlatJoinReturnTypes(FlatJoinFunction<IN1, IN2, OUT> joinInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
- {
- return getFlatJoinReturnTypes(joinInterface, in1Type, in2Type, null, false);
- }
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getFlatJoinReturnTypes(FlatJoinFunction<IN1, IN2, OUT> joinInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
- {
- return getBinaryOperatorReturnType((Function) joinInterface, FlatJoinFunction.class, false, true,
- in1Type, in2Type, functionName, allowMissing);
- }
-
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getJoinReturnTypes(JoinFunction<IN1, IN2, OUT> joinInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
- {
- return getJoinReturnTypes(joinInterface, in1Type, in2Type, null, false);
- }
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getJoinReturnTypes(JoinFunction<IN1, IN2, OUT> joinInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
- {
- return getBinaryOperatorReturnType((Function) joinInterface, JoinFunction.class, false, false,
- in1Type, in2Type, functionName, allowMissing);
- }
-
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getCoGroupReturnTypes(CoGroupFunction<IN1, IN2, OUT> coGroupInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
- {
- return getCoGroupReturnTypes(coGroupInterface, in1Type, in2Type, null, false);
- }
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getCoGroupReturnTypes(CoGroupFunction<IN1, IN2, OUT> coGroupInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
- {
- return getBinaryOperatorReturnType((Function) coGroupInterface, CoGroupFunction.class, true, true,
- in1Type, in2Type, functionName, allowMissing);
- }
-
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getCrossReturnTypes(CrossFunction<IN1, IN2, OUT> crossInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type)
- {
- return getCrossReturnTypes(crossInterface, in1Type, in2Type, null, false);
- }
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> getCrossReturnTypes(CrossFunction<IN1, IN2, OUT> crossInterface,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type, String functionName, boolean allowMissing)
- {
- return getBinaryOperatorReturnType((Function) crossInterface, CrossFunction.class, false, false,
- in1Type, in2Type, functionName, allowMissing);
- }
-
-
- public static <IN, OUT> TypeInformation<OUT> getKeySelectorTypes(KeySelector<IN, OUT> selectorInterface, TypeInformation<IN> inType) {
- return getKeySelectorTypes(selectorInterface, inType, null, false);
- }
-
- public static <IN, OUT> TypeInformation<OUT> getKeySelectorTypes(KeySelector<IN, OUT> selectorInterface,
- TypeInformation<IN> inType, String functionName, boolean allowMissing)
- {
- return getUnaryOperatorReturnType((Function) selectorInterface, KeySelector.class, false, false, inType, functionName, allowMissing);
- }
-
-
- public static <T> TypeInformation<T> getPartitionerTypes(Partitioner<T> partitioner) {
- return getPartitionerTypes(partitioner, null, false);
- }
-
- public static <T> TypeInformation<T> getPartitionerTypes(Partitioner<T> partitioner, String functionName, boolean allowMissing) {
- return new TypeExtractor().privateCreateTypeInfo(Partitioner.class, partitioner.getClass(), 0, null, null);
- }
-
-
- @SuppressWarnings("unchecked")
- public static <IN> TypeInformation<IN> getInputFormatTypes(InputFormat<IN, ?> inputFormatInterface) {
- if (inputFormatInterface instanceof ResultTypeQueryable) {
- return ((ResultTypeQueryable<IN>) inputFormatInterface).getProducedType();
- }
- return new TypeExtractor().privateCreateTypeInfo(InputFormat.class, inputFormatInterface.getClass(), 0, null, null);
- }
-
- // --------------------------------------------------------------------------------------------
- // Generic extraction methods
- // --------------------------------------------------------------------------------------------
-
- @SuppressWarnings("unchecked")
- public static <IN, OUT> TypeInformation<OUT> getUnaryOperatorReturnType(Function function, Class<?> baseClass,
- boolean hasIterable, boolean hasCollector, TypeInformation<IN> inType,
- String functionName, boolean allowMissing)
- {
- try {
- final Method m = FunctionUtils.checkAndExtractLambdaMethod(function);
- if (m != null) {
- // check for lambda type erasure
- validateLambdaGenericParameters(m);
-
- // parameters must be accessed from behind, since JVM can add additional parameters e.g. when using local variables inside lambda function
- final int paramLen = m.getGenericParameterTypes().length - 1;
- final Type input = (hasCollector)? m.getGenericParameterTypes()[paramLen - 1] : m.getGenericParameterTypes()[paramLen];
- validateInputType((hasIterable)?removeGenericWrapper(input) : input, inType);
- if(function instanceof ResultTypeQueryable) {
- return ((ResultTypeQueryable<OUT>) function).getProducedType();
- }
- return new TypeExtractor().privateCreateTypeInfo((hasCollector)? removeGenericWrapper(m.getGenericParameterTypes()[paramLen]) : m.getGenericReturnType(), inType, null);
- }
- else {
- validateInputType(baseClass, function.getClass(), 0, inType);
- if(function instanceof ResultTypeQueryable) {
- return ((ResultTypeQueryable<OUT>) function).getProducedType();
- }
- return new TypeExtractor().privateCreateTypeInfo(baseClass, function.getClass(), 1, inType, null);
- }
- }
- catch (InvalidTypesException e) {
- if (allowMissing) {
- return (TypeInformation<OUT>) new MissingTypeInfo(functionName != null ? functionName : function.toString(), e);
- } else {
- throw e;
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public static <IN1, IN2, OUT> TypeInformation<OUT> getBinaryOperatorReturnType(Function function, Class<?> baseClass,
- boolean hasIterables, boolean hasCollector, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type,
- String functionName, boolean allowMissing)
- {
- try {
- final Method m = FunctionUtils.checkAndExtractLambdaMethod(function);
- if (m != null) {
- // check for lambda type erasure
- validateLambdaGenericParameters(m);
-
- // parameters must be accessed from behind, since JVM can add additional parameters e.g. when using local variables inside lambda function
- final int paramLen = m.getGenericParameterTypes().length - 1;
- final Type input1 = (hasCollector)? m.getGenericParameterTypes()[paramLen - 2] : m.getGenericParameterTypes()[paramLen - 1];
- final Type input2 = (hasCollector)? m.getGenericParameterTypes()[paramLen - 1] : m.getGenericParameterTypes()[paramLen];
- validateInputType((hasIterables)? removeGenericWrapper(input1) : input1, in1Type);
- validateInputType((hasIterables)? removeGenericWrapper(input2) : input2, in2Type);
- if(function instanceof ResultTypeQueryable) {
- return ((ResultTypeQueryable<OUT>) function).getProducedType();
- }
- return new TypeExtractor().privateCreateTypeInfo((hasCollector)? removeGenericWrapper(m.getGenericParameterTypes()[paramLen]) : m.getGenericReturnType(), in1Type, in2Type);
- }
- else {
- validateInputType(baseClass, function.getClass(), 0, in1Type);
- validateInputType(baseClass, function.getClass(), 1, in2Type);
- if(function instanceof ResultTypeQueryable) {
- return ((ResultTypeQueryable<OUT>) function).getProducedType();
- }
- return new TypeExtractor().privateCreateTypeInfo(baseClass, function.getClass(), 2, in1Type, in2Type);
- }
- }
- catch (InvalidTypesException e) {
- if (allowMissing) {
- return (TypeInformation<OUT>) new MissingTypeInfo(functionName != null ? functionName : function.toString(), e);
- } else {
- throw e;
- }
- }
- }
-
- // --------------------------------------------------------------------------------------------
- // Create type information
- // --------------------------------------------------------------------------------------------
-
- @SuppressWarnings("unchecked")
- public static <T> TypeInformation<T> createTypeInfo(Class<T> type) {
- return (TypeInformation<T>) createTypeInfo((Type) type);
- }
-
- public static TypeInformation<?> createTypeInfo(Type t) {
- TypeInformation<?> ti = new TypeExtractor().privateCreateTypeInfo(t);
- if (ti == null) {
- throw new InvalidTypesException("Could not extract type information.");
- }
- return ti;
- }
-
- /**
- * Creates a {@link TypeInformation} from the given parameters.
- *
- * If the given {@code instance} implements {@link ResultTypeQueryable}, its information
- * is used to determine the type information. Otherwise, the type information is derived
- * based on the given class information.
- *
- * @param instance instance to determine type information for
- * @param baseClass base class of {@code instance}
- * @param clazz class of {@code instance}
- * @param returnParamPos index of the return type in the type arguments of {@code clazz}
- * @param <OUT> output type
- * @return type information
- */
- @SuppressWarnings("unchecked")
- public static <OUT> TypeInformation<OUT> createTypeInfo(Object instance, Class<?> baseClass, Class<?> clazz, int returnParamPos) {
- if (instance instanceof ResultTypeQueryable) {
- return ((ResultTypeQueryable<OUT>) instance).getProducedType();
- } else {
- return createTypeInfo(baseClass, clazz, returnParamPos, null, null);
- }
- }
-
- public static <IN1, IN2, OUT> TypeInformation<OUT> createTypeInfo(Class<?> baseClass, Class<?> clazz, int returnParamPos,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
- TypeInformation<OUT> ti = new TypeExtractor().privateCreateTypeInfo(baseClass, clazz, returnParamPos, in1Type, in2Type);
- if (ti == null) {
- throw new InvalidTypesException("Could not extract type information.");
- }
- return ti;
- }
-
- // ----------------------------------- private methods ----------------------------------------
-
- private TypeInformation<?> privateCreateTypeInfo(Type t) {
- ArrayList<Type> typeHierarchy = new ArrayList<Type>();
- typeHierarchy.add(t);
- return createTypeInfoWithTypeHierarchy(typeHierarchy, t, null, null);
- }
-
- // for (Rich)Functions
- @SuppressWarnings("unchecked")
- private <IN1, IN2, OUT> TypeInformation<OUT> privateCreateTypeInfo(Class<?> baseClass, Class<?> clazz, int returnParamPos,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
- ArrayList<Type> typeHierarchy = new ArrayList<Type>();
- Type returnType = getParameterType(baseClass, typeHierarchy, clazz, returnParamPos);
-
- TypeInformation<OUT> typeInfo;
-
- // return type is a variable -> try to get the type info from the input directly
- if (returnType instanceof TypeVariable<?>) {
- typeInfo = (TypeInformation<OUT>) createTypeInfoFromInputs((TypeVariable<?>) returnType, typeHierarchy, in1Type, in2Type);
-
- if (typeInfo != null) {
- return typeInfo;
- }
- }
-
- // get info from hierarchy
- return (TypeInformation<OUT>) createTypeInfoWithTypeHierarchy(typeHierarchy, returnType, in1Type, in2Type);
- }
-
- // for LambdaFunctions
- @SuppressWarnings("unchecked")
- private <IN1, IN2, OUT> TypeInformation<OUT> privateCreateTypeInfo(Type returnType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
- ArrayList<Type> typeHierarchy = new ArrayList<Type>();
-
- // get info from hierarchy
- return (TypeInformation<OUT>) createTypeInfoWithTypeHierarchy(typeHierarchy, returnType, in1Type, in2Type);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private <IN1, IN2, OUT> TypeInformation<OUT> createTypeInfoWithTypeHierarchy(ArrayList<Type> typeHierarchy, Type t,
- TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
-
- // check if type is a subclass of tuple
- if (isClassType(t) && Tuple.class.isAssignableFrom(typeToClass(t))) {
- Type curT = t;
-
- // do not allow usage of Tuple as type
- if (typeToClass(t).equals(Tuple.class)) {
- throw new InvalidTypesException(
- "Usage of class Tuple as a type is not allowed. Use a concrete subclass (e.g. Tuple1, Tuple2, etc.) instead.");
- }
-
- // go up the hierarchy until we reach immediate child of Tuple (with or without generics)
- // collect the types while moving up for a later top-down
- while (!(isClassType(curT) && typeToClass(curT).getSuperclass().equals(Tuple.class))) {
- typeHierarchy.add(curT);
- curT = typeToClass(curT).getGenericSuperclass();
- }
-
- if(curT == Tuple0.class) {
- return new TupleTypeInfo(Tuple0.class, new TypeInformation<?>[0]);
- }
-
- // check if immediate child of Tuple has generics
- if (curT instanceof Class<?>) {
- throw new InvalidTypesException("Tuple needs to be parameterized by using generics.");
- }
-
- typeHierarchy.add(curT);
-
- // create the type information for the subtypes
- TypeInformation<?>[] subTypesInfo = createSubTypesInfo(t, (ParameterizedType) curT, typeHierarchy, in1Type, in2Type);
- // type needs to be treated a pojo due to additional fields
- if (subTypesInfo == null) {
- if (t instanceof ParameterizedType) {
- return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), (ParameterizedType) t, in1Type, in2Type);
- }
- else {
- return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), null, in1Type, in2Type);
- }
- }
- // return tuple info
- return new TupleTypeInfo(typeToClass(t), subTypesInfo);
-
- }
- // check if type is a subclass of Either
- else if (isClassType(t) && Either.class.isAssignableFrom(typeToClass(t))) {
- Type curT = t;
-
- // go up the hierarchy until we reach Either (with or without generics)
- // collect the types while moving up for a later top-down
- while (!(isClassType(curT) && typeToClass(curT).equals(Either.class))) {
- typeHierarchy.add(curT);
- curT = typeToClass(curT).getGenericSuperclass();
- }
-
- // check if Either has generics
- if (curT instanceof Class<?>) {
- throw new InvalidTypesException("Either needs to be parameterized by using generics.");
- }
-
- typeHierarchy.add(curT);
-
- // create the type information for the subtypes
- TypeInformation<?>[] subTypesInfo = createSubTypesInfo(t, (ParameterizedType) curT, typeHierarchy, in1Type, in2Type);
- // type needs to be treated a pojo due to additional fields
- if (subTypesInfo == null) {
- if (t instanceof ParameterizedType) {
- return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), (ParameterizedType) t, in1Type, in2Type);
- }
- else {
- return (TypeInformation<OUT>) analyzePojo(typeToClass(t), new ArrayList<Type>(typeHierarchy), null, in1Type, in2Type);
- }
- }
- // return either info
- return (TypeInformation<OUT>) new EitherTypeInfo(subTypesInfo[0], subTypesInfo[1]);
- }
- // type depends on another type
- // e.g. class MyMapper<E> extends MapFunction<String, E>
- else if (t instanceof TypeVariable) {
- Type typeVar = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) t);
-
- if (!(typeVar instanceof TypeVariable)) {
- return createTypeInfoWithTypeHierarchy(typeHierarchy, typeVar, in1Type, in2Type);
- }
- // try to derive the type info of the TypeVariable from the immediate base child input as a last attempt
- else {
- TypeInformation<OUT> typeInfo = (TypeInformation<OUT>) createTypeInfoFromInputs((TypeVariable<?>) t, typeHierarchy, in1Type, in2Type);
- if (typeInfo != null) {
- return typeInfo;
- } else {
- throw new InvalidTypesException("Type of TypeVariable '" + ((TypeVariable<?>) t).getName() + "' in '"
- + ((TypeVariable<?>) t).getGenericDeclaration() + "' could not be determined. This is most likely a type erasure problem. "
- + "The type extraction currently supports types with generic variables only in cases where "
- + "all variables in the return type can be deduced from the input type(s).");
- }
- }
- }
- // arrays with generics
- else if (t instanceof GenericArrayType) {
- GenericArrayType genericArray = (GenericArrayType) t;
-
- Type componentType = genericArray.getGenericComponentType();
-
- // due to a Java 6 bug, it is possible that the JVM classifies e.g. String[] or int[] as GenericArrayType instead of Class
- if (componentType instanceof Class) {
-
- Class<?> componentClass = (Class<?>) componentType;
- String className;
- // for int[], double[] etc.
- if(componentClass.isPrimitive()) {
- className = encodePrimitiveClass(componentClass);
- }
- // for String[], Integer[] etc.
- else {
- className = "L" + componentClass.getName() + ";";
- }
-
- Class<OUT> classArray;
- try {
- classArray = (Class<OUT>) Class.forName("[" + className);
- } catch (ClassNotFoundException e) {
- throw new InvalidTypesException("Could not convert GenericArrayType to Class.");
- }
-
- return getForClass(classArray);
- } else {
- TypeInformation<?> componentInfo = createTypeInfoWithTypeHierarchy(
- typeHierarchy,
- genericArray.getGenericComponentType(),
- in1Type,
- in2Type);
-
- Class<OUT> classArray;
-
- try {
- String componentClassName = componentInfo.getTypeClass().getName();
- String resultingClassName;
-
- if (componentClassName.startsWith("[")) {
- resultingClassName = "[" + componentClassName;
- } else {
- resultingClassName = "[L" + componentClassName + ";";
- }
- classArray = (Class<OUT>) Class.forName(resultingClassName);
- } catch (ClassNotFoundException e) {
- throw new InvalidTypesException("Could not convert GenericArrayType to Class.");
- }
-
- return ObjectArrayTypeInfo.getInfoFor(classArray, componentInfo);
- }
- }
- // objects with generics are treated as Class first
- else if (t instanceof ParameterizedType) {
- return (TypeInformation<OUT>) privateGetForClass(typeToClass(t), typeHierarchy, (ParameterizedType) t, in1Type, in2Type);
- }
- // no tuple, no TypeVariable, no generic type
- else if (t instanceof Class) {
- return privateGetForClass((Class<OUT>) t, typeHierarchy);
- }
-
- throw new InvalidTypesException("Type Information could not be created.");
- }
-
- private <IN1, IN2> TypeInformation<?> createTypeInfoFromInputs(TypeVariable<?> returnTypeVar, ArrayList<Type> returnTypeHierarchy,
- TypeInformation<IN1> in1TypeInfo, TypeInformation<IN2> in2TypeInfo) {
-
- Type matReturnTypeVar = materializeTypeVariable(returnTypeHierarchy, returnTypeVar);
-
- // variable could be resolved
- if (!(matReturnTypeVar instanceof TypeVariable)) {
- return createTypeInfoWithTypeHierarchy(returnTypeHierarchy, matReturnTypeVar, in1TypeInfo, in2TypeInfo);
- }
- else {
- returnTypeVar = (TypeVariable<?>) matReturnTypeVar;
- }
-
- // no input information exists
- if (in1TypeInfo == null && in2TypeInfo == null) {
- return null;
- }
-
- // create a new type hierarchy for the input
- ArrayList<Type> inputTypeHierarchy = new ArrayList<Type>();
- // copy the function part of the type hierarchy
- for (Type t : returnTypeHierarchy) {
- if (isClassType(t) && Function.class.isAssignableFrom(typeToClass(t)) && typeToClass(t) != Function.class) {
- inputTypeHierarchy.add(t);
- }
- else {
- break;
- }
- }
- ParameterizedType baseClass = (ParameterizedType) inputTypeHierarchy.get(inputTypeHierarchy.size() - 1);
-
- TypeInformation<?> info = null;
- if (in1TypeInfo != null) {
- // find the deepest type variable that describes the type of input 1
- Type in1Type = baseClass.getActualTypeArguments()[0];
-
- info = createTypeInfoFromInput(returnTypeVar, new ArrayList<Type>(inputTypeHierarchy), in1Type, in1TypeInfo);
- }
-
- if (info == null && in2TypeInfo != null) {
- // find the deepest type variable that describes the type of input 2
- Type in2Type = baseClass.getActualTypeArguments()[1];
-
- info = createTypeInfoFromInput(returnTypeVar, new ArrayList<Type>(inputTypeHierarchy), in2Type, in2TypeInfo);
- }
-
- if (info != null) {
- return info;
- }
-
- return null;
- }
-
- private <IN1> TypeInformation<?> createTypeInfoFromInput(TypeVariable<?> returnTypeVar, ArrayList<Type> inputTypeHierarchy, Type inType, TypeInformation<IN1> inTypeInfo) {
- TypeInformation<?> info = null;
-
- // the input is a type variable
- if (inType instanceof TypeVariable) {
- inType = materializeTypeVariable(inputTypeHierarchy, (TypeVariable<?>) inType);
- info = findCorrespondingInfo(returnTypeVar, inType, inTypeInfo, inputTypeHierarchy);
- }
- // input is an array
- else if (inType instanceof GenericArrayType) {
- TypeInformation<?> componentInfo = null;
- if (inTypeInfo instanceof BasicArrayTypeInfo) {
- componentInfo = ((BasicArrayTypeInfo<?,?>) inTypeInfo).getComponentInfo();
- }
- else if (inTypeInfo instanceof PrimitiveArrayTypeInfo) {
- componentInfo = BasicTypeInfo.getInfoFor(inTypeInfo.getTypeClass().getComponentType());
- }
- else if (inTypeInfo instanceof ObjectArrayTypeInfo) {
- componentInfo = ((ObjectArrayTypeInfo<?,?>) inTypeInfo).getComponentInfo();
- }
- info = createTypeInfoFromInput(returnTypeVar, inputTypeHierarchy, ((GenericArrayType) inType).getGenericComponentType(), componentInfo);
- }
- // the input is a tuple
- else if (inTypeInfo instanceof TupleTypeInfo && isClassType(inType)
- && Tuple.class.isAssignableFrom(typeToClass(inType))) {
- ParameterizedType tupleBaseClass;
-
- // get tuple from possible tuple subclass
- while (!(isClassType(inType) && typeToClass(inType).getSuperclass().equals(Tuple.class))) {
- inputTypeHierarchy.add(inType);
- inType = typeToClass(inType).getGenericSuperclass();
- }
- inputTypeHierarchy.add(inType);
-
- // we can assume to be parameterized since we
- // already did input validation
- tupleBaseClass = (ParameterizedType) inType;
-
- Type[] tupleElements = tupleBaseClass.getActualTypeArguments();
- // go thru all tuple elements and search for type variables
- for (int i = 0; i < tupleElements.length; i++) {
- info = createTypeInfoFromInput(returnTypeVar, inputTypeHierarchy, tupleElements[i], ((TupleTypeInfo<?>) inTypeInfo).getTypeAt(i));
- if(info != null) {
- break;
- }
- }
- }
- // the input is a pojo
- else if (inTypeInfo instanceof PojoTypeInfo) {
- // build the entire type hierarchy for the pojo
- getTypeHierarchy(inputTypeHierarchy, inType, Object.class);
- info = findCorrespondingInfo(returnTypeVar, inType, inTypeInfo, inputTypeHierarchy);
- }
- return info;
- }
-
- /**
- * Creates the TypeInformation for all elements of a type that expects a certain number of
- * subtypes (e.g. TupleXX or Either).
- *
- * @param originalType most concrete subclass
- * @param definingType type that defines the number of subtypes (e.g. Tuple2 -> 2 subtypes)
- * @param typeHierarchy necessary for type inference
- * @param in1Type necessary for type inference
- * @param in2Type necessary for type inference
- * @return array containing TypeInformation of sub types or null if definingType contains
- * more subtypes (fields) that defined
- */
- private <IN1, IN2> TypeInformation<?>[] createSubTypesInfo(Type originalType, ParameterizedType definingType,
- ArrayList<Type> typeHierarchy, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
- Type[] subtypes = new Type[definingType.getActualTypeArguments().length];
-
- // materialize possible type variables
- for (int i = 0; i < subtypes.length; i++) {
- // materialize immediate TypeVariables
- if (definingType.getActualTypeArguments()[i] instanceof TypeVariable<?>) {
- subtypes[i] = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) definingType.getActualTypeArguments()[i]);
- }
- // class or parameterized type
- else {
- subtypes[i] = definingType.getActualTypeArguments()[i];
- }
- }
-
- TypeInformation<?>[] subTypesInfo = new TypeInformation<?>[subtypes.length];
- for (int i = 0; i < subtypes.length; i++) {
- ArrayList<Type> subTypeHierarchy = new ArrayList<Type>(typeHierarchy);
- subTypeHierarchy.add(subtypes[i]);
- // sub type could not be determined with materializing
- // try to derive the type info of the TypeVariable from the immediate base child input as a last attempt
- if (subtypes[i] instanceof TypeVariable<?>) {
- subTypesInfo[i] = createTypeInfoFromInputs((TypeVariable<?>) subtypes[i], subTypeHierarchy, in1Type, in2Type);
-
- // variable could not be determined
- if (subTypesInfo[i] == null) {
- throw new InvalidTypesException("Type of TypeVariable '" + ((TypeVariable<?>) subtypes[i]).getName() + "' in '"
- + ((TypeVariable<?>) subtypes[i]).getGenericDeclaration()
- + "' could not be determined. This is most likely a type erasure problem. "
- + "The type extraction currently supports types with generic variables only in cases where "
- + "all variables in the return type can be deduced from the input type(s).");
- }
- } else {
- subTypesInfo[i] = createTypeInfoWithTypeHierarchy(subTypeHierarchy, subtypes[i], in1Type, in2Type);
- }
- }
-
- Class<?> originalTypeAsClass = null;
- if (isClassType(originalType)) {
- originalTypeAsClass = typeToClass(originalType);
- }
- Preconditions.checkNotNull(originalTypeAsClass, "originalType has an unexpected type");
- // check if the class we assumed to conform to the defining type so far is actually a pojo because the
- // original type contains additional fields.
- // check for additional fields.
- int fieldCount = countFieldsInClass(originalTypeAsClass);
- if(fieldCount > subTypesInfo.length) {
- return null;
- }
- return subTypesInfo;
- }
-
- // --------------------------------------------------------------------------------------------
- // Extract type parameters
- // --------------------------------------------------------------------------------------------
-
- public static Type getParameterType(Class<?> baseClass, Class<?> clazz, int pos) {
- return getParameterType(baseClass, null, clazz, pos);
- }
-
- private static Type getParameterType(Class<?> baseClass, ArrayList<Type> typeHierarchy, Class<?> clazz, int pos) {
- if (typeHierarchy != null) {
- typeHierarchy.add(clazz);
- }
- Type[] interfaceTypes = clazz.getGenericInterfaces();
-
- // search in interfaces for base class
- for (Type t : interfaceTypes) {
- Type parameter = getParameterTypeFromGenericType(baseClass, typeHierarchy, t, pos);
- if (parameter != null) {
- return parameter;
- }
- }
-
- // search in superclass for base class
- Type t = clazz.getGenericSuperclass();
- Type parameter = getParameterTypeFromGenericType(baseClass, typeHierarchy, t, pos);
- if (parameter != null) {
- return parameter;
- }
-
- throw new InvalidTypesException("The types of the interface " + baseClass.getName() + " could not be inferred. " +
- "Support for synthetic interfaces, lambdas, and generic or raw types is limited at this point");
- }
-
- private static Type getParameterTypeFromGenericType(Class<?> baseClass, ArrayList<Type> typeHierarchy, Type t, int pos) {
- // base class
- if (t instanceof ParameterizedType && baseClass.equals(((ParameterizedType) t).getRawType())) {
- if (typeHierarchy != null) {
- typeHierarchy.add(t);
- }
- ParameterizedType baseClassChild = (ParameterizedType) t;
- return baseClassChild.getActualTypeArguments()[pos];
- }
- // interface that extended base class as class or parameterized type
- else if (t instanceof ParameterizedType && baseClass.isAssignableFrom((Class<?>) ((ParameterizedType) t).getRawType())) {
- if (typeHierarchy != null) {
- typeHierarchy.add(t);
- }
- return getParameterType(baseClass, typeHierarchy, (Class<?>) ((ParameterizedType) t).getRawType(), pos);
- }
- else if (t instanceof Class<?> && baseClass.isAssignableFrom((Class<?>) t)) {
- if (typeHierarchy != null) {
- typeHierarchy.add(t);
- }
- return getParameterType(baseClass, typeHierarchy, (Class<?>) t, pos);
- }
- return null;
- }
-
- // --------------------------------------------------------------------------------------------
- // Validate input
- // --------------------------------------------------------------------------------------------
-
- private static void validateInputType(Type t, TypeInformation<?> inType) {
- ArrayList<Type> typeHierarchy = new ArrayList<Type>();
- try {
- validateInfo(typeHierarchy, t, inType);
- }
- catch(InvalidTypesException e) {
- throw new InvalidTypesException("Input mismatch: " + e.getMessage(), e);
- }
- }
-
- private static void validateInputType(Class<?> baseClass, Class<?> clazz, int inputParamPos, TypeInformation<?> inTypeInfo) {
- ArrayList<Type> typeHierarchy = new ArrayList<Type>();
-
- // try to get generic parameter
- Type inType;
- try {
- inType = getParameterType(baseClass, typeHierarchy, clazz, inputParamPos);
- }
- catch (InvalidTypesException e) {
- return; // skip input validation e.g. for raw types
- }
-
- try {
- validateInfo(typeHierarchy, inType, inTypeInfo);
- }
- catch(InvalidTypesException e) {
- throw new InvalidTypesException("Input mismatch: " + e.getMessage(), e);
- }
- }
-
- @SuppressWarnings("unchecked")
- private static void validateInfo(ArrayList<Type> typeHierarchy, Type type, TypeInformation<?> typeInfo) {
- if (type == null) {
- throw new InvalidTypesException("Unknown Error. Type is null.");
- }
-
- if (typeInfo == null) {
- throw new InvalidTypesException("Unknown Error. TypeInformation is null.");
- }
-
- if (!(type instanceof TypeVariable<?>)) {
- // check for basic type
- if (typeInfo.isBasicType()) {
-
- TypeInformation<?> actual;
- // check if basic type at all
- if (!(type instanceof Class<?>) || (actual = BasicTypeInfo.getInfoFor((Class<?>) type)) == null) {
- throw new InvalidTypesException("Basic type expected.");
- }
- // check if correct basic type
- if (!typeInfo.equals(actual)) {
- throw new InvalidTypesException("Basic type '" + typeInfo + "' expected but was '" + actual + "'.");
- }
-
- }
- // check for tuple
- else if (typeInfo.isTupleType()) {
- // check if tuple at all
- if (!(isClassType(type) && Tuple.class.isAssignableFrom(typeToClass(type)))) {
- throw new InvalidTypesException("Tuple type expected.");
- }
-
- // do not allow usage of Tuple as type
- if (isClassType(type) && typeToClass(type).equals(Tuple.class)) {
- throw new InvalidTypesException("Concrete subclass of Tuple expected.");
- }
-
- // go up the hierarchy until we reach immediate child of Tuple (with or without generics)
- while (!(isClassType(type) && typeToClass(type).getSuperclass().equals(Tuple.class))) {
- typeHierarchy.add(type);
- type = typeToClass(type).getGenericSuperclass();
- }
-
- if(type == Tuple0.class) {
- return;
- }
-
- // check if immediate child of Tuple has generics
- if (type instanceof Class<?>) {
- throw new InvalidTypesException("Parameterized Tuple type expected.");
- }
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) typeInfo;
-
- Type[] subTypes = ((ParameterizedType) type).getActualTypeArguments();
-
- if (subTypes.length != tti.getArity()) {
- throw new InvalidTypesException("Tuple arity '" + tti.getArity() + "' expected but was '"
- + subTypes.length + "'.");
- }
-
- for (int i = 0; i < subTypes.length; i++) {
- validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[i], tti.getTypeAt(i));
- }
- }
- // check for Either
- else if (typeInfo instanceof EitherTypeInfo) {
- // check if Either at all
- if (!(isClassType(type) && Either.class.isAssignableFrom(typeToClass(type)))) {
- throw new InvalidTypesException("Either type expected.");
- }
-
- // go up the hierarchy until we reach Either (with or without generics)
- while (!(isClassType(type) && typeToClass(type).equals(Either.class))) {
- typeHierarchy.add(type);
- type = typeToClass(type).getGenericSuperclass();
- }
-
- // check if Either has generics
- if (type instanceof Class<?>) {
- throw new InvalidTypesException("Parameterized Either type expected.");
- }
-
- EitherTypeInfo<?, ?> eti = (EitherTypeInfo<?, ?>) typeInfo;
- Type[] subTypes = ((ParameterizedType) type).getActualTypeArguments();
- validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[0], eti.getLeftType());
- validateInfo(new ArrayList<Type>(typeHierarchy), subTypes[1], eti.getRightType());
- }
- // check for Writable
- else if (typeInfo instanceof WritableTypeInfo<?>) {
- // check if writable at all
- if (!(type instanceof Class<?> && Writable.class.isAssignableFrom((Class<?>) type))) {
- throw new InvalidTypesException("Writable type expected.");
- }
-
- // check writable type contents
- Class<?> clazz;
- if (((WritableTypeInfo<?>) typeInfo).getTypeClass() != (clazz = (Class<?>) type)) {
- throw new InvalidTypesException("Writable type '"
- + ((WritableTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '"
- + clazz.getCanonicalName() + "'.");
- }
- }
- // check for primitive array
- else if (typeInfo instanceof PrimitiveArrayTypeInfo) {
- Type component;
- // check if array at all
- if (!(type instanceof Class<?> && ((Class<?>) type).isArray() && (component = ((Class<?>) type).getComponentType()) != null)
- && !(type instanceof GenericArrayType && (component = ((GenericArrayType) type).getGenericComponentType()) != null)) {
- throw new InvalidTypesException("Array type expected.");
- }
- if (component instanceof TypeVariable<?>) {
- component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);
- if (component instanceof TypeVariable) {
- return;
- }
- }
- if (!(component instanceof Class<?> && ((Class<?>)component).isPrimitive())) {
- throw new InvalidTypesException("Primitive component expected.");
- }
- }
- // check for basic array
- else if (typeInfo instanceof BasicArrayTypeInfo<?, ?>) {
- Type component;
- // check if array at all
- if (!(type instanceof Class<?> && ((Class<?>) type).isArray() && (component = ((Class<?>) type).getComponentType()) != null)
- && !(type instanceof GenericArrayType && (component = ((GenericArrayType) type).getGenericComponentType()) != null)) {
- throw new InvalidTypesException("Array type expected.");
- }
-
- if (component instanceof TypeVariable<?>) {
- component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);
- if (component instanceof TypeVariable) {
- return;
- }
- }
-
- validateInfo(typeHierarchy, component, ((BasicArrayTypeInfo<?, ?>) typeInfo).getComponentInfo());
-
- }
- // check for object array
- else if (typeInfo instanceof ObjectArrayTypeInfo<?, ?>) {
- // check if array at all
- if (!(type instanceof Class<?> && ((Class<?>) type).isArray()) && !(type instanceof GenericArrayType)) {
- throw new InvalidTypesException("Object array type expected.");
- }
-
- // check component
- Type component;
- if (type instanceof Class<?>) {
- component = ((Class<?>) type).getComponentType();
- } else {
- component = ((GenericArrayType) type).getGenericComponentType();
- }
-
- if (component instanceof TypeVariable<?>) {
- component = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) component);
- if (component instanceof TypeVariable) {
- return;
- }
- }
-
- validateInfo(typeHierarchy, component, ((ObjectArrayTypeInfo<?, ?>) typeInfo).getComponentInfo());
- }
- // check for value
- else if (typeInfo instanceof ValueTypeInfo<?>) {
- // check if value at all
- if (!(type instanceof Class<?> && Value.class.isAssignableFrom((Class<?>) type))) {
- throw new InvalidTypesException("Value type expected.");
- }
-
- TypeInformation<?> actual;
- // check value type contents
- if (!((ValueTypeInfo<?>) typeInfo).equals(actual = ValueTypeInfo.getValueTypeInfo((Class<? extends Value>) type))) {
- throw new InvalidTypesException("Value type '" + typeInfo + "' expected but was '" + actual + "'.");
- }
- }
- // check for POJO
- else if (typeInfo instanceof PojoTypeInfo) {
- Class<?> clazz = null;
- if (!(isClassType(type) && ((PojoTypeInfo<?>) typeInfo).getTypeClass() == (clazz = typeToClass(type)))) {
- throw new InvalidTypesException("POJO type '"
- + ((PojoTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '"
- + clazz.getCanonicalName() + "'.");
- }
- }
- // check for Enum
- else if (typeInfo instanceof EnumTypeInfo) {
- if (!(type instanceof Class<?> && Enum.class.isAssignableFrom((Class<?>) type))) {
- throw new InvalidTypesException("Enum type expected.");
- }
- // check enum type contents
- if (!(typeInfo.getTypeClass() == type)) {
- throw new InvalidTypesException("Enum type '" + typeInfo.getTypeClass().getCanonicalName() + "' expected but was '"
- + typeToClass(type).getCanonicalName() + "'.");
- }
- }
- // check for generic object
- else if (typeInfo instanceof GenericTypeInfo<?>) {
- Class<?> clazz = null;
- if (!(isClassType(type) && ((GenericTypeInfo<?>) typeInfo).getTypeClass() == (clazz = typeToClass(type)))) {
- throw new InvalidTypesException("Generic object type '"
- + ((GenericTypeInfo<?>) typeInfo).getTypeClass().getCanonicalName() + "' expected but was '"
- + clazz.getCanonicalName() + "'.");
- }
- }
- } else {
- type = materializeTypeVariable(typeHierarchy, (TypeVariable<?>) type);
- if (!(type instanceof TypeVariable)) {
- validateInfo(typeHierarchy, type, typeInfo);
- }
- }
- }
-
- // --------------------------------------------------------------------------------------------
- // Utility methods
- // --------------------------------------------------------------------------------------------
-
- /**
- * @return number of items with equal type or same raw type
- */
- private static int countTypeInHierarchy(ArrayList<Type> typeHierarchy, Type type) {
- int count = 0;
- for (Type t : typeHierarchy) {
- if (t == type || (isClassType(type) && t == typeToClass(type))) {
- count++;
- }
- }
- return count;
- }
-
- /**
- * @param curT : start type
- * @return Type The immediate child of the top class
- */
- private static Type getTypeHierarchy(ArrayList<Type> typeHierarchy, Type curT, Class<?> stopAtClass) {
- // skip first one
- if (typeHierarchy.size() > 0 && typeHierarchy.get(0) == curT && isClassType(curT)) {
- curT = typeToClass(curT).getGenericSuperclass();
- }
- while (!(isClassType(curT) && typeToClass(curT).equals(stopAtClass))) {
- typeHierarchy.add(curT);
- curT = typeToClass(curT).getGenericSuperclass();
-
- if (curT == null) {
- break;
- }
- }
- return curT;
- }
-
- private int countFieldsInClass(Class<?> clazz) {
- int fieldCount = 0;
- for(Field field : clazz.getFields()) { // get all fields
- if( !Modifier.isStatic(field.getModifiers()) &&
- !Modifier.isTransient(field.getModifiers())
- ) {
- fieldCount++;
- }
- }
- return fieldCount;
- }
-
- private static Type removeGenericWrapper(Type t) {
- if(t instanceof ParameterizedType &&
- (Collector.class.isAssignableFrom(typeToClass(t))
- || Iterable.class.isAssignableFrom(typeToClass(t)))) {
- return ((ParameterizedType) t).getActualTypeArguments()[0];
- }
- return t;
- }
-
- private static void validateLambdaGenericParameters(Method m) {
- // check the arguments
- for (Type t : m.getGenericParameterTypes()) {
- validateLambdaGenericParameter(t);
- }
-
- // check the return type
- validateLambdaGenericParameter(m.getGenericReturnType());
- }
-
- private static void validateLambdaGenericParameter(Type t) {
- if(!(t instanceof Class)) {
- return;
- }
- final Class<?> clazz = (Class<?>) t;
-
- if(clazz.getTypeParameters().length > 0) {
- throw new InvalidTypesException("The generic type parameters of '" + clazz.getSimpleName() + "' are missing. \n"
- + "It seems that your compiler has not stored them into the .class file. \n"
- + "Currently, only the Eclipse JDT compiler preserves the type information necessary to use the lambdas feature type-safely. \n"
- + "See the documentation for more information about how to compile jobs containing lambda expressions.");
- }
- }
-
- private static String encodePrimitiveClass(Class<?> primitiveClass) {
- if (primitiveClass == boolean.class) {
- return "Z";
- }
- else if (primitiveClass == byte.class) {
- return "B";
- }
- else if (primitiveClass == char.class) {
- return "C";
- }
- else if (primitiveClass == double.class) {
- return "D";
- }
- else if (primitiveClass == float.class) {
- return "F";
- }
- else if (primitiveClass == int.class) {
- return "I";
- }
- else if (primitiveClass == long.class) {
- return "J";
- }
- else if (primitiveClass == short.class) {
- return "S";
- }
- throw new InvalidTypesException();
- }
-
- private static TypeInformation<?> findCorrespondingInfo(TypeVariable<?> typeVar, Type type, TypeInformation<?> corrInfo, ArrayList<Type> typeHierarchy) {
- if (sameTypeVars(type, typeVar)) {
- return corrInfo;
- }
- else if (type instanceof TypeVariable && sameTypeVars(materializeTypeVariable(typeHierarchy, (TypeVariable<?>) type), typeVar)) {
- return corrInfo;
- }
- else if (type instanceof GenericArrayType) {
- TypeInformation<?> componentInfo = null;
- if (corrInfo instanceof BasicArrayTypeInfo) {
- componentInfo = ((BasicArrayTypeInfo<?,?>) corrInfo).getComponentInfo();
- }
- else if (corrInfo instanceof PrimitiveArrayTypeInfo) {
- componentInfo = BasicTypeInfo.getInfoFor(corrInfo.getTypeClass().getComponentType());
- }
- else if (corrInfo instanceof ObjectArrayTypeInfo) {
- componentInfo = ((ObjectArrayTypeInfo<?,?>) corrInfo).getComponentInfo();
- }
- TypeInformation<?> info = findCorrespondingInfo(typeVar, ((GenericArrayType) type).getGenericComponentType(), componentInfo, typeHierarchy);
- if (info != null) {
- return info;
- }
- }
- else if (corrInfo instanceof TupleTypeInfo
- && type instanceof ParameterizedType
- && Tuple.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())) {
- ParameterizedType tuple = (ParameterizedType) type;
- Type[] args = tuple.getActualTypeArguments();
-
- for (int i = 0; i < args.length; i++) {
- TypeInformation<?> info = findCorrespondingInfo(typeVar, args[i], ((TupleTypeInfo<?>) corrInfo).getTypeAt(i), typeHierarchy);
- if (info != null) {
- return info;
- }
- }
- }
- else if (corrInfo instanceof PojoTypeInfo && isClassType(type)) {
- // determine a field containing the type variable
- List<Field> fields = getAllDeclaredFields(typeToClass(type));
- for (Field field : fields) {
- Type fieldType = field.getGenericType();
- if (fieldType instanceof TypeVariable
- && sameTypeVars(typeVar, materializeTypeVariable(typeHierarchy, (TypeVariable<?>) fieldType))) {
- return getTypeOfPojoField(corrInfo, field);
- }
- else if (fieldType instanceof ParameterizedType
- || fieldType instanceof GenericArrayType) {
- ArrayList<Type> typeHierarchyWithFieldType = new ArrayList<Type>(typeHierarchy);
- typeHierarchyWithFieldType.add(fieldType);
- TypeInformation<?> info = findCorrespondingInfo(typeVar, fieldType, getTypeOfPojoField(corrInfo, field), typeHierarchyWithFieldType);
- if (info != null) {
- return info;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Tries to find a concrete value (Class, ParameterizedType etc. ) for a TypeVariable by traversing the type hierarchy downwards.
- * If a value could not be found it will return the most bottom type variable in the hierarchy.
- */
- private static Type materializeTypeVariable(ArrayList<Type> typeHierarchy, TypeVariable<?> typeVar) {
- TypeVariable<?> inTypeTypeVar = typeVar;
- // iterate thru hierarchy from top to bottom until type variable gets a class assigned
- for (int i = typeHierarchy.size() - 1; i >= 0; i--) {
- Type curT = typeHierarchy.get(i);
-
- // parameterized type
- if (curT instanceof ParameterizedType) {
- Class<?> rawType = ((Class<?>) ((ParameterizedType) curT).getRawType());
-
- for (int paramIndex = 0; paramIndex < rawType.getTypeParameters().length; paramIndex++) {
-
- TypeVariable<?> curVarOfCurT = rawType.getTypeParameters()[paramIndex];
-
- // check if variable names match
- if (sameTypeVars(curVarOfCurT, inTypeTypeVar)) {
- Type curVarType = ((ParameterizedType) curT).getActualTypeArguments()[paramIndex];
-
- // another type variable level
- if (curVarType instanceof TypeVariable<?>) {
- inTypeTypeVar = (TypeVariable<?>) curVarType;
- }
- // class
- else {
- return curVarType;
- }
- }
- }
- }
- }
- // can not be materialized, most likely due to type erasure
- // return the type variable of the deepest level
- return inTypeTypeVar;
- }
-
- /**
- * Creates type information from a given Class such as Integer, String[] or POJOs.
- *
- * This method does not support ParameterizedTypes such as Tuples or complex type hierarchies.
- * In most cases {@link TypeExtractor#createTypeInfo(Type)} is the recommended method for type extraction
- * (a Class is a child of Type).
- *
- * @param clazz a Class to create TypeInformation for
- * @return TypeInformation that describes the passed Class
- */
- public static <X> TypeInformation<X> getForClass(Class<X> clazz) {
- return new TypeExtractor().privateGetForClass(clazz, new ArrayList<Type>());
- }
-
- private <X> TypeInformation<X> privateGetForClass(Class<X> clazz, ArrayList<Type> typeHierarchy) {
- return privateGetForClass(clazz, typeHierarchy, null, null, null);
- }
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private <OUT,IN1,IN2> TypeInformation<OUT> privateGetForClass(Class<OUT> clazz, ArrayList<Type> typeHierarchy,
- ParameterizedType parameterizedType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
- Preconditions.checkNotNull(clazz);
-
- if (clazz.equals(Object.class)) {
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- // check for arrays
- if (clazz.isArray()) {
-
- // primitive arrays: int[], byte[], ...
- PrimitiveArrayTypeInfo<OUT> primitiveArrayInfo = PrimitiveArrayTypeInfo.getInfoFor(clazz);
- if (primitiveArrayInfo != null) {
- return primitiveArrayInfo;
- }
-
- // basic type arrays: String[], Integer[], Double[]
- BasicArrayTypeInfo<OUT, ?> basicArrayInfo = BasicArrayTypeInfo.getInfoFor(clazz);
- if (basicArrayInfo != null) {
- return basicArrayInfo;
- }
-
- // object arrays
- else {
- TypeInformation<?> componentTypeInfo = createTypeInfoWithTypeHierarchy(
- typeHierarchy,
- clazz.getComponentType(),
- in1Type,
- in2Type);
-
- return ObjectArrayTypeInfo.getInfoFor(clazz, componentTypeInfo);
- }
- }
-
- // check for writable types
- if(Writable.class.isAssignableFrom(clazz) && !Writable.class.equals(clazz)) {
- return (TypeInformation<OUT>) WritableTypeInfo.getWritableTypeInfo((Class<? extends Writable>) clazz);
- }
-
- // check for basic types
- TypeInformation<OUT> basicTypeInfo = BasicTypeInfo.getInfoFor(clazz);
- if (basicTypeInfo != null) {
- return basicTypeInfo;
- }
-
- // check for subclasses of Value
- if (Value.class.isAssignableFrom(clazz)) {
- Class<? extends Value> valueClass = clazz.asSubclass(Value.class);
- return (TypeInformation<OUT>) ValueTypeInfo.getValueTypeInfo(valueClass);
- }
-
- // check for subclasses of Tuple
- if (Tuple.class.isAssignableFrom(clazz)) {
- if(clazz == Tuple0.class) {
- return new TupleTypeInfo(Tuple0.class);
- }
- throw new InvalidTypesException("Type information extraction for tuples (except Tuple0) cannot be done based on the class.");
- }
-
- // check for subclasses of Either
- if (Either.class.isAssignableFrom(clazz)) {
- throw new InvalidTypesException("Type information extraction for Either cannot be done based on the class.");
- }
-
- // check for Enums
- if(Enum.class.isAssignableFrom(clazz)) {
- return new EnumTypeInfo(clazz);
- }
-
- // special case for POJOs generated by Avro.
- if(SpecificRecordBase.class.isAssignableFrom(clazz)) {
- return new AvroTypeInfo(clazz);
- }
-
- if (countTypeInHierarchy(typeHierarchy, clazz) > 1) {
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- if (Modifier.isInterface(clazz.getModifiers())) {
- // Interface has no members and is therefore not handled as POJO
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- if (clazz.equals(Class.class)) {
- // special case handling for Class, this should not be handled by the POJO logic
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- try {
- TypeInformation<OUT> pojoType = analyzePojo(clazz, new ArrayList<Type>(typeHierarchy), parameterizedType, in1Type, in2Type);
- if (pojoType != null) {
- return pojoType;
- }
- } catch (InvalidTypesException e) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Unable to handle type "+clazz+" as POJO. Message: "+e.getMessage(), e);
- }
- // ignore and create generic type info
- }
-
- // return a generic type
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- /**
- * Checks if the given field is a valid pojo field:
- * - it is public
- * OR
- * - there are getter and setter methods for the field.
- *
- * @param f field to check
- * @param clazz class of field
- * @param typeHierarchy type hierarchy for materializing generic types
- */
- private boolean isValidPojoField(Field f, Class<?> clazz, ArrayList<Type> typeHierarchy) {
- if(Modifier.isPublic(f.getModifiers())) {
- return true;
- } else {
- boolean hasGetter = false, hasSetter = false;
- final String fieldNameLow = f.getName().toLowerCase().replaceAll("_", "");
-
- Type fieldType = f.getGenericType();
- Class<?> fieldTypeWrapper = ClassUtils.primitiveToWrapper(f.getType());
-
- TypeVariable<?> fieldTypeGeneric = null;
- if(fieldType instanceof TypeVariable) {
- fieldTypeGeneric = (TypeVariable<?>) fieldType;
- fieldType = materializeTypeVariable(typeHierarchy, (TypeVariable<?>)fieldType);
- }
- for(Method m : clazz.getMethods()) {
- final String methodNameLow = m.getName().endsWith("_$eq") ?
- m.getName().toLowerCase().replaceAll("_", "").replaceFirst("\\$eq$", "_\\$eq") :
- m.getName().toLowerCase().replaceAll("_", "");
-
- // check for getter
- if( // The name should be "get<FieldName>" or "<fieldName>" (for scala) or "is<fieldName>" for boolean fields.
- (methodNameLow.equals("get"+fieldNameLow) || methodNameLow.equals("is"+fieldNameLow) || methodNameLow.equals(fieldNameLow)) &&
- // no arguments for the getter
- m.getParameterTypes().length == 0 &&
- // return type is same as field type (or the generic variant of it)
- (m.getGenericReturnType().equals( fieldType ) || (fieldTypeWrapper != null && m.getReturnType().equals( fieldTypeWrapper )) || (fieldTypeGeneric != null && m.getGenericReturnType().equals(fieldTypeGeneric)) )
- ) {
- if(hasGetter) {
- throw new IllegalStateException("Detected more than one getter");
- }
- hasGetter = true;
- }
- // check for setters (<FieldName>_$eq for scala)
- if((methodNameLow.equals("set"+fieldNameLow) || methodNameLow.equals(fieldNameLow+"_$eq")) &&
- m.getParameterTypes().length == 1 && // one parameter of the field's type
- (m.getGenericParameterTypes()[0].equals( fieldType ) || (fieldTypeWrapper != null && m.getParameterTypes()[0].equals( fieldTypeWrapper )) || (fieldTypeGeneric != null && m.getGenericParameterTypes()[0].equals(fieldTypeGeneric) ) )&&
- // return type is void.
- m.getReturnType().equals(Void.TYPE)
- ) {
- if(hasSetter) {
- throw new IllegalStateException("Detected more than one setter");
- }
- hasSetter = true;
- }
- }
- if(hasGetter && hasSetter) {
- return true;
- } else {
- if(!hasGetter) {
- LOG.debug(clazz+" does not contain a getter for field "+f.getName() );
- }
- if(!hasSetter) {
- LOG.debug(clazz+" does not contain a setter for field "+f.getName() );
- }
- return false;
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- protected <OUT, IN1, IN2> TypeInformation<OUT> analyzePojo(Class<OUT> clazz, ArrayList<Type> typeHierarchy,
- ParameterizedType parameterizedType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
-
- if (!Modifier.isPublic(clazz.getModifiers())) {
- LOG.info("Class " + clazz.getName() + " is not public, cannot treat it as a POJO type. Will be handled as GenericType");
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- // add the hierarchy of the POJO itself if it is generic
- if (parameterizedType != null) {
- getTypeHierarchy(typeHierarchy, parameterizedType, Object.class);
- }
- // create a type hierarchy, if the incoming only contains the most bottom one or none.
- else if (typeHierarchy.size() <= 1) {
- getTypeHierarchy(typeHierarchy, clazz, Object.class);
- }
-
- List<Field> fields = getAllDeclaredFields(clazz);
- if (fields.size() == 0) {
- LOG.info("No fields detected for " + clazz + ". Cannot be used as a PojoType. Will be handled as GenericType");
- return new GenericTypeInfo<OUT>(clazz);
- }
-
- List<PojoField> pojoFields = new ArrayList<PojoField>();
- for (Field field : fields) {
- Type fieldType = field.getGenericType();
- if(!isValidPojoField(field, clazz, typeHierarchy)) {
- LOG.info(clazz + " is not a valid POJO type");
- return null;
- }
- try {
- ArrayList<Type> fieldTypeHierarchy = new ArrayList<Type>(typeHierarchy);
- fieldTypeHierarchy.add(fieldType);
- TypeInformation<?> ti = createTypeInfoWithTypeHierarchy(fieldTypeHierarchy, fieldType, in1Type, in2Type);
- pojoFields.add(new PojoField(field, ti));
- } catch (InvalidTypesException e) {
- Class<?> genericClass = Object.class;
- if(isClassType(fieldType)) {
- genericClass = typeToClass(fieldType);
- }
- pojoFields.add(new PojoField(field, new GenericTypeInfo<OUT>((Class<OUT>) genericClass)));
- }
- }
-
- CompositeType<OUT> pojoType = new PojoTypeInfo<OUT>(clazz, pojoFields);
-
- //
- // Validate the correctness of the pojo.
- // returning "null" will result create a generic type information.
- //
- List<Method> methods = getAllDeclaredMethods(clazz);
- for (Method method : methods) {
- if (method.getName().equals("readObject") || method.getName().equals("writeObject")) {
- LOG.info(clazz+" contains custom serialization methods we do not call.");
- return null;
- }
- }
-
- // Try retrieving the default constructor, if it does not have one
- // we cannot use this because the serializer uses it.
- Constructor defaultConstructor = null;
- try {
- defaultConstructor = clazz.getDeclaredConstructor();
- } catch (NoSuchMethodException e) {
- if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
- LOG.info(clazz + " is abstract or an interface, having a concrete " +
- "type can increase performance.");
- } else {
- LOG.info(clazz + " must have a default constructor to be used as a POJO.");
- return null;
- }
- }
- if(defaultConstructor != null && !Modifier.isPublic(defaultConstructor.getModifiers())) {
- LOG.info("The default constructor of " + clazz + " should be Public to be used as a POJO.");
- return null;
- }
-
- // everything is checked, we return the pojo
- return pojoType;
- }
-
- /**
- * recursively determine all declared fields
- * This is required because class.getFields() is not returning fields defined
- * in parent classes.
- */
- public static List<Field> getAllDeclaredFields(Class<?> clazz) {
- List<Field> result = new ArrayList<Field>();
- while (clazz != null) {
- Field[] fields = clazz.getDeclaredFields();
- for (Field field : fields) {
- if(Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) {
- continue; // we have no use for transient or static fields
- }
- if(hasFieldWithSameName(field.getName(), result)) {
- throw new RuntimeException("The field "+field+" is already contained in the hierarchy of the "+clazz+"."
- + "Please use unique field names through your classes hierarchy");
- }
- result.add(field);
- }
- clazz = clazz.getSuperclass();
- }
- return result;
- }
-
- public static Field getDeclaredField(Class<?> clazz, String name) {
- for (Field field : getAllDeclaredFields(clazz)) {
- if (field.getName().equals(name)) {
- return field;
- }
- }
- return null;
- }
-
- private static boolean hasFieldWithSameName(String name, List<Field> fields) {
- for(Field field : fields) {
- if(name.equals(field.getName())) {
- return true;
- }
- }
- return false;
- }
-
-
- // recursively determine all declared methods
- private static List<Method> getAllDeclaredMethods(Class<?> clazz) {
- List<Method> result = new ArrayList<Method>();
- while (clazz != null) {
- Method[] methods = clazz.getDeclaredMethods();
- for (Method method : methods) {
- result.add(method);
- }
- clazz = clazz.getSuperclass();
- }
- return result;
- }
-
- // not public to users
- public static Class<?> typeToClass(Type t) {
- if (t instanceof Class) {
- return (Class<?>)t;
- }
- else if (t instanceof ParameterizedType) {
- return ((Class<?>)((ParameterizedType) t).getRawType());
- }
- throw new IllegalArgumentException("Cannot convert type to class");
- }
-
- // not public to users
- public static boolean isClassType(Type t) {
- return t instanceof Class<?> || t instanceof ParameterizedType;
- }
-
- private static boolean sameTypeVars(Type t1, Type t2) {
- if (!(t1 instanceof TypeVariable) || !(t2 instanceof TypeVariable)) {
- return false;
- }
- return ((TypeVariable<?>) t1).getName().equals(((TypeVariable<?>) t2).getName())
- && ((TypeVariable<?>) t1).getGenericDeclaration().equals(((TypeVariable<?>) t2).getGenericDeclaration());
- }
-
- private static TypeInformation<?> getTypeOfPojoField(TypeInformation<?> pojoInfo, Field field) {
- for (int j = 0; j < pojoInfo.getArity(); j++) {
- PojoField pf = ((PojoTypeInfo<?>) pojoInfo).getPojoFieldAt(j);
- if (pf.getField().getName().equals(field.getName())) {
- return pf.getTypeInformation();
- }
- }
- return null;
- }
-
-
- public static <X> TypeInformation<X> getForObject(X value) {
- return new TypeExtractor().privateGetForObject(value);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private <X> TypeInformation<X> privateGetForObject(X value) {
- Preconditions.checkNotNull(value);
-
- // check if we can extract the types from tuples, otherwise work with the class
- if (value instanceof Tuple) {
- Tuple t = (Tuple) value;
- int numFields = t.getArity();
- if(numFields != countFieldsInClass(value.getClass())) {
- // not a tuple since it has more fields.
- return analyzePojo((Class<X>) value.getClass(), new ArrayList<Type>(), null, null, null); // we immediately call analyze Pojo here, because
- // there is currently no other type that can handle such a class.
- }
-
- TypeInformation<?>[] infos = new TypeInformation[numFields];
- for (int i = 0; i < numFields; i++) {
- Object field = t.getField(i);
-
- if (field == null) {
- throw new InvalidTypesException("Automatic type extraction is not possible on candidates with null values. "
- + "Please specify the types directly.");
- }
-
- infos[i] = privateGetForObject(field);
- }
- return new TupleTypeInfo(value.getClass(), infos);
- }
- // we can not extract the types from an Either object since it only contains type information
- // of one type, but from Either classes
- else if (value instanceof Either) {
- try {
- return (TypeInformation<X>) privateCreateTypeInfo(value.getClass());
- }
- catch (InvalidTypesException e) {
- throw new InvalidTypesException("Automatic type extraction is not possible on an Either type "
- + "as it does not contain information about both possible types. "
- + "Please specify the types directly.");
- }
- }
- else {
- return privateGetForClass((Class<X>) value.getClass(), new ArrayList<Type>());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java
deleted file mode 100644
index b89a830..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeInfoParser.java
+++ /dev/null
@@ -1,383 +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.java.typeutils;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.types.Value;
-
-
-public class TypeInfoParser {
- private static final String TUPLE_PACKAGE = "org.apache.flink.api.java.tuple";
- private static final String VALUE_PACKAGE = "org.apache.flink.types";
- private static final String WRITABLE_PACKAGE = "org.apache.hadoop.io";
-
- private static final Pattern tuplePattern = Pattern.compile("^(" + TUPLE_PACKAGE.replaceAll("\\.", "\\\\.") + "\\.)?((Tuple[1-9][0-9]?)<|(Tuple0))");
- private static final Pattern writablePattern = Pattern.compile("^((" + WRITABLE_PACKAGE.replaceAll("\\.", "\\\\.") + "\\.)?Writable)<([^\\s,>]*)(,|>|$|\\[)");
- private static final Pattern enumPattern = Pattern.compile("^((java\\.lang\\.)?Enum)<([^\\s,>]*)(,|>|$|\\[)");
- private static final Pattern basicTypePattern = Pattern
- .compile("^((java\\.lang\\.)?(String|Integer|Byte|Short|Character|Double|Float|Long|Boolean|Void))(,|>|$|\\[)");
- private static final Pattern basicTypeDatePattern = Pattern.compile("^((java\\.util\\.)?Date)(,|>|$|\\[)");
- private static final Pattern primitiveTypePattern = Pattern.compile("^(int|byte|short|char|double|float|long|boolean|void)(,|>|$|\\[)");
- private static final Pattern valueTypePattern = Pattern.compile("^((" + VALUE_PACKAGE.replaceAll("\\.", "\\\\.")
- + "\\.)?(String|Int|Byte|Short|Char|Double|Float|Long|Boolean|List|Map|Null))Value(,|>|$|\\[)");
- private static final Pattern pojoGenericObjectPattern = Pattern.compile("^([^\\s,<>\\[]+)(<)?");
- private static final Pattern fieldPattern = Pattern.compile("^([^\\s,<>\\[]+)=");
-
- /**
- * Generates an instance of <code>TypeInformation</code> by parsing a type
- * information string. A type information string can contain the following
- * types:
- *
- * <ul>
- * <li>Basic types such as <code>Integer</code>, <code>String</code>, etc.
- * <li>Basic type arrays such as <code>Integer[]</code>,
- * <code>String[]</code>, etc.
- * <li>Tuple types such as <code>Tuple1<TYPE0></code>,
- * <code>Tuple2<TYPE0, TYPE1></code>, etc.</li>
- * <li>Pojo types such as <code>org.my.MyPojo<myFieldName=TYPE0,myFieldName2=TYPE1></code>, etc.</li>
- * <li>Generic types such as <code>java.lang.Class</code>, etc.
- * <li>Custom type arrays such as <code>org.my.CustomClass[]</code>,
- * <code>org.my.CustomClass$StaticInnerClass[]</code>, etc.
- * <li>Value types such as <code>DoubleValue</code>,
- * <code>StringValue</code>, <code>IntegerValue</code>, etc.</li>
- * <li>Tuple array types such as <code>Tuple2<TYPE0,TYPE1>[], etc.</code></li>
- * <li>Writable types such as <code>Writable<org.my.CustomWritable></code></li>
- * <li>Enum types such as <code>Enum<org.my.CustomEnum></code></li>
- * </ul>
- *
- * Example:
- * <code>"Tuple2<String,Tuple2<Integer,org.my.MyJob$Pojo<word=String>>>"</code>
- *
- * @param infoString
- * type information string to be parsed
- * @return <code>TypeInformation</code> representation of the string
- */
- @SuppressWarnings("unchecked")
- public static <X> TypeInformation<X> parse(String infoString) {
- try {
- if (infoString == null) {
- throw new IllegalArgumentException("String is null.");
- }
- String clearedString = infoString.replaceAll("\\s", "");
- if (clearedString.length() == 0) {
- throw new IllegalArgumentException("String must not be empty.");
- }
- StringBuilder sb = new StringBuilder(clearedString);
- TypeInformation<X> ti = (TypeInformation<X>) parse(sb);
- if (sb.length() > 0) {
- throw new IllegalArgumentException("String could not be parsed completely.");
- }
- return ti;
- } catch (Exception e) {
- throw new IllegalArgumentException("String could not be parsed: " + e.getMessage(), e);
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private static TypeInformation<?> parse(StringBuilder sb) throws ClassNotFoundException {
- String infoString = sb.toString();
- final Matcher tupleMatcher = tuplePattern.matcher(infoString);
-
- final Matcher writableMatcher = writablePattern.matcher(infoString);
- final Matcher enumMatcher = enumPattern.matcher(infoString);
-
- final Matcher basicTypeMatcher = basicTypePattern.matcher(infoString);
- final Matcher basicTypeDateMatcher = basicTypeDatePattern.matcher(infoString);
-
- final Matcher primitiveTypeMatcher = primitiveTypePattern.matcher(infoString);
-
- final Matcher valueTypeMatcher = valueTypePattern.matcher(infoString);
-
- final Matcher pojoGenericMatcher = pojoGenericObjectPattern.matcher(infoString);
-
- if (infoString.length() == 0) {
- return null;
- }
-
- TypeInformation<?> returnType = null;
- boolean isPrimitiveType = false;
-
- // tuples
- if (tupleMatcher.find()) {
- boolean isGenericTuple = true;
- String className = tupleMatcher.group(3);
- if(className == null) { // matched Tuple0
- isGenericTuple = false;
- className = tupleMatcher.group(2);
- sb.delete(0, className.length());
- } else {
- sb.delete(0, className.length() + 1); // +1 for "<"
- }
-
- if (infoString.startsWith(TUPLE_PACKAGE)) {
- sb.delete(0, TUPLE_PACKAGE.length() + 1); // +1 for trailing "."
- }
-
- int arity = Integer.parseInt(className.replaceAll("\\D", ""));
- Class<?> clazz = loadClass(TUPLE_PACKAGE + "." + className);
-
- TypeInformation<?>[] types = new TypeInformation<?>[arity];
- for (int i = 0; i < arity; i++) {
- types[i] = parse(sb);
- if (types[i] == null) {
- throw new IllegalArgumentException("Tuple arity does not match given parameters.");
- }
- }
- if (isGenericTuple) {
- if(sb.charAt(0) != '>') {
- throw new IllegalArgumentException("Tuple arity does not match given parameters.");
- }
- // remove '>'
- sb.deleteCharAt(0);
- }
- returnType = new TupleTypeInfo(clazz, types);
- }
- // writable types
- else if (writableMatcher.find()) {
- String className = writableMatcher.group(1);
- String fullyQualifiedName = writableMatcher.group(3);
- sb.delete(0, className.length() + 1 + fullyQualifiedName.length() + 1);
- Class<?> clazz = loadClass(fullyQualifiedName);
- returnType = WritableTypeInfo.getWritableTypeInfo((Class) clazz);
- }
- // enum types
- else if (enumMatcher.find()) {
- String className = enumMatcher.group(1);
- String fullyQualifiedName = enumMatcher.group(3);
- sb.delete(0, className.length() + 1 + fullyQualifiedName.length() + 1);
- Class<?> clazz = loadClass(fullyQualifiedName);
- returnType = new EnumTypeInfo(clazz);
- }
- // basic types
- else if (basicTypeMatcher.find()) {
- String className = basicTypeMatcher.group(1);
- sb.delete(0, className.length());
- Class<?> clazz;
- // check if fully qualified
- if (className.startsWith("java.lang")) {
- clazz = loadClass(className);
- } else {
- clazz = loadClass("java.lang." + className);
- }
- returnType = BasicTypeInfo.getInfoFor(clazz);
- }
- // special basic type "Date"
- else if (basicTypeDateMatcher.find()) {
- String className = basicTypeDateMatcher.group(1);
- sb.delete(0, className.length());
- Class<?> clazz;
- // check if fully qualified
- if (className.startsWith("java.util")) {
- clazz = loadClass(className);
- } else {
- clazz = loadClass("java.util." + className);
- }
- returnType = BasicTypeInfo.getInfoFor(clazz);
- }
- // primitive types
- else if (primitiveTypeMatcher.find()) {
- String keyword = primitiveTypeMatcher.group(1);
- sb.delete(0, keyword.length());
-
- Class<?> clazz = null;
- if (keyword.equals("int")) {
- clazz = int.class;
- } else if (keyword.equals("byte")) {
- clazz = byte.class;
- } else if (keyword.equals("short")) {
- clazz = short.class;
- } else if (keyword.equals("char")) {
- clazz = char.class;
- } else if (keyword.equals("double")) {
- clazz = double.class;
- } else if (keyword.equals("float")) {
- clazz = float.class;
- } else if (keyword.equals("long")) {
- clazz = long.class;
- } else if (keyword.equals("boolean")) {
- clazz = boolean.class;
- } else if (keyword.equals("void")) {
- clazz = void.class;
- }
- returnType = BasicTypeInfo.getInfoFor(clazz);
- isPrimitiveType = true;
- }
- // values
- else if (valueTypeMatcher.find()) {
- String className = valueTypeMatcher.group(1);
- sb.delete(0, className.length() + 5);
-
- Class<?> clazz;
- // check if fully qualified
- if (className.startsWith(VALUE_PACKAGE)) {
- clazz = loadClass(className + "Value");
- } else {
- clazz = loadClass(VALUE_PACKAGE + "." + className + "Value");
- }
- returnType = ValueTypeInfo.getValueTypeInfo((Class<Value>) clazz);
- }
- // pojo objects or generic types
- else if (pojoGenericMatcher.find()) {
- String fullyQualifiedName = pojoGenericMatcher.group(1);
- sb.delete(0, fullyQualifiedName.length());
-
- boolean isPojo = pojoGenericMatcher.group(2) != null;
-
- // pojo
- if (isPojo) {
- sb.deleteCharAt(0);
- Class<?> clazz = loadClass(fullyQualifiedName);
-
- ArrayList<PojoField> fields = new ArrayList<PojoField>();
- while (sb.charAt(0) != '>') {
- final Matcher fieldMatcher = fieldPattern.matcher(sb);
- if (!fieldMatcher.find()) {
- throw new IllegalArgumentException("Field name missing.");
- }
- String fieldName = fieldMatcher.group(1);
- sb.delete(0, fieldName.length() + 1);
-
- Field field = TypeExtractor.getDeclaredField(clazz, fieldName);
- if (field == null) {
- throw new IllegalArgumentException("Field '" + fieldName + "'could not be accessed.");
- }
- fields.add(new PojoField(field, parse(sb)));
- }
- sb.deleteCharAt(0); // remove '>'
- returnType = new PojoTypeInfo(clazz, fields);
- }
- // generic type
- else {
- returnType = new GenericTypeInfo(loadClass(fullyQualifiedName));
- }
- }
-
- if (returnType == null) {
- throw new IllegalArgumentException("Error at '" + infoString + "'");
- }
-
- // arrays
- int arrayDimensionCount = 0;
- while (sb.length() > 1 && sb.charAt(0) == '[' && sb.charAt(1) == ']') {
- arrayDimensionCount++;
- sb.delete(0, 2);
- }
-
- if (sb.length() > 0 && sb.charAt(0) == '[') {
- throw new IllegalArgumentException("Closing square bracket missing.");
- }
-
- // construct multidimension array
- if (arrayDimensionCount > 0) {
- TypeInformation<?> arrayInfo = null;
-
- // first dimension
- // primitive array
- if (isPrimitiveType) {
- if (returnType == BasicTypeInfo.INT_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.BYTE_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.SHORT_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.CHAR_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.DOUBLE_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.FLOAT_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.LONG_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
- arrayInfo = PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.VOID_TYPE_INFO) {
- throw new IllegalArgumentException("Can not create an array of void.");
- }
- }
- // basic array
- else if (returnType instanceof BasicTypeInfo
- && returnType != BasicTypeInfo.DATE_TYPE_INFO) {
- if (returnType == BasicTypeInfo.INT_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.INT_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.BYTE_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.BYTE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.SHORT_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.SHORT_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.CHAR_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.CHAR_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.DOUBLE_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.DOUBLE_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.FLOAT_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.FLOAT_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.LONG_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.LONG_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.STRING_TYPE_INFO) {
- arrayInfo = BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO;
- } else if (returnType == BasicTypeInfo.VOID_TYPE_INFO) {
- throw new IllegalArgumentException("Can not create an array of void.");
- }
- }
- // object array
- else {
- arrayInfo = ObjectArrayTypeInfo.getInfoFor(loadClass("[L" + returnType.getTypeClass().getName() + ";"),
- returnType);
- }
-
- // further dimensions
- if (arrayDimensionCount > 1) {
- String arrayPrefix = "[";
- for (int i = 1; i < arrayDimensionCount; i++) {
- arrayPrefix += "[";
- arrayInfo = ObjectArrayTypeInfo.getInfoFor(loadClass(arrayPrefix + "L" +
- returnType.getTypeClass().getName() + ";"), arrayInfo);
- }
- }
- returnType = arrayInfo;
- }
-
- // remove possible ','
- if (sb.length() > 0 && sb.charAt(0) == ',') {
- sb.deleteCharAt(0);
- }
-
- // check if end
- return returnType;
- }
-
- private static Class<?> loadClass(String fullyQualifiedName) {
- try {
- return Class.forName(fullyQualifiedName);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Class '" + fullyQualifiedName
- + "' could not be found. Please note that inner classes must be declared static.");
- }
- }
-
-}
[04/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java
deleted file mode 100644
index 19fac43..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeComparatorTest.java
+++ /dev/null
@@ -1,28 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-public class AvroGenericTypeComparatorTest extends AbstractGenericTypeComparatorTest {
- @Override
- protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
- return new AvroSerializer<T>(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java
deleted file mode 100644
index df1ff60..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroGenericTypeSerializerTest.java
+++ /dev/null
@@ -1,29 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-public class AvroGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
-
- @Override
- protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
- return new AvroSerializer<T>(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java
deleted file mode 100644
index 8a89410..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/AvroSerializerEmptyArrayTest.java
+++ /dev/null
@@ -1,189 +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.java.typeutils.runtime;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.avro.reflect.Nullable;
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.junit.Test;
-
-public class AvroSerializerEmptyArrayTest {
-
- @Test
- public void testBookSerialization() {
- try {
- Book b = new Book(123, "This is a test book", 26382648);
- AvroSerializer<Book> serializer = new AvroSerializer<Book>(Book.class);
- SerializerTestInstance<Book> test = new SerializerTestInstance<Book>(serializer, Book.class, -1, b);
- test.testAll();
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testSerialization() {
- try {
- List<String> titles = new ArrayList<String>();
-
- List<Book> books = new ArrayList<Book>();
- books.add(new Book(123, "This is a test book", 1));
- books.add(new Book(24234234, "This is a test book", 1));
- books.add(new Book(1234324, "This is a test book", 3));
-
- BookAuthor a = new BookAuthor(1, titles, "Test Author");
- a.books = books;
- a.bookType = BookAuthor.BookType.journal;
-
- AvroSerializer<BookAuthor> serializer = new AvroSerializer<BookAuthor>(BookAuthor.class);
-
- SerializerTestInstance<BookAuthor> test = new SerializerTestInstance<BookAuthor>(serializer, BookAuthor.class, -1, a);
- test.testAll();
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- public static class Book {
-
- long bookId;
- @Nullable
- String title;
- long authorId;
-
- public Book() {}
-
- public Book(long bookId, String title, long authorId) {
- this.bookId = bookId;
- this.title = title;
- this.authorId = authorId;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (authorId ^ (authorId >>> 32));
- result = prime * result + (int) (bookId ^ (bookId >>> 32));
- result = prime * result + ((title == null) ? 0 : title.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Book other = (Book) obj;
- if (authorId != other.authorId)
- return false;
- if (bookId != other.bookId)
- return false;
- if (title == null) {
- if (other.title != null)
- return false;
- } else if (!title.equals(other.title))
- return false;
- return true;
- }
- }
-
- public static class BookAuthor {
-
- enum BookType {
- book,
- article,
- journal
- }
-
- long authorId;
-
- @Nullable
- List<String> bookTitles;
-
- @Nullable
- List<Book> books;
-
- String authorName;
-
- BookType bookType;
-
- public BookAuthor() {}
-
- public BookAuthor(long authorId, List<String> bookTitles, String authorName) {
- this.authorId = authorId;
- this.bookTitles = bookTitles;
- this.authorName = authorName;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (authorId ^ (authorId >>> 32));
- result = prime * result + ((authorName == null) ? 0 : authorName.hashCode());
- result = prime * result + ((bookTitles == null) ? 0 : bookTitles.hashCode());
- result = prime * result + ((bookType == null) ? 0 : bookType.hashCode());
- result = prime * result + ((books == null) ? 0 : books.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BookAuthor other = (BookAuthor) obj;
- if (authorId != other.authorId)
- return false;
- if (authorName == null) {
- if (other.authorName != null)
- return false;
- } else if (!authorName.equals(other.authorName))
- return false;
- if (bookTitles == null) {
- if (other.bookTitles != null)
- return false;
- } else if (!bookTitles.equals(other.bookTitles))
- return false;
- if (bookType != other.bookType)
- return false;
- if (books == null) {
- if (other.books != null)
- return false;
- } else if (!books.equals(other.books))
- return false;
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java
deleted file mode 100644
index b317275..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/CopyableValueComparatorTest.java
+++ /dev/null
@@ -1,53 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.types.StringValue;
-
-public class CopyableValueComparatorTest extends ComparatorTestBase<StringValue> {
-
- StringValue[] data = new StringValue[]{
- new StringValue(""),
- new StringValue("Lorem Ipsum Dolor Omit Longer"),
- new StringValue("aaaa"),
- new StringValue("abcd"),
- new StringValue("abce"),
- new StringValue("abdd"),
- new StringValue("accd"),
- new StringValue("bbcd")
- };
-
- @Override
- protected TypeComparator<StringValue> createComparator(boolean ascending) {
- return new CopyableValueComparator<StringValue>(ascending, StringValue.class);
- }
-
- @Override
- protected TypeSerializer<StringValue> createSerializer() {
- return new CopyableValueSerializer<StringValue>(StringValue.class);
- }
-
- @Override
- protected StringValue[] getSortedTestData() {
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
deleted file mode 100644
index e4672cc..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
+++ /dev/null
@@ -1,113 +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.java.typeutils.runtime;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.apache.flink.api.java.typeutils.Either.Left;
-import static org.apache.flink.api.java.typeutils.Either.Right;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.typeutils.Either;
-import org.apache.flink.api.java.typeutils.EitherTypeInfo;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.junit.Test;
-
-public class EitherSerializerTest {
-
- @SuppressWarnings("unchecked")
- @Test
- public void testStringDoubleEither() {
-
- Either<String, Double>[] testData = new Either[] {
- Left("banana"),
- Left(""),
- Right(32.0),
- Right(Double.MIN_VALUE),
- Right(Double.MAX_VALUE)};
-
- EitherTypeInfo<String, Double> eitherTypeInfo = (EitherTypeInfo<String, Double>) new EitherTypeInfo<String, Double>(
- BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO);
- EitherSerializer<String, Double> eitherSerializer =
- (EitherSerializer<String, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig());
- SerializerTestInstance<Either<String, Double>> testInstance =
- new EitherSerializerTestInstance<Either<String, Double>>(eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData);
- testInstance.testAll();
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testEitherWithTuple() {
-
- Either<Tuple2<Long, Long>, Double>[] testData = new Either[] {
- Either.Left(new Tuple2<>(2l, 9l)),
- new Left<>(new Tuple2<>(Long.MIN_VALUE, Long.MAX_VALUE)),
- new Right<>(32.0),
- Right(Double.MIN_VALUE),
- Right(Double.MAX_VALUE)};
-
- EitherTypeInfo<Tuple2<Long, Long>, Double> eitherTypeInfo = (EitherTypeInfo<Tuple2<Long, Long>, Double>)
- new EitherTypeInfo<Tuple2<Long, Long>, Double>(
- new TupleTypeInfo<Tuple2<Long, Long>>(BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO),
- BasicTypeInfo.DOUBLE_TYPE_INFO);
- EitherSerializer<Tuple2<Long, Long>, Double> eitherSerializer =
- (EitherSerializer<Tuple2<Long, Long>, Double>) eitherTypeInfo.createSerializer(new ExecutionConfig());
- SerializerTestInstance<Either<Tuple2<Long, Long>, Double>> testInstance =
- new EitherSerializerTestInstance<Either<Tuple2<Long, Long>, Double>>(
- eitherSerializer, eitherTypeInfo.getTypeClass(), -1, testData);
- testInstance.testAll();
- }
-
- /**
- * {@link org.apache.flink.api.common.typeutils.SerializerTestBase#testInstantiate()}
- * checks that the type of the created instance is the same as the type class parameter.
- * Since we arbitrarily create always create a Left instance we override this test.
- */
- private class EitherSerializerTestInstance<T> extends SerializerTestInstance<T> {
-
- public EitherSerializerTestInstance(TypeSerializer<T> serializer,
- Class<T> typeClass, int length, T[] testData) {
- super(serializer, typeClass, length, testData);
- }
-
- @Override
- @Test
- public void testInstantiate() {
- try {
- TypeSerializer<T> serializer = getSerializer();
-
- T instance = serializer.createInstance();
- assertNotNull("The created instance must not be null.", instance);
-
- Class<T> type = getTypeClass();
- assertNotNull("The test is corrupt: type class is null.", type);
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- fail("Exception in test: " + e.getMessage());
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java
deleted file mode 100644
index 06330d3..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/GenericPairComparatorTest.java
+++ /dev/null
@@ -1,89 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.GenericPairComparator;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.tuple.Tuple4;
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TuplePairComparatorTestBase;
-
-public class GenericPairComparatorTest extends TuplePairComparatorTestBase<Tuple3<Integer, String, Double>, Tuple4<Integer, Float, Long, Double>> {
-
- @SuppressWarnings("unchecked")
- private Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, String, Double>(4, "hello", 20.0),
- new Tuple3<Integer, String, Double>(4, "world", 23.2),
- new Tuple3<Integer, String, Double>(5, "hello", 18.0),
- new Tuple3<Integer, String, Double>(5, "world", 19.2),
- new Tuple3<Integer, String, Double>(6, "hello", 16.0),
- new Tuple3<Integer, String, Double>(6, "world", 17.2),
- new Tuple3<Integer, String, Double>(7, "hello", 14.0),
- new Tuple3<Integer, String, Double>(7, "world", 15.2)
- };
-
- @SuppressWarnings("unchecked")
- private Tuple4<Integer, Float, Long, Double>[] dataIDL = new Tuple4[]{
- new Tuple4<Integer, Float, Long, Double>(4, 0.11f, 14L, 20.0),
- new Tuple4<Integer, Float, Long, Double>(4, 0.221f, 15L, 23.2),
- new Tuple4<Integer, Float, Long, Double>(5, 0.33f, 15L, 18.0),
- new Tuple4<Integer, Float, Long, Double>(5, 0.44f, 20L, 19.2),
- new Tuple4<Integer, Float, Long, Double>(6, 0.55f, 20L, 16.0),
- new Tuple4<Integer, Float, Long, Double>(6, 0.66f, 29L, 17.2),
- new Tuple4<Integer, Float, Long, Double>(7, 0.77f, 29L, 14.0),
- new Tuple4<Integer, Float, Long, Double>(7, 0.88f, 34L, 15.2)
- };
-
- @SuppressWarnings("rawtypes")
- @Override
- protected GenericPairComparator<Tuple3<Integer, String, Double>, Tuple4<Integer, Float, Long, Double>> createComparator(boolean ascending) {
- int[] fields1 = new int[]{0, 2};
- int[] fields2 = new int[]{0, 3};
- TypeComparator[] comps1 = new TypeComparator[]{
- new IntComparator(ascending),
- new DoubleComparator(ascending)
- };
- TypeComparator[] comps2 = new TypeComparator[]{
- new IntComparator(ascending),
- new DoubleComparator(ascending)
- };
- TypeSerializer[] sers1 = new TypeSerializer[]{
- IntSerializer.INSTANCE,
- DoubleSerializer.INSTANCE
- };
- TypeSerializer[] sers2= new TypeSerializer[]{
- IntSerializer.INSTANCE,
- DoubleSerializer.INSTANCE
- };
- TypeComparator<Tuple3<Integer, String, Double>> comp1 = new TupleComparator<Tuple3<Integer, String, Double>>(fields1, comps1, sers1);
- TypeComparator<Tuple4<Integer, Float, Long, Double>> comp2 = new TupleComparator<Tuple4<Integer, Float, Long, Double>>(fields2, comps2, sers2);
- return new GenericPairComparator<Tuple3<Integer, String, Double>, Tuple4<Integer, Float, Long, Double>>(comp1, comp2);
- }
-
- @Override
- protected Tuple2<Tuple3<Integer, String, Double>[], Tuple4<Integer, Float, Long, Double>[]> getSortedTestData() {
- return new Tuple2<Tuple3<Integer, String, Double>[], Tuple4<Integer, Float, Long, Double>[]>(dataISD, dataIDL);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java
deleted file mode 100644
index 1c97816..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/MultidimensionalArraySerializerTest.java
+++ /dev/null
@@ -1,120 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.typeutils.TypeInfoParser;
-import org.junit.Test;
-
-
-/**
- * A serialization test for multidimensional arrays.
- */
-public class MultidimensionalArraySerializerTest {
-
- @Test
- public void testStringArray() {
- String[][] array = new String[][]{{null,"b"},{"c","d"},{"e","f"},{"g","h"},null};
- TypeInformation<String[][]> ti = TypeExtractor.getForClass(String[][].class);
-
- SerializerTestInstance<String[][]> testInstance = new SerializerTestInstance<String[][]>(ti.createSerializer(new ExecutionConfig()), String[][].class, -1, array);
- testInstance.testAll();
- }
-
- @Test
- public void testPrimitiveArray() {
- int[][] array = new int[][]{{12,1},{48,42},{23,80},{484,849},{987,4}};
- TypeInformation<int[][]> ti = TypeExtractor.getForClass(int[][].class);
-
- SerializerTestInstance<int[][]> testInstance = new SerializerTestInstance<int[][]>(ti.createSerializer(new ExecutionConfig()), int[][].class, -1, array);
- testInstance.testAll();
- }
-
- public static class MyPojo {
- public String field1;
- public int field2;
-
- public MyPojo(String field1, int field2) {
- this.field1 = field1;
- this.field2 = field2;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof MyPojo)) {
- return false;
- }
- MyPojo other = (MyPojo) obj;
- return ((field1 == null && other.field1 == null) || (field1 != null && field1.equals(other.field1)))
- && field2 == other.field2;
- }
- }
-
- @Test
- public void testObjectArrays() {
- Integer[][] array = new Integer[][]{{0,1}, null, {null, 42}};
- TypeInformation<Integer[][]> ti = TypeExtractor.getForClass(Integer[][].class);
-
- SerializerTestInstance<Integer[][]> testInstance = new SerializerTestInstance<Integer[][]>(ti.createSerializer(new ExecutionConfig()), Integer[][].class, -1, array);
- testInstance.testAll();
-
- MyPojo[][] array2 = new MyPojo[][]{{new MyPojo(null, 42), new MyPojo("test2", -1)}, {null, null}, null};
- TypeInformation<MyPojo[][]> ti2 = TypeExtractor.getForClass(MyPojo[][].class);
-
- SerializerTestInstance<MyPojo[][]> testInstance2 = new SerializerTestInstance<MyPojo[][]>(ti2.createSerializer(new ExecutionConfig()), MyPojo[][].class, -1, array2);
- testInstance2.testAll();
- }
-
- public static class MyGenericPojo<T> {
- public T[][] field;
-
- public MyGenericPojo() {
- // nothing to do
- }
-
- public MyGenericPojo(T[][] field) {
- this.field = field;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof MyGenericPojo)) {
- return false;
- }
- MyGenericPojo<?> other = (MyGenericPojo<?>) obj;
- return (field == null && other.field == null) || (field != null && field.length == other.field.length);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericObjectArrays() {
- MyGenericPojo<String>[][] array = (MyGenericPojo<String>[][]) new MyGenericPojo[][]{
- { new MyGenericPojo<String>(new String[][]{{"a", "b"},{"c", "d"}}), null}
- };
- TypeInformation ti = TypeInfoParser.parse("org.apache.flink.api.java.typeutils.runtime.MultidimensionalArraySerializerTest$MyGenericPojo<field=String[][]>[][]");
-
- SerializerTestInstance testInstance = new SerializerTestInstance(ti.createSerializer(new ExecutionConfig()), MyGenericPojo[][].class, -1, (Object) array);
- testInstance.testAll();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java
deleted file mode 100644
index 1baf443..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoComparatorTest.java
+++ /dev/null
@@ -1,63 +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.java.typeutils.runtime;
-
-import java.util.Arrays;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.junit.Assert;
-
-
-public class PojoComparatorTest extends ComparatorTestBase<PojoContainingTuple> {
- TypeInformation<PojoContainingTuple> type = TypeExtractor.getForClass(PojoContainingTuple.class);
-
- PojoContainingTuple[] data = new PojoContainingTuple[]{
- new PojoContainingTuple(1, 1L, 1L),
- new PojoContainingTuple(2, 2L, 2L),
- new PojoContainingTuple(8519, 85190L, 85190L),
- new PojoContainingTuple(8520, 85191L, 85191L),
- };
-
- @Override
- protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) {
- Assert.assertTrue(type instanceof CompositeType);
- CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type;
- ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType);
- boolean[] orders = new boolean[keys.getNumberOfKeyFields()];
- Arrays.fill(orders, ascending);
- return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig());
- }
-
- @Override
- protected TypeSerializer<PojoContainingTuple> createSerializer() {
- return type.createSerializer(new ExecutionConfig());
- }
-
- @Override
- protected PojoContainingTuple[] getSortedTestData() {
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java
deleted file mode 100644
index ca17ee0..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoContainingTuple.java
+++ /dev/null
@@ -1,44 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.java.tuple.Tuple2;
-
-/**
- * This file belongs to the PojoComparatorTest test
- *
- */
-public class PojoContainingTuple {
- public int someInt;
- public String someString = "abc";
- public Tuple2<Long, Long> theTuple;
- public PojoContainingTuple() {}
- public PojoContainingTuple(int i, long l1, long l2) {
- someInt = i;
- theTuple = new Tuple2<Long, Long>(l1, l2);
- }
-
- @Override
- public boolean equals(Object obj) {
- if(obj instanceof PojoContainingTuple) {
- PojoContainingTuple other = (PojoContainingTuple) obj;
- return someInt == other.someInt && theTuple.equals(other.theTuple);
- }
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java
deleted file mode 100644
index d405412..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoGenericTypeSerializerTest.java
+++ /dev/null
@@ -1,33 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-
-public class PojoGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
-
- @Override
- protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
- TypeInformation<T> typeInfo = TypeExtractor.getForClass(type);
- return typeInfo.createSerializer(new ExecutionConfig());
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java
deleted file mode 100644
index b1467b9..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializerTest.java
+++ /dev/null
@@ -1,243 +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.java.typeutils.runtime;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.SerializerTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-import org.apache.flink.api.java.operators.Keys.IncompatibleKeysException;
-import org.apache.flink.api.java.tuple.Tuple1;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.PojoTypeInfo;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.google.common.base.Objects;
-
-/**
- * A test for the {@link PojoSerializer}.
- */
-public class PojoSerializerTest extends SerializerTestBase<PojoSerializerTest.TestUserClass> {
- private TypeInformation<TestUserClass> type = TypeExtractor.getForClass(TestUserClass.class);
-
- @Override
- protected TypeSerializer<TestUserClass> createSerializer() {
- TypeSerializer<TestUserClass> serializer = type.createSerializer(new ExecutionConfig());
- assert(serializer instanceof PojoSerializer);
- return serializer;
- }
-
- @Override
- protected int getLength() {
- return -1;
- }
-
- @Override
- protected Class<TestUserClass> getTypeClass() {
- return TestUserClass.class;
- }
-
- @Override
- protected TestUserClass[] getTestData() {
- Random rnd = new Random(874597969123412341L);
-
- return new TestUserClass[]{
- new TestUserClass(rnd.nextInt(), "foo", rnd.nextDouble(), new int[]{1, 2, 3}, new Date(),
- new NestedTestUserClass(rnd.nextInt(), "foo@boo", rnd.nextDouble(), new int[]{10, 11, 12})),
- new TestUserClass(rnd.nextInt(), "bar", rnd.nextDouble(), new int[]{4, 5, 6}, null,
- new NestedTestUserClass(rnd.nextInt(), "bar@bas", rnd.nextDouble(), new int[]{20, 21, 22})),
- new TestUserClass(rnd.nextInt(), null, rnd.nextDouble(), null, null, null),
- new TestUserClass(rnd.nextInt(), "bar", rnd.nextDouble(), new int[]{4, 5, 6}, new Date(),
- new NestedTestUserClass(rnd.nextInt(), "bar@bas", rnd.nextDouble(), new int[]{20, 21, 22}))
- };
-
- }
-
- // User code class for testing the serializer
- public static class TestUserClass {
- public int dumm1;
- public String dumm2;
- public double dumm3;
- public int[] dumm4;
- public Date dumm5;
-
- public NestedTestUserClass nestedClass;
-
- public TestUserClass() {
- }
-
- public TestUserClass(int dumm1, String dumm2, double dumm3, int[] dumm4, Date dumm5, NestedTestUserClass nestedClass) {
- this.dumm1 = dumm1;
- this.dumm2 = dumm2;
- this.dumm3 = dumm3;
- this.dumm4 = dumm4;
- this.dumm5 = dumm5;
- this.nestedClass = nestedClass;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(dumm1, dumm2, dumm3, dumm4, nestedClass);
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClass)) {
- return false;
- }
- TestUserClass otherTUC = (TestUserClass) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if ((dumm2 == null && otherTUC.dumm2 != null)
- || (dumm2 != null && !dumm2.equals(otherTUC.dumm2))) {
- return false;
- }
- if (dumm3 != otherTUC.dumm3) {
- return false;
- }
- if ((dumm4 != null && otherTUC.dumm4 == null)
- || (dumm4 == null && otherTUC.dumm4 != null)
- || (dumm4 != null && otherTUC.dumm4 != null && dumm4.length != otherTUC.dumm4.length)) {
- return false;
- }
- if (dumm4 != null && otherTUC.dumm4 != null) {
- for (int i = 0; i < dumm4.length; i++) {
- if (dumm4[i] != otherTUC.dumm4[i]) {
- return false;
- }
- }
- }
-
- if ((nestedClass == null && otherTUC.nestedClass != null)
- || (nestedClass != null && !nestedClass.equals(otherTUC.nestedClass))) {
- return false;
- }
- return true;
- }
- }
-
- public static class NestedTestUserClass {
- public int dumm1;
- public String dumm2;
- public double dumm3;
- public int[] dumm4;
-
- public NestedTestUserClass() {
- }
-
- public NestedTestUserClass(int dumm1, String dumm2, double dumm3, int[] dumm4) {
- this.dumm1 = dumm1;
- this.dumm2 = dumm2;
- this.dumm3 = dumm3;
- this.dumm4 = dumm4;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(dumm1, dumm2, dumm3, dumm4);
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof NestedTestUserClass)) {
- return false;
- }
- NestedTestUserClass otherTUC = (NestedTestUserClass) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- if (dumm3 != otherTUC.dumm3) {
- return false;
- }
- if (dumm4.length != otherTUC.dumm4.length) {
- return false;
- }
- for (int i = 0; i < dumm4.length; i++) {
- if (dumm4[i] != otherTUC.dumm4[i]) {
- return false;
- }
- }
- return true;
- }
- }
-
- /**
- * This tests if the hashes returned by the pojo and tuple comparators are the same
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testTuplePojoTestEquality() {
-
- // test with a simple, string-key first.
- PojoTypeInfo<TestUserClass> pType = (PojoTypeInfo<TestUserClass>) type;
- List<FlatFieldDescriptor> result = new ArrayList<FlatFieldDescriptor>();
- pType.getFlatFields("nestedClass.dumm2", 0, result);
- int[] fields = new int[1]; // see below
- fields[0] = result.get(0).getPosition();
- TypeComparator<TestUserClass> pojoComp = pType.createComparator( fields, new boolean[]{true}, 0, new ExecutionConfig());
-
- TestUserClass pojoTestRecord = new TestUserClass(0, "abc", 3d, new int[] {1,2,3}, new Date(), new NestedTestUserClass(1, "haha", 4d, new int[] {5,4,3}));
- int pHash = pojoComp.hash(pojoTestRecord);
-
- Tuple1<String> tupleTest = new Tuple1<String>("haha");
- TupleTypeInfo<Tuple1<String>> tType = (TupleTypeInfo<Tuple1<String>>)TypeExtractor.getForObject(tupleTest);
- TypeComparator<Tuple1<String>> tupleComp = tType.createComparator(new int[] {0}, new boolean[] {true}, 0, new ExecutionConfig());
-
- int tHash = tupleComp.hash(tupleTest);
-
- Assert.assertTrue("The hashing for tuples and pojos must be the same, so that they are mixable", pHash == tHash);
-
- Tuple3<Integer, String, Double> multiTupleTest = new Tuple3<Integer, String, Double>(1, "haha", 4d); // its important here to use the same values.
- TupleTypeInfo<Tuple3<Integer, String, Double>> multiTupleType = (TupleTypeInfo<Tuple3<Integer, String, Double>>)TypeExtractor.getForObject(multiTupleTest);
-
- ExpressionKeys fieldKey = new ExpressionKeys(new int[]{1,0,2}, multiTupleType);
- ExpressionKeys expressKey = new ExpressionKeys(new String[] {"nestedClass.dumm2", "nestedClass.dumm1", "nestedClass.dumm3"}, pType);
- try {
- Assert.assertTrue("Expecting the keys to be compatible", fieldKey.areCompatible(expressKey));
- } catch (IncompatibleKeysException e) {
- e.printStackTrace();
- Assert.fail("Keys must be compatible: "+e.getMessage());
- }
- TypeComparator<TestUserClass> multiPojoComp = pType.createComparator( expressKey.computeLogicalKeyPositions(), new boolean[]{true, true, true}, 0, new ExecutionConfig());
- int multiPojoHash = multiPojoComp.hash(pojoTestRecord);
-
-
- // pojo order is: dumm2 (str), dumm1 (int), dumm3 (double).
- TypeComparator<Tuple3<Integer, String, Double>> multiTupleComp = multiTupleType.createComparator(fieldKey.computeLogicalKeyPositions(), new boolean[] {true, true,true}, 0, new ExecutionConfig());
- int multiTupleHash = multiTupleComp.hash(multiTupleTest);
-
- Assert.assertTrue("The hashing for tuples and pojos must be the same, so that they are mixable. Also for those with multiple key fields", multiPojoHash == multiTupleHash);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java
deleted file mode 100644
index 3a03683..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassComparatorTest.java
+++ /dev/null
@@ -1,76 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.junit.Assert;
-
-import java.util.Arrays;
-
-
-public class PojoSubclassComparatorTest extends ComparatorTestBase<PojoContainingTuple> {
- TypeInformation<PojoContainingTuple> type = TypeExtractor.getForClass(PojoContainingTuple.class);
-
- PojoContainingTuple[] data = new PojoContainingTuple[]{
- new Subclass(1, 1L, 1L, 17L),
- new Subclass(2, 2L, 2L, 42L),
- new Subclass(8519, 85190L, 85190L, 117L),
- new Subclass(8520, 85191L, 85191L, 93L),
- };
-
- @Override
- protected TypeComparator<PojoContainingTuple> createComparator(boolean ascending) {
- Assert.assertTrue(type instanceof CompositeType);
- CompositeType<PojoContainingTuple> cType = (CompositeType<PojoContainingTuple>) type;
- ExpressionKeys<PojoContainingTuple> keys = new ExpressionKeys<PojoContainingTuple>(new String[] {"theTuple.*"}, cType);
- boolean[] orders = new boolean[keys.getNumberOfKeyFields()];
- Arrays.fill(orders, ascending);
- return cType.createComparator(keys.computeLogicalKeyPositions(), orders, 0, new ExecutionConfig());
- }
-
- @Override
- protected TypeSerializer<PojoContainingTuple> createSerializer() {
- return type.createSerializer(new ExecutionConfig());
- }
-
- @Override
- protected PojoContainingTuple[] getSortedTestData() {
- return data;
- }
-
- public static class Subclass extends PojoContainingTuple {
-
- public long additionalField;
-
- public Subclass() {
- }
-
- public Subclass(int i, long l1, long l2, long additionalField) {
- super(i, l1, l2);
- this.additionalField = additionalField;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java
deleted file mode 100644
index 8c61a19..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/PojoSubclassSerializerTest.java
+++ /dev/null
@@ -1,196 +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.java.typeutils.runtime;
-
-import com.google.common.base.Objects;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.SerializerTestBase;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.junit.Test;
-
-import java.util.Random;
-
-/**
- * A test for the {@link PojoSerializer}.
- */
-public class PojoSubclassSerializerTest extends SerializerTestBase<PojoSubclassSerializerTest.TestUserClassBase> {
- private TypeInformation<TestUserClassBase> type = TypeExtractor.getForClass(TestUserClassBase.class);
-
- @Override
- protected TypeSerializer<TestUserClassBase> createSerializer() {
- // only register one of the three child classes, the third child class is NO POJO
- ExecutionConfig conf = new ExecutionConfig();
- conf.registerPojoType(TestUserClass1.class);
- TypeSerializer<TestUserClassBase> serializer = type.createSerializer(conf);
- assert(serializer instanceof PojoSerializer);
- return serializer;
- }
-
- @Override
- protected int getLength() {
- return -1;
- }
-
- @Override
- protected Class<TestUserClassBase> getTypeClass() {
- return TestUserClassBase.class;
- }
-
- @Override
- protected TestUserClassBase[] getTestData() {
- Random rnd = new Random(874597969123412341L);
-
- return new TestUserClassBase[]{
- new TestUserClass1(rnd.nextInt(), "foo", rnd.nextLong()),
- new TestUserClass2(rnd.nextInt(), "bar", rnd.nextFloat()),
- new TestUserClass3(rnd.nextInt(), "bar", rnd.nextFloat())
- };
-
- }
-
- @Override
- @Test
- public void testInstantiate() {
- // don't do anything, since the PojoSerializer with subclass will return null
- }
-
- // User code class for testing the serializer
- public static abstract class TestUserClassBase {
- public int dumm1;
- public String dumm2;
-
-
- public TestUserClassBase() {
- }
-
- public TestUserClassBase(int dumm1, String dumm2) {
- this.dumm1 = dumm1;
- this.dumm2 = dumm2;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(dumm1, dumm2);
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClassBase)) {
- return false;
- }
- TestUserClassBase otherTUC = (TestUserClassBase) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- return true;
- }
- }
-
- public static class TestUserClass1 extends TestUserClassBase {
- public long dumm3;
-
- public TestUserClass1() {
- }
-
- public TestUserClass1(int dumm1, String dumm2, long dumm3) {
- super(dumm1, dumm2);
- this.dumm3 = dumm3;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClass1)) {
- return false;
- }
- TestUserClass1 otherTUC = (TestUserClass1) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- if (dumm3 != otherTUC.dumm3) {
- return false;
- }
- return true;
- }
- }
-
- public static class TestUserClass2 extends TestUserClassBase {
- public float dumm4;
-
- public TestUserClass2() {
- }
-
- public TestUserClass2(int dumm1, String dumm2, float dumm4) {
- super(dumm1, dumm2);
- this.dumm4 = dumm4;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClass2)) {
- return false;
- }
- TestUserClass2 otherTUC = (TestUserClass2) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- if (dumm4 != otherTUC.dumm4) {
- return false;
- }
- return true;
- }
- }
-
- public static class TestUserClass3 extends TestUserClassBase {
- public float dumm4;
-
- public TestUserClass3(int dumm1, String dumm2, float dumm4) {
- super(dumm1, dumm2);
- this.dumm4 = dumm4;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClass3)) {
- return false;
- }
- TestUserClass3 otherTUC = (TestUserClass3) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- if (dumm4 != otherTUC.dumm4) {
- return false;
- }
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java
deleted file mode 100644
index 7c608f2..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/StringArrayWritable.java
+++ /dev/null
@@ -1,83 +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.java.typeutils.runtime;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.hadoop.io.Writable;
-
-public class StringArrayWritable implements Writable, Comparable<StringArrayWritable> {
-
- private String[] array = new String[0];
-
- public StringArrayWritable() {
- super();
- }
-
- public StringArrayWritable(String[] array) {
- this.array = array;
- }
-
- @Override
- public void write(DataOutput out) throws IOException {
- out.writeInt(this.array.length);
-
- for(String str : this.array) {
- byte[] b = str.getBytes();
- out.writeInt(b.length);
- out.write(b);
- }
- }
-
- @Override
- public void readFields(DataInput in) throws IOException {
- this.array = new String[in.readInt()];
-
- for(int i = 0; i < this.array.length; i++) {
- byte[] b = new byte[in.readInt()];
- in.readFully(b);
- this.array[i] = new String(b);
- }
- }
-
- @Override
- public int compareTo(StringArrayWritable o) {
- if(this.array.length != o.array.length) {
- return this.array.length - o.array.length;
- }
-
- for(int i = 0; i < this.array.length; i++) {
- int comp = this.array[i].compareTo(o.array[i]);
- if(comp != 0) {
- return comp;
- }
- }
- return 0;
- }
-
- @Override
- public boolean equals(Object obj) {
- if(!(obj instanceof StringArrayWritable)) {
- return false;
- }
- return this.compareTo((StringArrayWritable) obj) == 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java
deleted file mode 100644
index b797090..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/SubclassFromInterfaceSerializerTest.java
+++ /dev/null
@@ -1,171 +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.java.typeutils.runtime;
-
-import com.google.common.base.Objects;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.SerializerTestBase;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
-import org.junit.Test;
-
-import java.util.Random;
-
-/**
- * Testing the serialization of classes which are subclasses of a class that implements an interface.
- */
-public class SubclassFromInterfaceSerializerTest extends SerializerTestBase<SubclassFromInterfaceSerializerTest.TestUserInterface> {
- private TypeInformation<TestUserInterface> type = TypeExtractor.getForClass(TestUserInterface.class);
-
- @Override
- protected TypeSerializer<TestUserInterface> createSerializer() {
- // only register one of the two child classes
- ExecutionConfig conf = new ExecutionConfig();
- conf.registerPojoType(TestUserClass2.class);
- TypeSerializer<TestUserInterface> serializer = type.createSerializer(conf);
- assert(serializer instanceof KryoSerializer);
- return serializer;
- }
-
- @Override
- protected int getLength() {
- return -1;
- }
-
- @Override
- protected Class<TestUserInterface> getTypeClass() {
- return TestUserInterface.class;
- }
-
- @Override
- protected TestUserInterface[] getTestData() {
- Random rnd = new Random(874597969123412341L);
-
- return new TestUserInterface[]{
- new TestUserClass1(rnd.nextInt(), "foo", rnd.nextLong()),
- new TestUserClass2(rnd.nextInt(), "bar", rnd.nextFloat())
- };
-
- }
-
- @Override
- @Test
- public void testInstantiate() {
- // don't do anything, since the PojoSerializer with subclass will return null
- }
-
- public interface TestUserInterface {}
-
- // User code class for testing the serializer
- public static class TestUserClassBase implements TestUserInterface {
- public int dumm1;
- public String dumm2;
-
-
- public TestUserClassBase() {
- }
-
- public TestUserClassBase(int dumm1, String dumm2) {
- this.dumm1 = dumm1;
- this.dumm2 = dumm2;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(dumm1, dumm2);
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClassBase)) {
- return false;
- }
- TestUserClassBase otherTUC = (TestUserClassBase) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- return true;
- }
- }
-
- public static class TestUserClass1 extends TestUserClassBase {
- public long dumm3;
-
- public TestUserClass1() {
- }
-
- public TestUserClass1(int dumm1, String dumm2, long dumm3) {
- super(dumm1, dumm2);
- this.dumm3 = dumm3;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClass1)) {
- return false;
- }
- TestUserClass1 otherTUC = (TestUserClass1) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- if (dumm3 != otherTUC.dumm3) {
- return false;
- }
- return true;
- }
- }
-
- public static class TestUserClass2 extends TestUserClassBase {
- public float dumm4;
-
- public TestUserClass2() {
- }
-
- public TestUserClass2(int dumm1, String dumm2, float dumm4) {
- super(dumm1, dumm2);
- this.dumm4 = dumm4;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof TestUserClass2)) {
- return false;
- }
- TestUserClass2 otherTUC = (TestUserClass2) other;
- if (dumm1 != otherTUC.dumm1) {
- return false;
- }
- if (!dumm2.equals(otherTUC.dumm2)) {
- return false;
- }
- if (dumm4 != otherTUC.dumm4) {
- return false;
- }
- return true;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java
deleted file mode 100644
index 87be6db..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TestDataOutputSerializer.java
+++ /dev/null
@@ -1,308 +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.java.typeutils.runtime;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.UTFDataFormatException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.core.memory.MemoryUtils;
-
-public final class TestDataOutputSerializer implements DataOutputView {
-
- private byte[] buffer;
-
- private int position;
-
- private ByteBuffer wrapper;
-
- private final int maxSize;
-
-
- public TestDataOutputSerializer(int startSize) {
- this(startSize, Integer.MAX_VALUE);
- }
-
- public TestDataOutputSerializer(int startSize, int maxSize) {
- if (startSize < 1 || startSize > maxSize) {
- throw new IllegalArgumentException();
- }
-
- this.buffer = new byte[startSize];
- this.wrapper = ByteBuffer.wrap(buffer);
- this.maxSize = maxSize;
- }
-
- public ByteBuffer wrapAsByteBuffer() {
- this.wrapper.position(0);
- this.wrapper.limit(this.position);
- return this.wrapper;
- }
-
- public byte[] copyByteBuffer() {
- byte[] target = new byte[position];
- System.arraycopy(buffer, 0, target, 0, position);
-
- return target;
- }
-
- public void clear() {
- this.position = 0;
- }
-
- public int length() {
- return this.position;
- }
-
- @Override
- public String toString() {
- return String.format("[pos=%d cap=%d]", this.position, this.buffer.length);
- }
-
- // ----------------------------------------------------------------------------------------
- // Data Output
- // ----------------------------------------------------------------------------------------
-
- @Override
- public void write(int b) throws IOException {
- if (this.position >= this.buffer.length) {
- resize(1);
- }
- this.buffer[this.position++] = (byte) (b & 0xff);
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- write(b, 0, b.length);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- if (len < 0 || off > b.length - len) {
- throw new ArrayIndexOutOfBoundsException();
- }
- if (this.position > this.buffer.length - len) {
- resize(len);
- }
- System.arraycopy(b, off, this.buffer, this.position, len);
- this.position += len;
- }
-
- @Override
- public void writeBoolean(boolean v) throws IOException {
- write(v ? 1 : 0);
- }
-
- @Override
- public void writeByte(int v) throws IOException {
- write(v);
- }
-
- @Override
- public void writeBytes(String s) throws IOException {
- final int sLen = s.length();
- if (this.position >= this.buffer.length - sLen) {
- resize(sLen);
- }
-
- for (int i = 0; i < sLen; i++) {
- writeByte(s.charAt(i));
- }
- this.position += sLen;
- }
-
- @Override
- public void writeChar(int v) throws IOException {
- if (this.position >= this.buffer.length - 1) {
- resize(2);
- }
- this.buffer[this.position++] = (byte) (v >> 8);
- this.buffer[this.position++] = (byte) v;
- }
-
- @Override
- public void writeChars(String s) throws IOException {
- final int sLen = s.length();
- if (this.position >= this.buffer.length - 2*sLen) {
- resize(2*sLen);
- }
- for (int i = 0; i < sLen; i++) {
- writeChar(s.charAt(i));
- }
- }
-
- @Override
- public void writeDouble(double v) throws IOException {
- writeLong(Double.doubleToLongBits(v));
- }
-
- @Override
- public void writeFloat(float v) throws IOException {
- writeInt(Float.floatToIntBits(v));
- }
-
- @SuppressWarnings("restriction")
- @Override
- public void writeInt(int v) throws IOException {
- if (this.position >= this.buffer.length - 3) {
- resize(4);
- }
- if (LITTLE_ENDIAN) {
- v = Integer.reverseBytes(v);
- }
- UNSAFE.putInt(this.buffer, BASE_OFFSET + this.position, v);
- this.position += 4;
- }
-
- @SuppressWarnings("restriction")
- @Override
- public void writeLong(long v) throws IOException {
- if (this.position >= this.buffer.length - 7) {
- resize(8);
- }
- if (LITTLE_ENDIAN) {
- v = Long.reverseBytes(v);
- }
- UNSAFE.putLong(this.buffer, BASE_OFFSET + this.position, v);
- this.position += 8;
- }
-
- @Override
- public void writeShort(int v) throws IOException {
- if (this.position >= this.buffer.length - 1) {
- resize(2);
- }
- this.buffer[this.position++] = (byte) ((v >>> 8) & 0xff);
- this.buffer[this.position++] = (byte) ((v >>> 0) & 0xff);
- }
-
- @Override
- public void writeUTF(String str) throws IOException {
- int strlen = str.length();
- int utflen = 0;
- int c;
-
- /* use charAt instead of copying String to char array */
- for (int i = 0; i < strlen; i++) {
- c = str.charAt(i);
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- } else if (c > 0x07FF) {
- utflen += 3;
- } else {
- utflen += 2;
- }
- }
-
- if (utflen > 65535) {
- throw new UTFDataFormatException("Encoded string is too long: " + utflen);
- }
- else if (this.position > this.buffer.length - utflen - 2) {
- resize(utflen + 2);
- }
-
- byte[] bytearr = this.buffer;
- int count = this.position;
-
- bytearr[count++] = (byte) ((utflen >>> 8) & 0xFF);
- bytearr[count++] = (byte) ((utflen >>> 0) & 0xFF);
-
- int i = 0;
- for (i = 0; i < strlen; i++) {
- c = str.charAt(i);
- if (!((c >= 0x0001) && (c <= 0x007F))) {
- break;
- }
- bytearr[count++] = (byte) c;
- }
-
- for (; i < strlen; i++) {
- c = str.charAt(i);
- if ((c >= 0x0001) && (c <= 0x007F)) {
- bytearr[count++] = (byte) c;
-
- } else if (c > 0x07FF) {
- bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
- bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
- bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- } else {
- bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
- bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- }
-
- this.position = count;
- }
-
-
- private void resize(int minCapacityAdd) throws IOException {
- try {
- int newLen = Math.max(this.buffer.length * 2, this.buffer.length + minCapacityAdd);
-
- if (newLen > maxSize) {
-
- if (this.buffer.length + minCapacityAdd > maxSize) {
- throw new EOFException("Exceeded maximum capacity");
- }
-
- newLen = maxSize;
- }
-
- final byte[] nb = new byte[newLen];
- System.arraycopy(this.buffer, 0, nb, 0, this.position);
- this.buffer = nb;
- this.wrapper = ByteBuffer.wrap(this.buffer);
- }
- catch (NegativeArraySizeException nasex) {
- throw new IOException("Serialization failed because the record length would exceed 2GB (max addressable array size in Java).");
- }
- }
-
- @SuppressWarnings("restriction")
- private static final sun.misc.Unsafe UNSAFE = MemoryUtils.UNSAFE;
-
- @SuppressWarnings("restriction")
- private static final long BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
-
- private static final boolean LITTLE_ENDIAN = (MemoryUtils.NATIVE_BYTE_ORDER == ByteOrder.LITTLE_ENDIAN);
-
- @Override
- public void skipBytesToWrite(int numBytes) throws IOException {
- if(buffer.length - this.position < numBytes){
- throw new EOFException("Could not skip " + numBytes + " bytes.");
- }
-
- this.position += numBytes;
- }
-
- @Override
- public void write(DataInputView source, int numBytes) throws IOException {
- if(buffer.length - this.position < numBytes){
- throw new EOFException("Could not write " + numBytes + " bytes. Buffer overflow.");
- }
-
- source.read(this.buffer, this.position, numBytes);
- this.position += numBytes;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java
deleted file mode 100644
index cfc4914..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD2Test.java
+++ /dev/null
@@ -1,73 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorILD2Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, Long, Double>(4, 14L, 20.0),
- new Tuple3<Integer, Long, Double>(4, 15L, 23.2),
- new Tuple3<Integer, Long, Double>(5, 15L, 20.0),
- new Tuple3<Integer, Long, Double>(5, 20L, 20.0),
- new Tuple3<Integer, Long, Double>(6, 20L, 23.2),
- new Tuple3<Integer, Long, Double>(6, 29L, 20.0),
- new Tuple3<Integer, Long, Double>(7, 29L, 20.0),
- new Tuple3<Integer, Long, Double>(7, 34L, 23.2)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, Long, Double>>(
- new int[]{0, 1},
- new TypeComparator[]{
- new IntComparator(ascending),
- new LongComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, Long, Double>>(
- (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new LongSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java
deleted file mode 100644
index e5a0e6c..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILD3Test.java
+++ /dev/null
@@ -1,75 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorILD3Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 20.0),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 23.2),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(9), 20.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(4), 20.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(4), 23.2),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(9), 20.0),
- new Tuple3<Integer, Long, Double>(6, Long.valueOf(4), 20.0),
- new Tuple3<Integer, Long, Double>(6, Long.valueOf(4), 23.2)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, Long, Double>>(
- new int[]{0, 1, 2},
- new TypeComparator[]{
- new IntComparator(ascending),
- new LongComparator(ascending),
- new DoubleComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, Long, Double>>(
- (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new LongSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java
deleted file mode 100644
index a1e6c40..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDC3Test.java
+++ /dev/null
@@ -1,75 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorILDC3Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 20.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(1), 20.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(2), 20.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(10), 23.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(19), 24.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(20), 24.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(24), 25.0),
- new Tuple3<Integer, Long, Double>(5, Long.valueOf(25), 25.0)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, Long, Double>>(
- new int[]{2, 0, 1},
- new TypeComparator[]{
- new DoubleComparator(ascending),
- new IntComparator(ascending),
- new LongComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, Long, Double>>(
- (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new LongSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java
deleted file mode 100644
index b5c0c1f..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDX1Test.java
+++ /dev/null
@@ -1,71 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorILDX1Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(4), 20.0),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(5), 23.2),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(9), 20.0),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(10), 24.0),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(19), 23.2),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(20), 24.0),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(24), 20.0),
- new Tuple3<Integer, Long, Double>(4, Long.valueOf(25), 23.2)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, Long, Double>>(
- new int[]{1},
- new TypeComparator[]{
- new LongComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, Long, Double>>(
- (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new LongSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java
deleted file mode 100644
index 793a2f4..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorILDXC2Test.java
+++ /dev/null
@@ -1,73 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorILDXC2Test extends TupleComparatorTestBase<Tuple3<Integer, Long, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, Long, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, Long, Double>(4, 4L, 20.0),
- new Tuple3<Integer, Long, Double>(4, 5L, 20.0),
- new Tuple3<Integer, Long, Double>(4, 3L, 23.0),
- new Tuple3<Integer, Long, Double>(4, 19L, 23.0),
- new Tuple3<Integer, Long, Double>(4, 17L, 24.0),
- new Tuple3<Integer, Long, Double>(4, 18L, 24.0),
- new Tuple3<Integer, Long, Double>(4, 24L, 25.0),
- new Tuple3<Integer, Long, Double>(4, 25L, 25.0)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, Long, Double>>(
- new int[]{2, 1},
- new TypeComparator[]{
- new DoubleComparator(ascending),
- new LongComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, DoubleSerializer.INSTANCE, LongSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, Long, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, Long, Double>>(
- (Class<Tuple3<Integer, Long, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new LongSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, Long, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
[28/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java
new file mode 100644
index 0000000..2ab1d0a
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple15;
+
+public class Tuple15Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> {
+
+ private List<Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> tuples = new ArrayList<>();
+
+ public Tuple15Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14){
+ tuples.add(new Tuple15<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>[] build(){
+ return tuples.toArray(new Tuple15[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java
new file mode 100644
index 0000000..5b4fba2
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple16;
+
+public class Tuple16Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> {
+
+ private List<Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> tuples = new ArrayList<>();
+
+ public Tuple16Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15){
+ tuples.add(new Tuple16<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>[] build(){
+ return tuples.toArray(new Tuple16[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java
new file mode 100644
index 0000000..68ba92b
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple17;
+
+public class Tuple17Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> {
+
+ private List<Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>> tuples = new ArrayList<>();
+
+ public Tuple17Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16){
+ tuples.add(new Tuple17<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>[] build(){
+ return tuples.toArray(new Tuple17[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java
new file mode 100644
index 0000000..d4ee37c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple18;
+
+public class Tuple18Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> {
+
+ private List<Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>> tuples = new ArrayList<>();
+
+ public Tuple18Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17){
+ tuples.add(new Tuple18<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>[] build(){
+ return tuples.toArray(new Tuple18[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java
new file mode 100644
index 0000000..baf00ce
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple19;
+
+public class Tuple19Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> {
+
+ private List<Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> tuples = new ArrayList<>();
+
+ public Tuple19Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18){
+ tuples.add(new Tuple19<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>[] build(){
+ return tuples.toArray(new Tuple19[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java
new file mode 100644
index 0000000..f16a9d1
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple1;
+
+public class Tuple1Builder<T0> {
+
+ private List<Tuple1<T0>> tuples = new ArrayList<>();
+
+ public Tuple1Builder<T0> add(T0 value0){
+ tuples.add(new Tuple1<>(value0));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple1<T0>[] build(){
+ return tuples.toArray(new Tuple1[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java
new file mode 100644
index 0000000..41bb974
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple20;
+
+public class Tuple20Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> {
+
+ private List<Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>> tuples = new ArrayList<>();
+
+ public Tuple20Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19){
+ tuples.add(new Tuple20<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>[] build(){
+ return tuples.toArray(new Tuple20[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java
new file mode 100644
index 0000000..f24b7ec
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple21;
+
+public class Tuple21Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> {
+
+ private List<Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>> tuples = new ArrayList<>();
+
+ public Tuple21Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20){
+ tuples.add(new Tuple21<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>[] build(){
+ return tuples.toArray(new Tuple21[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java
new file mode 100644
index 0000000..710fe50
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple22;
+
+public class Tuple22Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> {
+
+ private List<Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>> tuples = new ArrayList<>();
+
+ public Tuple22Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21){
+ tuples.add(new Tuple22<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>[] build(){
+ return tuples.toArray(new Tuple22[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java
new file mode 100644
index 0000000..a81e6c1
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple23;
+
+public class Tuple23Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> {
+
+ private List<Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>> tuples = new ArrayList<>();
+
+ public Tuple23Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22){
+ tuples.add(new Tuple23<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>[] build(){
+ return tuples.toArray(new Tuple23[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java
new file mode 100644
index 0000000..2b6fa4c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple24;
+
+public class Tuple24Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> {
+
+ private List<Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>> tuples = new ArrayList<>();
+
+ public Tuple24Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23){
+ tuples.add(new Tuple24<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>[] build(){
+ return tuples.toArray(new Tuple24[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java
new file mode 100644
index 0000000..2ab94fb
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple25;
+
+public class Tuple25Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> {
+
+ private List<Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>> tuples = new ArrayList<>();
+
+ public Tuple25Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24){
+ tuples.add(new Tuple25<>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23, value24));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>[] build(){
+ return tuples.toArray(new Tuple25[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java
new file mode 100644
index 0000000..aa8ad9e
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+
+public class Tuple2Builder<T0, T1> {
+
+ private List<Tuple2<T0, T1>> tuples = new ArrayList<>();
+
+ public Tuple2Builder<T0, T1> add(T0 value0, T1 value1){
+ tuples.add(new Tuple2<>(value0, value1));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple2<T0, T1>[] build(){
+ return tuples.toArray(new Tuple2[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java
new file mode 100644
index 0000000..024c3c9
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple3;
+
+public class Tuple3Builder<T0, T1, T2> {
+
+ private List<Tuple3<T0, T1, T2>> tuples = new ArrayList<>();
+
+ public Tuple3Builder<T0, T1, T2> add(T0 value0, T1 value1, T2 value2){
+ tuples.add(new Tuple3<>(value0, value1, value2));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple3<T0, T1, T2>[] build(){
+ return tuples.toArray(new Tuple3[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java
new file mode 100644
index 0000000..f889dcb
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple4;
+
+public class Tuple4Builder<T0, T1, T2, T3> {
+
+ private List<Tuple4<T0, T1, T2, T3>> tuples = new ArrayList<>();
+
+ public Tuple4Builder<T0, T1, T2, T3> add(T0 value0, T1 value1, T2 value2, T3 value3){
+ tuples.add(new Tuple4<>(value0, value1, value2, value3));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple4<T0, T1, T2, T3>[] build(){
+ return tuples.toArray(new Tuple4[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java
new file mode 100644
index 0000000..9f0725c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple5;
+
+public class Tuple5Builder<T0, T1, T2, T3, T4> {
+
+ private List<Tuple5<T0, T1, T2, T3, T4>> tuples = new ArrayList<>();
+
+ public Tuple5Builder<T0, T1, T2, T3, T4> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4){
+ tuples.add(new Tuple5<>(value0, value1, value2, value3, value4));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple5<T0, T1, T2, T3, T4>[] build(){
+ return tuples.toArray(new Tuple5[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java
new file mode 100644
index 0000000..2320fdd
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple6;
+
+public class Tuple6Builder<T0, T1, T2, T3, T4, T5> {
+
+ private List<Tuple6<T0, T1, T2, T3, T4, T5>> tuples = new ArrayList<>();
+
+ public Tuple6Builder<T0, T1, T2, T3, T4, T5> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5){
+ tuples.add(new Tuple6<>(value0, value1, value2, value3, value4, value5));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple6<T0, T1, T2, T3, T4, T5>[] build(){
+ return tuples.toArray(new Tuple6[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java
new file mode 100644
index 0000000..278526b
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple7;
+
+public class Tuple7Builder<T0, T1, T2, T3, T4, T5, T6> {
+
+ private List<Tuple7<T0, T1, T2, T3, T4, T5, T6>> tuples = new ArrayList<>();
+
+ public Tuple7Builder<T0, T1, T2, T3, T4, T5, T6> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6){
+ tuples.add(new Tuple7<>(value0, value1, value2, value3, value4, value5, value6));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple7<T0, T1, T2, T3, T4, T5, T6>[] build(){
+ return tuples.toArray(new Tuple7[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java
new file mode 100644
index 0000000..e09acde
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple8;
+
+public class Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> {
+
+ private List<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tuples = new ArrayList<>();
+
+ public Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7){
+ tuples.add(new Tuple8<>(value0, value1, value2, value3, value4, value5, value6, value7));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>[] build(){
+ return tuples.toArray(new Tuple8[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java
new file mode 100644
index 0000000..cea4e41
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flink.api.java.tuple.Tuple9;
+
+public class Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> {
+
+ private List<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tuples = new ArrayList<>();
+
+ public Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8){
+ tuples.add(new Tuple9<>(value0, value1, value2, value3, value4, value5, value6, value7, value8));
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>[] build(){
+ return tuples.toArray(new Tuple9[tuples.size()]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java b/flink-core/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java
new file mode 100644
index 0000000..8b149bd
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java
@@ -0,0 +1,521 @@
+/*
+ * 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.java.tuple;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Scanner;
+
+/**
+ * Source code generator for tuple classes and classes which depend on the arity of tuples.
+ */
+class TupleGenerator {
+
+ // Parameters for tuple classes
+
+ private static final String ROOT_DIRECTORY = "./flink-core/src/main/java";
+
+ private static final String PACKAGE = "org.apache.flink.api.java.tuple";
+
+ private static final String BUILDER_SUFFIX = "builder";
+
+ private static final String GEN_TYPE_PREFIX = "T";
+
+ // Parameters for tuple-dependent classes
+ private static final String BEGIN_INDICATOR = "BEGIN_OF_TUPLE_DEPENDENT_CODE";
+
+ private static final String END_INDICATOR = "END_OF_TUPLE_DEPENDENT_CODE";
+
+ // Parameters for TupleTypeInfo
+ private static final String TUPLE_PACKAGE = "org.apache.flink.api.java.tuple";
+
+ private static final String TUPLE_CLASSNAME = "Tuple";
+
+ // min. and max. tuple arity
+ private static final int FIRST = 1;
+
+ private static final int LAST = 25;
+
+
+ public static void main(String[] args) throws Exception {
+ System.err.println("Current directory "+System.getProperty("user.dir"));
+ String rootDir = ROOT_DIRECTORY;
+ if(args.length > 0) {
+ rootDir = args[0] + "/" + ROOT_DIRECTORY;
+ }
+ System.err.println("Using root directory: "+rootDir);
+ File root = new File(rootDir);
+
+ createTupleClasses(root);
+
+ createTupleBuilderClasses(root);
+
+ modifyTupleType(root);
+
+ }
+
+ private static File getPackage(File root, String packageString) {
+ File dir = new File(root, packageString.replace('.', '/'));
+ if (!dir.exists() && dir.isDirectory()) {
+ System.err.println("None existent directory: " + dir.getAbsolutePath());
+ System.exit(1);
+ }
+ return dir;
+ }
+
+ private static void insertCodeIntoFile(String code, File file) throws IOException {
+ String fileContent = Files.toString(file, Charsets.UTF_8);
+
+ try (Scanner s = new Scanner(fileContent)) {
+ StringBuilder sb = new StringBuilder();
+ String line;
+
+ boolean indicatorFound = false;
+
+ // add file beginning
+ while (s.hasNextLine() && (line = s.nextLine()) != null) {
+ sb.append(line).append("\n");
+ if (line.contains(BEGIN_INDICATOR)) {
+ indicatorFound = true;
+ break;
+ }
+ }
+
+ if(!indicatorFound) {
+ System.out.println("No indicator found in '" + file + "'. Will skip code generation.");
+ s.close();
+ return;
+ }
+
+ // add generator signature
+ sb.append("\t// GENERATED FROM ").append(TupleGenerator.class.getName()).append(".\n");
+
+ // add tuple dependent code
+ sb.append(code).append("\n");
+
+ // skip generated code
+ while (s.hasNextLine() && (line = s.nextLine()) != null) {
+ if (line.contains(END_INDICATOR)) {
+ sb.append(line).append("\n");
+ break;
+ }
+ }
+
+ // add file ending
+ while (s.hasNextLine() && (line = s.nextLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ Files.write(sb.toString(), file, Charsets.UTF_8);
+ }
+ }
+
+
+ private static void modifyTupleType(File root) throws IOException {
+ // generate code
+ StringBuilder sb = new StringBuilder();
+ sb.append("\tprivate static final Class<?>[] CLASSES = new Class<?>[] {\n\t\tTuple0.class");
+ for (int i = FIRST; i <= LAST; i++) {
+ sb.append(", Tuple").append(i).append(".class");
+ }
+ sb.append("\n\t};");
+
+ // insert code into file
+ File dir = getPackage(root, TUPLE_PACKAGE);
+ File tupleTypeInfoClass = new File(dir, TUPLE_CLASSNAME + ".java");
+ insertCodeIntoFile(sb.toString(), tupleTypeInfoClass);
+ }
+
+ private static void createTupleClasses(File root) throws FileNotFoundException {
+ File dir = getPackage(root, PACKAGE);
+
+ for (int i = FIRST; i <= LAST; i++) {
+ File tupleFile = new File(dir, "Tuple" + i + ".java");
+ PrintWriter writer = new PrintWriter(tupleFile);
+ writeTupleClass(writer, i);
+ writer.flush();
+ writer.close();
+ }
+ }
+
+ private static void writeTupleClass(PrintWriter w, int numFields) {
+ final String className = "Tuple" + numFields;
+
+ // head
+ w.print(HEADER);
+
+ // package and imports
+ w.println("package " + PACKAGE + ';');
+ w.println();
+ w.println("import org.apache.flink.util.StringUtils;");
+ w.println();
+
+ // class declaration and class comments
+ w.println("/**");
+ w.println(" * A tuple with " + numFields + " fields. Tuples are strongly typed; each field may be of a separate type.");
+ w.println(" * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position");
+ w.println(" * through the {@link #getField(int)} method. The tuple field positions start at zero.");
+ w.println(" * <p>");
+ w.println(" * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work");
+ w.println(" * with Tuples to reuse objects in order to reduce pressure on the garbage collector.");
+ w.println(" *");
+ w.println(" * @see Tuple");
+ w.println(" *");
+ for (int i = 0; i < numFields; i++) {
+ w.println(" * @param <" + GEN_TYPE_PREFIX + i + "> The type of field " + i);
+ }
+ w.println(" */");
+ w.print("public class " + className + "<");
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ w.print(", ");
+ }
+ w.print(GEN_TYPE_PREFIX + i);
+ }
+ w.println("> extends Tuple {");
+ w.println();
+
+ w.println("\tprivate static final long serialVersionUID = 1L;");
+ w.println();
+
+ // fields
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t/** Field " + i + " of the tuple. */");
+ w.println("\tpublic " + GEN_TYPE_PREFIX + i + " f" + i + ';');
+ }
+ w.println();
+
+ String paramList = "("; // This will be like "(T0 value0, T1 value1)"
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ paramList += ", ";
+ }
+ paramList += GEN_TYPE_PREFIX + i + " value" + i;
+ }
+ paramList += ")";
+
+ // constructors
+ w.println("\t/**");
+ w.println("\t * Creates a new tuple where all fields are null.");
+ w.println("\t */");
+ w.println("\tpublic " + className + "() {}");
+ w.println();
+ w.println("\t/**");
+ w.println("\t * Creates a new tuple and assigns the given values to the tuple's fields.");
+ w.println("\t *");
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t * @param value" + i + " The value for field " + i);
+ }
+ w.println("\t */");
+ w.println("\tpublic " + className + paramList + " {");
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t\tthis.f" + i + " = value" + i + ';');
+ }
+ w.println("\t}");
+ w.println();
+
+
+ // arity accessor
+ w.println("\t@Override");
+ w.println("\tpublic int getArity() { return " + numFields + "; }");
+ w.println();
+
+ // accessor getter method
+ w.println("\t@Override");
+ w.println("\t@SuppressWarnings(\"unchecked\")");
+ w.println("\tpublic <T> T getField(int pos) {");
+ w.println("\t\tswitch(pos) {");
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t\t\tcase " + i + ": return (T) this.f" + i + ';');
+ }
+ w.println("\t\t\tdefault: throw new IndexOutOfBoundsException(String.valueOf(pos));");
+ w.println("\t\t}");
+ w.println("\t}");
+ w.println();
+
+ // accessor setter method
+ w.println("\t@Override");
+ w.println("\t@SuppressWarnings(\"unchecked\")");
+ w.println("\tpublic <T> void setField(T value, int pos) {");
+ w.println("\t\tswitch(pos) {");
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t\t\tcase " + i + ':');
+ w.println("\t\t\t\tthis.f" + i + " = (" + GEN_TYPE_PREFIX + i + ") value;");
+ w.println("\t\t\t\tbreak;");
+ }
+ w.println("\t\t\tdefault: throw new IndexOutOfBoundsException(String.valueOf(pos));");
+ w.println("\t\t}");
+ w.println("\t}");
+ w.println();
+
+ // accessor setter method for all fields
+ w.println("\t/**");
+ w.println("\t * Sets new values to all fields of the tuple.");
+ w.println("\t *");
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t * @param value" + i + " The value for field " + i);
+ }
+ w.println("\t */");
+ w.println("\tpublic void setFields" + paramList + " {");
+ for (int i = 0; i < numFields; i++) {
+ w.println("\t\tthis.f" + i + " = value" + i + ';');
+ }
+ w.println("\t}");
+ w.println();
+
+ // swap method only for Tuple2
+ if (numFields == 2) {
+ w.println("\t/**");
+ w.println("\t* Returns a shallow copy of the tuple with swapped values.");
+ w.println("\t*");
+ w.println("\t* @return shallow copy of the tuple with swapped values");
+ w.println("\t*/");
+ w.println("\tpublic Tuple2<T1, T0> swap() {");
+ w.println("\t\treturn new Tuple2<T1, T0>(f1, f0);");
+ w.println("\t}");
+ }
+
+ // standard utilities (toString, equals, hashCode, copy)
+ w.println();
+ w.println("\t// -------------------------------------------------------------------------------------------------");
+ w.println("\t// standard utilities");
+ w.println("\t// -------------------------------------------------------------------------------------------------");
+ w.println();
+ w.println("\t/**");
+ w.println("\t * Creates a string representation of the tuple in the form");
+ w.print("\t * (f0");
+ for (int i = 1; i < numFields; i++) {
+ w.print(", f" + i);
+ }
+ w.println("),");
+ w.println("\t * where the individual fields are the value returned by calling {@link Object#toString} on that field.");
+ w.println("\t * @return The string representation of the tuple.");
+ w.println("\t */");
+ w.println("\t@Override");
+ w.println("\tpublic String toString() {");
+ w.println("\t\treturn \"(\" + StringUtils.arrayAwareToString(this.f0)");
+ for (int i = 1; i < numFields; i++) {
+ w.println("\t\t\t+ \",\" + StringUtils.arrayAwareToString(this.f" + i + ")");
+ }
+ w.println("\t\t\t+ \")\";");
+ w.println("\t}");
+
+ w.println();
+ w.println("\t/**");
+ w.println("\t * Deep equality for tuples by calling equals() on the tuple members");
+ w.println("\t * @param o the object checked for equality");
+ w.println("\t * @return true if this is equal to o.");
+ w.println("\t */");
+ w.println("\t@Override");
+ w.println("\tpublic boolean equals(Object o) {");
+ w.println("\t\tif(this == o) { return true; }");
+ w.println("\t\tif (!(o instanceof " + className + ")) { return false; }");
+ w.println("\t\t@SuppressWarnings(\"rawtypes\")");
+ w.println("\t\t" + className + " tuple = (" + className + ") o;");
+ for (int i = 0; i < numFields; i++) {
+ String field = "f" + i;
+ w.println("\t\tif (" + field + " != null ? !" + field +".equals(tuple." +
+ field + ") : tuple." + field + " != null) { return false; }");
+ }
+ w.println("\t\treturn true;");
+ w.println("\t}");
+
+ w.println();
+ w.println("\t@Override");
+ w.println("\tpublic int hashCode() {");
+ w.println("\t\tint result = f0 != null ? f0.hashCode() : 0;");
+ for (int i = 1; i < numFields; i++) {
+ String field = "f" + i;
+ w.println("\t\tresult = 31 * result + (" + field + " != null ? " + field + ".hashCode() : 0);");
+ }
+ w.println("\t\treturn result;");
+ w.println("\t}");
+
+
+ String tupleTypes = "<";
+ for (int i = 0; i < numFields; i++) {
+ tupleTypes += "T" + i;
+ if (i < numFields - 1) {
+ tupleTypes += ",";
+ }
+ }
+ tupleTypes += ">";
+
+ w.println();
+ w.println("\t/**");
+ w.println("\t* Shallow tuple copy.");
+ w.println("\t* @return A new Tuple with the same fields as this.");
+ w.println("\t*/");
+ w.println("\t@Override");
+ w.println("\t@SuppressWarnings(\"unchecked\")");
+ w.println("\tpublic " + className + tupleTypes + " copy(){ ");
+
+ w.print("\t\treturn new " + className + tupleTypes + "(this.f0");
+ if (numFields > 1) {
+ w.println(",");
+ }
+ for (int i = 1; i < numFields; i++) {
+ String field = "f" + i;
+ w.print("\t\t\tthis." + field);
+ if (i < numFields - 1) {
+ w.println(",");
+ }
+ }
+ w.println(");");
+ w.println("\t}");
+
+ w.println();
+ w.println("\t/**");
+ w.println("\t * Creates a new tuple and assigns the given values to the tuple's fields.");
+ w.println("\t * This is more convenient than using the constructor, because the compiler can");
+ w.println("\t * infer the generic type arguments implicitly. For example:");
+ w.println("\t * {@code Tuple3.of(n, x, s)}");
+ w.println("\t * instead of");
+ w.println("\t * {@code new Tuple3<Integer, Double, String>(n, x, s)}");
+ w.println("\t */");
+ w.println("\tpublic static " + tupleTypes + " " + className + tupleTypes + " of" + paramList + " {");
+ w.print("\t\treturn new " + className + tupleTypes + "(");
+ for(int i = 0; i < numFields; i++) {
+ w.print("value" + i);
+ if(i < numFields - 1) {
+ w.print(", ");
+ }
+ }
+ w.println(");");
+ w.println("\t}");
+
+ // foot
+ w.println("}");
+ }
+
+ private static void createTupleBuilderClasses(File root) throws FileNotFoundException {
+ File dir = getPackage(root, PACKAGE+"."+BUILDER_SUFFIX);
+
+ for (int i = FIRST; i <= LAST; i++) {
+ File tupleFile = new File(dir, "Tuple" + i + "Builder.java");
+ PrintWriter writer = new PrintWriter(tupleFile);
+ writeTupleBuilderClass(writer, i);
+ writer.flush();
+ writer.close();
+ }
+ }
+
+ private static void printGenericsString(PrintWriter w, int numFields){
+ w.print("<");
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ w.print(", ");
+ }
+ w.print(GEN_TYPE_PREFIX + i);
+ }
+ w.print(">");
+ }
+
+ private static void writeTupleBuilderClass(PrintWriter w, int numFields) {
+ final String className = "Tuple" + numFields + "Builder";
+
+ // head
+ w.print(HEADER);
+
+ // package and imports
+ w.println("package " + PACKAGE + "." + BUILDER_SUFFIX + ';');
+ w.println();
+ w.println("import java.util.ArrayList;");
+ w.println("import java.util.List;");
+ w.println();
+ w.println("import " + PACKAGE + ".Tuple" + numFields + ";");
+ w.println();
+
+ // class declaration
+ w.print("public class " + className);
+ printGenericsString(w, numFields);
+ w.println(" {");
+ w.println();
+
+ // Class-Attributes - a list of tuples
+ w.print("\tprivate List<Tuple" + numFields);
+ printGenericsString(w, numFields);
+ w.println("> tuples = new ArrayList<>();");
+ w.println();
+
+ // add(...) function for adding a single tuple
+ w.print("\tpublic " + className);
+ printGenericsString(w, numFields);
+ w.print(" add(");
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ w.print(", ");
+ }
+ w.print(GEN_TYPE_PREFIX + i + " value" + i);
+ }
+ w.println("){");
+ w.print("\t\ttuples.add(new Tuple" + numFields + "<>(");
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ w.print(", ");
+ }
+ w.print("value" + i);
+ }
+ w.println("));");
+ w.println("\t\treturn this;");
+ w.println("\t}");
+ w.println();
+
+ // build() function, returns an array of tuples
+ w.println("\t@SuppressWarnings(\"unchecked\")");
+ w.print("\tpublic Tuple" + numFields);
+ printGenericsString(w, numFields);
+ w.println("[] build(){");
+ w.println("\t\treturn tuples.toArray(new Tuple" + numFields + "[tuples.size()]);");
+ w.println("\t}");
+
+ // foot
+ w.println("}");
+ }
+
+ private static String HEADER =
+ "/*\n"
+ + " * Licensed to the Apache Software Foundation (ASF) under one\n"
+ + " * or more contributor license agreements. See the NOTICE file\n"
+ + " * distributed with this work for additional information\n"
+ + " * regarding copyright ownership. The ASF licenses this file\n"
+ + " * to you under the Apache License, Version 2.0 (the\n"
+ + " * \"License\"); you may not use this file except in compliance\n"
+ + " * with the License. You may obtain a copy of the License at\n"
+ + " *\n"
+ + " * http://www.apache.org/licenses/LICENSE-2.0\n"
+ + " *\n"
+ + " * Unless required by applicable law or agreed to in writing, software\n"
+ + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"
+ + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
+ + " * See the License for the specific language governing permissions and\n"
+ + " * limitations under the License.\n"
+ + " */" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "// --------------------------------------------------------------\n" +
+ "// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!\n" +
+ "// GENERATED FROM " + TupleGenerator.class.getName() + ".\n" +
+ "// --------------------------------------------------------------\n\n\n";
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
deleted file mode 100644
index 71b1f61..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
+++ /dev/null
@@ -1,118 +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.java.tuple;
-
-import org.apache.flink.types.NullFieldException;
-
-
-/**
- * The base class of all tuples. Tuples have a fix length and contain a set of fields,
- * which may all be of different types. Because Tuples are strongly typed, each distinct
- * tuple length is represented by its own class. Tuples exists with up to 25 fields and
- * are described in the classes {@link Tuple1} to {@link Tuple25}.
- * <p>
- * The fields in the tuples may be accessed directly a public fields, or via position (zero indexed)
- * {@link #getField(int)}.
- * <p>
- * Tuples are in principle serializable. However, they may contain non-serializable fields,
- * in which case serialization will fail.
- */
-public abstract class Tuple implements java.io.Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final int MAX_ARITY = 25;
-
-
- /**
- * Gets the field at the specified position.
- *
- * @param pos The position of the field, zero indexed.
- * @return The field at the specified position.
- * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
- */
- public abstract <T> T getField(int pos);
-
- /**
- * Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
- *
- * @param pos The position of the field, zero indexed.
- * @return The field at the specified position.
- * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
- * @throws NullFieldException Thrown, if the field at pos is null.
- */
- public <T> T getFieldNotNull(int pos){
- T field = getField(pos);
- if (field != null) {
- return field;
- } else {
- throw new NullFieldException(pos);
- }
- }
-
- /**
- * Sets the field at the specified position.
- *
- * @param value The value to be assigned to the field at the specified position.
- * @param pos The position of the field, zero indexed.
- * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
- */
- public abstract <T> void setField(T value, int pos);
-
- /**
- * Gets the number of field in the tuple (the tuple arity).
- *
- * @return The number of fields in the tuple.
- */
- public abstract int getArity();
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- public abstract <T extends Tuple> T copy();
-
- // --------------------------------------------------------------------------------------------
-
- /**
- * Gets the class corresponding to the tuple of the given arity (dimensions). For
- * example, {@code getTupleClass(3)} will return the {@code Tuple3.class}.
- *
- * @param arity The arity of the tuple class to get.
- * @return The tuple class with the given arity.
- */
- @SuppressWarnings("unchecked")
- public static Class<? extends Tuple> getTupleClass(int arity) {
- if (arity < 0 || arity > MAX_ARITY) {
- throw new IllegalArgumentException("The tuple arity must be in [0, " + MAX_ARITY + "].");
- }
- return (Class<? extends Tuple>) CLASSES[arity];
- }
-
- // --------------------------------------------------------------------------------------------
- // The following lines are generated.
- // --------------------------------------------------------------------------------------------
-
- // BEGIN_OF_TUPLE_DEPENDENT_CODE
- // GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
- private static final Class<?>[] CLASSES = new Class<?>[] {
- Tuple0.class, Tuple1.class, Tuple2.class, Tuple3.class, Tuple4.class, Tuple5.class, Tuple6.class, Tuple7.class, Tuple8.class, Tuple9.class, Tuple10.class, Tuple11.class, Tuple12.class, Tuple13.class, Tuple14.class, Tuple15.class, Tuple16.class, Tuple17.class, Tuple18.class, Tuple19.class, Tuple20.class, Tuple21.class, Tuple22.class, Tuple23.class, Tuple24.class, Tuple25.class
- };
- // END_OF_TUPLE_DEPENDENT_CODE
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java
deleted file mode 100644
index c3386dc..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java
+++ /dev/null
@@ -1,98 +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.java.tuple;
-
-import java.io.ObjectStreamException;
-
-/**
- * A tuple with 0 fields.
- *
- * <p>The Tuple0 is a soft singleton, i.e., there is a "singleton" instance, but it does
- * not prevent creation of additional instances.</p>
- *
- * @see Tuple
- */
-public class Tuple0 extends Tuple {
- private static final long serialVersionUID = 1L;
-
- /** An immutable reusable Tuple0 instance */
- public static final Tuple0 INSTANCE = new Tuple0();
-
- // ------------------------------------------------------------------------
-
- @Override
- public int getArity() {
- return 0;
- }
-
- @Override
- public <T> T getField(int pos) {
- throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
-
- @Override
- public <T> void setField(T value, int pos) {
- throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple0 copy(){
- return new Tuple0();
- }
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form "()"
- *
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "()";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- *
- * @param o
- * the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- return this == o || o instanceof Tuple0;
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
-
- // singleton deserialization
- private Object readResolve() throws ObjectStreamException {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java
deleted file mode 100644
index 01c5501..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java
+++ /dev/null
@@ -1,154 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 1 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- */
-public class Tuple1<T0> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple1() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- */
- public Tuple1(T0 value0) {
- this.f0 = value0;
- }
-
- @Override
- public int getArity() { return 1; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- */
- public void setFields(T0 value0) {
- this.f0 = value0;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple1)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple1 tuple = (Tuple1) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple1<T0> copy(){
- return new Tuple1<T0>(this.f0);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0> Tuple1<T0> of(T0 value0) {
- return new Tuple1<T0>(value0);
- }
-}
[25/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java
deleted file mode 100644
index 5f7194b..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple22.java
+++ /dev/null
@@ -1,469 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 22 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- * @param <T19> The type of field 19
- * @param <T20> The type of field 20
- * @param <T21> The type of field 21
- */
-public class Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
- /** Field 19 of the tuple. */
- public T19 f19;
- /** Field 20 of the tuple. */
- public T20 f20;
- /** Field 21 of the tuple. */
- public T21 f21;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple22() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- */
- public Tuple22(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- }
-
- @Override
- public int getArity() { return 22; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- case 19: return (T) this.f19;
- case 20: return (T) this.f20;
- case 21: return (T) this.f21;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- case 19:
- this.f19 = (T19) value;
- break;
- case 20:
- this.f20 = (T20) value;
- break;
- case 21:
- this.f21 = (T21) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + "," + StringUtils.arrayAwareToString(this.f19)
- + "," + StringUtils.arrayAwareToString(this.f20)
- + "," + StringUtils.arrayAwareToString(this.f21)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple22)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple22 tuple = (Tuple22) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
- if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
- if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- result = 31 * result + (f19 != null ? f19.hashCode() : 0);
- result = 31 * result + (f20 != null ? f20.hashCode() : 0);
- result = 31 * result + (f21 != null ? f21.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> copy(){
- return new Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18,
- this.f19,
- this.f20,
- this.f21);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21) {
- return new Tuple22<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java
deleted file mode 100644
index 35c71ce..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple23.java
+++ /dev/null
@@ -1,484 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 23 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- * @param <T19> The type of field 19
- * @param <T20> The type of field 20
- * @param <T21> The type of field 21
- * @param <T22> The type of field 22
- */
-public class Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
- /** Field 19 of the tuple. */
- public T19 f19;
- /** Field 20 of the tuple. */
- public T20 f20;
- /** Field 21 of the tuple. */
- public T21 f21;
- /** Field 22 of the tuple. */
- public T22 f22;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple23() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- * @param value22 The value for field 22
- */
- public Tuple23(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- this.f22 = value22;
- }
-
- @Override
- public int getArity() { return 23; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- case 19: return (T) this.f19;
- case 20: return (T) this.f20;
- case 21: return (T) this.f21;
- case 22: return (T) this.f22;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- case 19:
- this.f19 = (T19) value;
- break;
- case 20:
- this.f20 = (T20) value;
- break;
- case 21:
- this.f21 = (T21) value;
- break;
- case 22:
- this.f22 = (T22) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- * @param value22 The value for field 22
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- this.f22 = value22;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + "," + StringUtils.arrayAwareToString(this.f19)
- + "," + StringUtils.arrayAwareToString(this.f20)
- + "," + StringUtils.arrayAwareToString(this.f21)
- + "," + StringUtils.arrayAwareToString(this.f22)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple23)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple23 tuple = (Tuple23) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
- if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
- if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
- if (f22 != null ? !f22.equals(tuple.f22) : tuple.f22 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- result = 31 * result + (f19 != null ? f19.hashCode() : 0);
- result = 31 * result + (f20 != null ? f20.hashCode() : 0);
- result = 31 * result + (f21 != null ? f21.hashCode() : 0);
- result = 31 * result + (f22 != null ? f22.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> copy(){
- return new Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18,
- this.f19,
- this.f20,
- this.f21,
- this.f22);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22) {
- return new Tuple23<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java
deleted file mode 100644
index 5c7f91f..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple24.java
+++ /dev/null
@@ -1,499 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 24 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- * @param <T19> The type of field 19
- * @param <T20> The type of field 20
- * @param <T21> The type of field 21
- * @param <T22> The type of field 22
- * @param <T23> The type of field 23
- */
-public class Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
- /** Field 19 of the tuple. */
- public T19 f19;
- /** Field 20 of the tuple. */
- public T20 f20;
- /** Field 21 of the tuple. */
- public T21 f21;
- /** Field 22 of the tuple. */
- public T22 f22;
- /** Field 23 of the tuple. */
- public T23 f23;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple24() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- * @param value22 The value for field 22
- * @param value23 The value for field 23
- */
- public Tuple24(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- this.f22 = value22;
- this.f23 = value23;
- }
-
- @Override
- public int getArity() { return 24; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- case 19: return (T) this.f19;
- case 20: return (T) this.f20;
- case 21: return (T) this.f21;
- case 22: return (T) this.f22;
- case 23: return (T) this.f23;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- case 19:
- this.f19 = (T19) value;
- break;
- case 20:
- this.f20 = (T20) value;
- break;
- case 21:
- this.f21 = (T21) value;
- break;
- case 22:
- this.f22 = (T22) value;
- break;
- case 23:
- this.f23 = (T23) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- * @param value22 The value for field 22
- * @param value23 The value for field 23
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- this.f22 = value22;
- this.f23 = value23;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + "," + StringUtils.arrayAwareToString(this.f19)
- + "," + StringUtils.arrayAwareToString(this.f20)
- + "," + StringUtils.arrayAwareToString(this.f21)
- + "," + StringUtils.arrayAwareToString(this.f22)
- + "," + StringUtils.arrayAwareToString(this.f23)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple24)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple24 tuple = (Tuple24) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
- if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
- if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
- if (f22 != null ? !f22.equals(tuple.f22) : tuple.f22 != null) { return false; }
- if (f23 != null ? !f23.equals(tuple.f23) : tuple.f23 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- result = 31 * result + (f19 != null ? f19.hashCode() : 0);
- result = 31 * result + (f20 != null ? f20.hashCode() : 0);
- result = 31 * result + (f21 != null ? f21.hashCode() : 0);
- result = 31 * result + (f22 != null ? f22.hashCode() : 0);
- result = 31 * result + (f23 != null ? f23.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> copy(){
- return new Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18,
- this.f19,
- this.f20,
- this.f21,
- this.f22,
- this.f23);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23) {
- return new Tuple24<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java
deleted file mode 100644
index 901b838..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple25.java
+++ /dev/null
@@ -1,514 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 25 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- * @param <T4> The type of field 4
- * @param <T5> The type of field 5
- * @param <T6> The type of field 6
- * @param <T7> The type of field 7
- * @param <T8> The type of field 8
- * @param <T9> The type of field 9
- * @param <T10> The type of field 10
- * @param <T11> The type of field 11
- * @param <T12> The type of field 12
- * @param <T13> The type of field 13
- * @param <T14> The type of field 14
- * @param <T15> The type of field 15
- * @param <T16> The type of field 16
- * @param <T17> The type of field 17
- * @param <T18> The type of field 18
- * @param <T19> The type of field 19
- * @param <T20> The type of field 20
- * @param <T21> The type of field 21
- * @param <T22> The type of field 22
- * @param <T23> The type of field 23
- * @param <T24> The type of field 24
- */
-public class Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
- /** Field 4 of the tuple. */
- public T4 f4;
- /** Field 5 of the tuple. */
- public T5 f5;
- /** Field 6 of the tuple. */
- public T6 f6;
- /** Field 7 of the tuple. */
- public T7 f7;
- /** Field 8 of the tuple. */
- public T8 f8;
- /** Field 9 of the tuple. */
- public T9 f9;
- /** Field 10 of the tuple. */
- public T10 f10;
- /** Field 11 of the tuple. */
- public T11 f11;
- /** Field 12 of the tuple. */
- public T12 f12;
- /** Field 13 of the tuple. */
- public T13 f13;
- /** Field 14 of the tuple. */
- public T14 f14;
- /** Field 15 of the tuple. */
- public T15 f15;
- /** Field 16 of the tuple. */
- public T16 f16;
- /** Field 17 of the tuple. */
- public T17 f17;
- /** Field 18 of the tuple. */
- public T18 f18;
- /** Field 19 of the tuple. */
- public T19 f19;
- /** Field 20 of the tuple. */
- public T20 f20;
- /** Field 21 of the tuple. */
- public T21 f21;
- /** Field 22 of the tuple. */
- public T22 f22;
- /** Field 23 of the tuple. */
- public T23 f23;
- /** Field 24 of the tuple. */
- public T24 f24;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple25() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- * @param value22 The value for field 22
- * @param value23 The value for field 23
- * @param value24 The value for field 24
- */
- public Tuple25(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- this.f22 = value22;
- this.f23 = value23;
- this.f24 = value24;
- }
-
- @Override
- public int getArity() { return 25; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- case 4: return (T) this.f4;
- case 5: return (T) this.f5;
- case 6: return (T) this.f6;
- case 7: return (T) this.f7;
- case 8: return (T) this.f8;
- case 9: return (T) this.f9;
- case 10: return (T) this.f10;
- case 11: return (T) this.f11;
- case 12: return (T) this.f12;
- case 13: return (T) this.f13;
- case 14: return (T) this.f14;
- case 15: return (T) this.f15;
- case 16: return (T) this.f16;
- case 17: return (T) this.f17;
- case 18: return (T) this.f18;
- case 19: return (T) this.f19;
- case 20: return (T) this.f20;
- case 21: return (T) this.f21;
- case 22: return (T) this.f22;
- case 23: return (T) this.f23;
- case 24: return (T) this.f24;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- case 4:
- this.f4 = (T4) value;
- break;
- case 5:
- this.f5 = (T5) value;
- break;
- case 6:
- this.f6 = (T6) value;
- break;
- case 7:
- this.f7 = (T7) value;
- break;
- case 8:
- this.f8 = (T8) value;
- break;
- case 9:
- this.f9 = (T9) value;
- break;
- case 10:
- this.f10 = (T10) value;
- break;
- case 11:
- this.f11 = (T11) value;
- break;
- case 12:
- this.f12 = (T12) value;
- break;
- case 13:
- this.f13 = (T13) value;
- break;
- case 14:
- this.f14 = (T14) value;
- break;
- case 15:
- this.f15 = (T15) value;
- break;
- case 16:
- this.f16 = (T16) value;
- break;
- case 17:
- this.f17 = (T17) value;
- break;
- case 18:
- this.f18 = (T18) value;
- break;
- case 19:
- this.f19 = (T19) value;
- break;
- case 20:
- this.f20 = (T20) value;
- break;
- case 21:
- this.f21 = (T21) value;
- break;
- case 22:
- this.f22 = (T22) value;
- break;
- case 23:
- this.f23 = (T23) value;
- break;
- case 24:
- this.f24 = (T24) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- * @param value4 The value for field 4
- * @param value5 The value for field 5
- * @param value6 The value for field 6
- * @param value7 The value for field 7
- * @param value8 The value for field 8
- * @param value9 The value for field 9
- * @param value10 The value for field 10
- * @param value11 The value for field 11
- * @param value12 The value for field 12
- * @param value13 The value for field 13
- * @param value14 The value for field 14
- * @param value15 The value for field 15
- * @param value16 The value for field 16
- * @param value17 The value for field 17
- * @param value18 The value for field 18
- * @param value19 The value for field 19
- * @param value20 The value for field 20
- * @param value21 The value for field 21
- * @param value22 The value for field 22
- * @param value23 The value for field 23
- * @param value24 The value for field 24
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- this.f4 = value4;
- this.f5 = value5;
- this.f6 = value6;
- this.f7 = value7;
- this.f8 = value8;
- this.f9 = value9;
- this.f10 = value10;
- this.f11 = value11;
- this.f12 = value12;
- this.f13 = value13;
- this.f14 = value14;
- this.f15 = value15;
- this.f16 = value16;
- this.f17 = value17;
- this.f18 = value18;
- this.f19 = value19;
- this.f20 = value20;
- this.f21 = value21;
- this.f22 = value22;
- this.f23 = value23;
- this.f24 = value24;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22, f23, f24),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + "," + StringUtils.arrayAwareToString(this.f4)
- + "," + StringUtils.arrayAwareToString(this.f5)
- + "," + StringUtils.arrayAwareToString(this.f6)
- + "," + StringUtils.arrayAwareToString(this.f7)
- + "," + StringUtils.arrayAwareToString(this.f8)
- + "," + StringUtils.arrayAwareToString(this.f9)
- + "," + StringUtils.arrayAwareToString(this.f10)
- + "," + StringUtils.arrayAwareToString(this.f11)
- + "," + StringUtils.arrayAwareToString(this.f12)
- + "," + StringUtils.arrayAwareToString(this.f13)
- + "," + StringUtils.arrayAwareToString(this.f14)
- + "," + StringUtils.arrayAwareToString(this.f15)
- + "," + StringUtils.arrayAwareToString(this.f16)
- + "," + StringUtils.arrayAwareToString(this.f17)
- + "," + StringUtils.arrayAwareToString(this.f18)
- + "," + StringUtils.arrayAwareToString(this.f19)
- + "," + StringUtils.arrayAwareToString(this.f20)
- + "," + StringUtils.arrayAwareToString(this.f21)
- + "," + StringUtils.arrayAwareToString(this.f22)
- + "," + StringUtils.arrayAwareToString(this.f23)
- + "," + StringUtils.arrayAwareToString(this.f24)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple25)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple25 tuple = (Tuple25) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
- if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
- if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
- if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
- if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
- if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
- if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
- if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
- if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
- if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
- if (f14 != null ? !f14.equals(tuple.f14) : tuple.f14 != null) { return false; }
- if (f15 != null ? !f15.equals(tuple.f15) : tuple.f15 != null) { return false; }
- if (f16 != null ? !f16.equals(tuple.f16) : tuple.f16 != null) { return false; }
- if (f17 != null ? !f17.equals(tuple.f17) : tuple.f17 != null) { return false; }
- if (f18 != null ? !f18.equals(tuple.f18) : tuple.f18 != null) { return false; }
- if (f19 != null ? !f19.equals(tuple.f19) : tuple.f19 != null) { return false; }
- if (f20 != null ? !f20.equals(tuple.f20) : tuple.f20 != null) { return false; }
- if (f21 != null ? !f21.equals(tuple.f21) : tuple.f21 != null) { return false; }
- if (f22 != null ? !f22.equals(tuple.f22) : tuple.f22 != null) { return false; }
- if (f23 != null ? !f23.equals(tuple.f23) : tuple.f23 != null) { return false; }
- if (f24 != null ? !f24.equals(tuple.f24) : tuple.f24 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- result = 31 * result + (f4 != null ? f4.hashCode() : 0);
- result = 31 * result + (f5 != null ? f5.hashCode() : 0);
- result = 31 * result + (f6 != null ? f6.hashCode() : 0);
- result = 31 * result + (f7 != null ? f7.hashCode() : 0);
- result = 31 * result + (f8 != null ? f8.hashCode() : 0);
- result = 31 * result + (f9 != null ? f9.hashCode() : 0);
- result = 31 * result + (f10 != null ? f10.hashCode() : 0);
- result = 31 * result + (f11 != null ? f11.hashCode() : 0);
- result = 31 * result + (f12 != null ? f12.hashCode() : 0);
- result = 31 * result + (f13 != null ? f13.hashCode() : 0);
- result = 31 * result + (f14 != null ? f14.hashCode() : 0);
- result = 31 * result + (f15 != null ? f15.hashCode() : 0);
- result = 31 * result + (f16 != null ? f16.hashCode() : 0);
- result = 31 * result + (f17 != null ? f17.hashCode() : 0);
- result = 31 * result + (f18 != null ? f18.hashCode() : 0);
- result = 31 * result + (f19 != null ? f19.hashCode() : 0);
- result = 31 * result + (f20 != null ? f20.hashCode() : 0);
- result = 31 * result + (f21 != null ? f21.hashCode() : 0);
- result = 31 * result + (f22 != null ? f22.hashCode() : 0);
- result = 31 * result + (f23 != null ? f23.hashCode() : 0);
- result = 31 * result + (f24 != null ? f24.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> copy(){
- return new Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24>(this.f0,
- this.f1,
- this.f2,
- this.f3,
- this.f4,
- this.f5,
- this.f6,
- this.f7,
- this.f8,
- this.f9,
- this.f10,
- this.f11,
- this.f12,
- this.f13,
- this.f14,
- this.f15,
- this.f16,
- this.f17,
- this.f18,
- this.f19,
- this.f20,
- this.f21,
- this.f22,
- this.f23,
- this.f24);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24) {
- return new Tuple25<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23, value24);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java
deleted file mode 100644
index 3a46222..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple3.java
+++ /dev/null
@@ -1,184 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 3 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- */
-public class Tuple3<T0, T1, T2> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple3() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- */
- public Tuple3(T0 value0, T1 value1, T2 value2) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- }
-
- @Override
- public int getArity() { return 3; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- */
- public void setFields(T0 value0, T1 value1, T2 value2) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple3)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple3 tuple = (Tuple3) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple3<T0,T1,T2> copy(){
- return new Tuple3<T0,T1,T2>(this.f0,
- this.f1,
- this.f2);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2> Tuple3<T0,T1,T2> of(T0 value0, T1 value1, T2 value2) {
- return new Tuple3<T0,T1,T2>(value0, value1, value2);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java
deleted file mode 100644
index 0556ad4..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/Tuple4.java
+++ /dev/null
@@ -1,199 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple;
-
-import org.apache.flink.util.StringUtils;
-
-/**
- * A tuple with 4 fields. Tuples are strongly typed; each field may be of a separate type.
- * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
- * through the {@link #getField(int)} method. The tuple field positions start at zero.
- * <p>
- * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
- * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
- *
- * @see Tuple
- *
- * @param <T0> The type of field 0
- * @param <T1> The type of field 1
- * @param <T2> The type of field 2
- * @param <T3> The type of field 3
- */
-public class Tuple4<T0, T1, T2, T3> extends Tuple {
-
- private static final long serialVersionUID = 1L;
-
- /** Field 0 of the tuple. */
- public T0 f0;
- /** Field 1 of the tuple. */
- public T1 f1;
- /** Field 2 of the tuple. */
- public T2 f2;
- /** Field 3 of the tuple. */
- public T3 f3;
-
- /**
- * Creates a new tuple where all fields are null.
- */
- public Tuple4() {}
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- */
- public Tuple4(T0 value0, T1 value1, T2 value2, T3 value3) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- }
-
- @Override
- public int getArity() { return 4; }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getField(int pos) {
- switch(pos) {
- case 0: return (T) this.f0;
- case 1: return (T) this.f1;
- case 2: return (T) this.f2;
- case 3: return (T) this.f3;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> void setField(T value, int pos) {
- switch(pos) {
- case 0:
- this.f0 = (T0) value;
- break;
- case 1:
- this.f1 = (T1) value;
- break;
- case 2:
- this.f2 = (T2) value;
- break;
- case 3:
- this.f3 = (T3) value;
- break;
- default: throw new IndexOutOfBoundsException(String.valueOf(pos));
- }
- }
-
- /**
- * Sets new values to all fields of the tuple.
- *
- * @param value0 The value for field 0
- * @param value1 The value for field 1
- * @param value2 The value for field 2
- * @param value3 The value for field 3
- */
- public void setFields(T0 value0, T1 value1, T2 value2, T3 value3) {
- this.f0 = value0;
- this.f1 = value1;
- this.f2 = value2;
- this.f3 = value3;
- }
-
-
- // -------------------------------------------------------------------------------------------------
- // standard utilities
- // -------------------------------------------------------------------------------------------------
-
- /**
- * Creates a string representation of the tuple in the form
- * (f0, f1, f2, f3),
- * where the individual fields are the value returned by calling {@link Object#toString} on that field.
- * @return The string representation of the tuple.
- */
- @Override
- public String toString() {
- return "(" + StringUtils.arrayAwareToString(this.f0)
- + "," + StringUtils.arrayAwareToString(this.f1)
- + "," + StringUtils.arrayAwareToString(this.f2)
- + "," + StringUtils.arrayAwareToString(this.f3)
- + ")";
- }
-
- /**
- * Deep equality for tuples by calling equals() on the tuple members
- * @param o the object checked for equality
- * @return true if this is equal to o.
- */
- @Override
- public boolean equals(Object o) {
- if(this == o) { return true; }
- if (!(o instanceof Tuple4)) { return false; }
- @SuppressWarnings("rawtypes")
- Tuple4 tuple = (Tuple4) o;
- if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
- if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
- if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
- if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = f0 != null ? f0.hashCode() : 0;
- result = 31 * result + (f1 != null ? f1.hashCode() : 0);
- result = 31 * result + (f2 != null ? f2.hashCode() : 0);
- result = 31 * result + (f3 != null ? f3.hashCode() : 0);
- return result;
- }
-
- /**
- * Shallow tuple copy.
- * @return A new Tuple with the same fields as this.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Tuple4<T0,T1,T2,T3> copy(){
- return new Tuple4<T0,T1,T2,T3>(this.f0,
- this.f1,
- this.f2,
- this.f3);
- }
-
- /**
- * Creates a new tuple and assigns the given values to the tuple's fields.
- * This is more convenient than using the constructor, because the compiler can
- * infer the generic type arguments implicitly. For example:
- * {@code Tuple3.of(n, x, s)}
- * instead of
- * {@code new Tuple3<Integer, Double, String>(n, x, s)}
- */
- public static <T0,T1,T2,T3> Tuple4<T0,T1,T2,T3> of(T0 value0, T1 value1, T2 value2, T3 value3) {
- return new Tuple4<T0,T1,T2,T3>(value0, value1, value2, value3);
- }
-}
[03/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java
deleted file mode 100644
index 8cdee9b..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD1Test.java
+++ /dev/null
@@ -1,69 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorISD1Test extends TupleComparatorTestBase<Tuple3<Integer, String, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, String, Double>(4, "hello", 20.0),
- new Tuple3<Integer, String, Double>(5, "hello", 23.2),
- new Tuple3<Integer, String, Double>(6, "world", 20.0),
- new Tuple3<Integer, String, Double>(7, "hello", 20.0),
- new Tuple3<Integer, String, Double>(8, "hello", 23.2),
- new Tuple3<Integer, String, Double>(9, "world", 20.0),
- new Tuple3<Integer, String, Double>(10, "hello", 20.0),
- new Tuple3<Integer, String, Double>(11, "hello", 23.2)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, String, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, String, Double>>(
- new int[]{0},
- new TypeComparator[]{ new IntComparator(ascending) },
- new TypeSerializer[]{ IntSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, String, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, String, Double>>(
- (Class<Tuple3<Integer, String, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new StringSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, String, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java
deleted file mode 100644
index 06c292f..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD2Test.java
+++ /dev/null
@@ -1,73 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.StringComparator;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorISD2Test extends TupleComparatorTestBase<Tuple3<Integer, String, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, String, Double>(4, "hello", 20.0),
- new Tuple3<Integer, String, Double>(4, "world", 23.2),
- new Tuple3<Integer, String, Double>(5, "hello", 20.0),
- new Tuple3<Integer, String, Double>(5, "world", 20.0),
- new Tuple3<Integer, String, Double>(6, "hello", 23.2),
- new Tuple3<Integer, String, Double>(6, "world", 20.0),
- new Tuple3<Integer, String, Double>(7, "hello", 20.0),
- new Tuple3<Integer, String, Double>(7, "world", 23.2)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, String, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, String, Double>>(
- new int[]{0, 1},
- new TypeComparator[]{
- new IntComparator(ascending),
- new StringComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, StringSerializer.INSTANCE, DoubleSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, String, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, String, Double>>(
- (Class<Tuple3<Integer, String, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new StringSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, String, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java
deleted file mode 100644
index d823a29..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorISD3Test.java
+++ /dev/null
@@ -1,75 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.StringComparator;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.tuple.Tuple3;
-
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorISD3Test extends TupleComparatorTestBase<Tuple3<Integer, String, Double>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Integer, String, Double>[] dataISD = new Tuple3[]{
- new Tuple3<Integer, String, Double>(4, "hello", 20.0),
- new Tuple3<Integer, String, Double>(4, "hello", 23.2),
- new Tuple3<Integer, String, Double>(4, "world", 20.0),
- new Tuple3<Integer, String, Double>(5, "hello", 20.0),
- new Tuple3<Integer, String, Double>(5, "hello", 23.2),
- new Tuple3<Integer, String, Double>(5, "world", 20.0),
- new Tuple3<Integer, String, Double>(6, "hello", 20.0),
- new Tuple3<Integer, String, Double>(6, "hello", 23.2)
- };
-
- @Override
- protected TupleComparator<Tuple3<Integer, String, Double>> createComparator(boolean ascending) {
- return new TupleComparator<Tuple3<Integer, String, Double>>(
- new int[]{0, 1, 2},
- new TypeComparator[]{
- new IntComparator(ascending),
- new StringComparator(ascending),
- new DoubleComparator(ascending)
- },
- new TypeSerializer[]{ IntSerializer.INSTANCE, StringSerializer.INSTANCE, DoubleSerializer.INSTANCE });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Integer, String, Double>> createSerializer() {
- return new TupleSerializer<Tuple3<Integer, String, Double>>(
- (Class<Tuple3<Integer, String, Double>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new IntSerializer(),
- new StringSerializer(),
- new DoubleSerializer()});
- }
-
- @Override
- protected Tuple3<Integer, String, Double>[] getSortedTestData() {
- return dataISD;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java
deleted file mode 100644
index cf73be2..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT1Test.java
+++ /dev/null
@@ -1,139 +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.java.typeutils.runtime;
-
-import static org.junit.Assert.assertEquals;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.common.typeutils.base.StringComparator;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorTTT1Test extends TupleComparatorTestBase<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] dataISD = new Tuple3[]{
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 1.0), new Tuple2<Long, Long>(1L, 1L), new Tuple2<Integer, Long>(4, -10L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 2.0), new Tuple2<Long, Long>(1L, 2L), new Tuple2<Integer, Long>(4, -5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.0), new Tuple2<Long, Long>(1L, 3L), new Tuple2<Integer, Long>(4, 0L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.5), new Tuple2<Long, Long>(1L, 4L), new Tuple2<Integer, Long>(4, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 4325.12), new Tuple2<Long, Long>(1L, 5L), new Tuple2<Integer, Long>(4, 15L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 1.0), new Tuple2<Long, Long>(2L, 4L), new Tuple2<Integer, Long>(45, -5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 2.0), new Tuple2<Long, Long>(2L, 6L), new Tuple2<Integer, Long>(45, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.0), new Tuple2<Long, Long>(2L, 8L), new Tuple2<Integer, Long>(323, 2L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.5), new Tuple2<Long, Long>(2L, 9L), new Tuple2<Integer, Long>(323, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 4325.12), new Tuple2<Long, Long>(2L, 123L), new Tuple2<Integer, Long>(555, 1L))
-
- };
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator(
- boolean ascending) {
- return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
- new int[] { 0 },
- new TypeComparator[] {
- new TupleComparator<Tuple2<String, Double>>(
- new int[] { 0, 1 },
- new TypeComparator[] {
- new StringComparator(ascending),
- new DoubleComparator(ascending) },
- new TypeSerializer[] {
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE }) },
- new TypeSerializer[] {
- new TupleSerializer<Tuple2<String, Double>>(
- (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE }),
- new TupleSerializer<Tuple2<Long, Long>>(
- (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE }),
- new TupleSerializer<Tuple2<Integer, Long>>(
- (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE }) });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() {
- return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
- (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new TupleSerializer<Tuple2<String, Double>> (
- (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE
- }),
- new TupleSerializer<Tuple2<Long, Long>> (
- (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE
- }),
- new TupleSerializer<Tuple2<Integer, Long>> (
- (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE
- })
- });
- }
-
- @Override
- protected Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] getSortedTestData() {
- return this.dataISD;
- }
-
- @Override
- protected void deepEquals(
- String message,
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> should,
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> is) {
-
- for (int x = 0; x < should.getArity(); x++) {
- // Check whether field is of type Tuple2 because assertEquals must be called on the non Tuple2 fields.
- if(should.getField(x) instanceof Tuple2) {
- this.deepEquals(message, (Tuple2<?,?>) should.getField(x), (Tuple2<?,?>)is.getField(x));
- }
- else {
- assertEquals(message, should.getField(x), is.getField(x));
- }
- }// For
- }
-
- protected void deepEquals(String message, Tuple2<?,?> should, Tuple2<?,?> is) {
- for (int x = 0; x < should.getArity(); x++) {
- assertEquals(message, should.getField(x), is.getField(x));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java
deleted file mode 100644
index 4b07c61..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT2Test.java
+++ /dev/null
@@ -1,145 +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.java.typeutils.runtime;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.common.typeutils.base.StringComparator;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorTTT2Test extends TupleComparatorTestBase<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> {
-
- @SuppressWarnings("unchecked")
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] dataISD = new Tuple3[]{
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 1.0), new Tuple2<Long, Long>(1L, 1L), new Tuple2<Integer, Long>(4, -10L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 2.0), new Tuple2<Long, Long>(1L, 2L), new Tuple2<Integer, Long>(4, -5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.0), new Tuple2<Long, Long>(1L, 3L), new Tuple2<Integer, Long>(4, 0L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.5), new Tuple2<Long, Long>(1L, 4L), new Tuple2<Integer, Long>(4, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 4325.12), new Tuple2<Long, Long>(1L, 5L), new Tuple2<Integer, Long>(4, 15L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 1.0), new Tuple2<Long, Long>(2L, 4L), new Tuple2<Integer, Long>(45, -5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 2.0), new Tuple2<Long, Long>(2L, 6L), new Tuple2<Integer, Long>(45, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.0), new Tuple2<Long, Long>(2L, 8L), new Tuple2<Integer, Long>(323, 2L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.5), new Tuple2<Long, Long>(2L, 9L), new Tuple2<Integer, Long>(323, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 4325.12), new Tuple2<Long, Long>(2L, 123L), new Tuple2<Integer, Long>(555, 1L))
-
- };
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator(
- boolean ascending) {
- return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
- new int[] { 0, 2 },
- new TypeComparator[] {
- new TupleComparator<Tuple2<String, Double>>(
- new int[] { 0, 1 },
- new TypeComparator[] {
- new StringComparator(ascending),
- new DoubleComparator(ascending) },
- new TypeSerializer[] {
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE }),
- new TupleComparator<Tuple2<Integer, Long>>(
- new int[] { 0, 1 },
- new TypeComparator[] {
- new IntComparator(ascending),
- new LongComparator(ascending) },
- new TypeSerializer[] {
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE }) },
- new TypeSerializer[] {
- new TupleSerializer<Tuple2<String, Double>>(
- (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE }),
- new TupleSerializer<Tuple2<Long, Long>>(
- (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE }),
- new TupleSerializer<Tuple2<Integer, Long>>(
- (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE }) });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() {
- return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
- (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new TupleSerializer<Tuple2<String, Double>> (
- (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE}),
- new TupleSerializer<Tuple2<Long, Long>> (
- (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE}),
- new TupleSerializer<Tuple2<Integer, Long>> (
- (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE})
- });
- }
-
- @Override
- protected Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] getSortedTestData() {
- return this.dataISD;
- }
-
- @Override
- protected void deepEquals(
- String message,
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> should,
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> is) {
-
- for (int x = 0; x < should.getArity(); x++) {
- // Check whether field is of type Tuple2 because assertEquals must be called on the non Tuple2 fields.
- if(should.getField(x) instanceof Tuple2) {
- this.deepEquals(message, (Tuple2<?,?>) should.getField(x), (Tuple2<?,?>)is.getField(x));
- }
- else {
- assertEquals(message, should.getField(x), is.getField(x));
- }
- }// For
- }
-
- protected void deepEquals(String message, Tuple2<?,?> should, Tuple2<?,?> is) {
- for (int x = 0; x < should.getArity(); x++) {
- assertEquals(message, should.getField(x), is.getField(x));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java
deleted file mode 100644
index 0dfc094..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorTTT3Test.java
+++ /dev/null
@@ -1,154 +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.java.typeutils.runtime;
-
-import static org.junit.Assert.assertEquals;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.common.typeutils.base.DoubleComparator;
-import org.apache.flink.api.common.typeutils.base.DoubleSerializer;
-import org.apache.flink.api.common.typeutils.base.IntComparator;
-import org.apache.flink.api.common.typeutils.base.IntSerializer;
-import org.apache.flink.api.common.typeutils.base.LongComparator;
-import org.apache.flink.api.common.typeutils.base.LongSerializer;
-import org.apache.flink.api.common.typeutils.base.StringComparator;
-import org.apache.flink.api.common.typeutils.base.StringSerializer;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.runtime.tuple.base.TupleComparatorTestBase;
-
-public class TupleComparatorTTT3Test extends TupleComparatorTestBase<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>{
- @SuppressWarnings("unchecked")
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] dataISD = new Tuple3[]{
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 1.0), new Tuple2<Long, Long>(1L, 1L), new Tuple2<Integer, Long>(4, -10L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 2.0), new Tuple2<Long, Long>(1L, 2L), new Tuple2<Integer, Long>(4, -5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.0), new Tuple2<Long, Long>(1L, 3L), new Tuple2<Integer, Long>(4, 0L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 3.5), new Tuple2<Long, Long>(1L, 4L), new Tuple2<Integer, Long>(4, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("hello", 4325.12), new Tuple2<Long, Long>(1L, 5L), new Tuple2<Integer, Long>(4, 15L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 1.0), new Tuple2<Long, Long>(2L, 4L), new Tuple2<Integer, Long>(45, -5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 2.0), new Tuple2<Long, Long>(2L, 6L), new Tuple2<Integer, Long>(45, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.0), new Tuple2<Long, Long>(2L, 8L), new Tuple2<Integer, Long>(323, 2L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 3.5), new Tuple2<Long, Long>(2L, 9L), new Tuple2<Integer, Long>(323, 5L)),
- new Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>(new Tuple2<String, Double>("world", 4325.12), new Tuple2<Long, Long>(2L, 123L), new Tuple2<Integer, Long>(555, 1L))
-
- };
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator(
- boolean ascending) {
- return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
- new int[] { 0, 1, 2 },
- new TypeComparator[] {
- new TupleComparator<Tuple2<String, Double>>(
- new int[] { 0, 1 },
- new TypeComparator[] {
- new StringComparator(ascending),
- new DoubleComparator(ascending) },
- new TypeSerializer[] {
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE }),
- new TupleComparator<Tuple2<Long, Long>>(
- new int[] { 0, 1 },
- new TypeComparator[] {
- new LongComparator(ascending),
- new LongComparator(ascending) },
- new TypeSerializer[] {
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE }),
- new TupleComparator<Tuple2<Integer, Long>>(
- new int[] { 0, 1 },
- new TypeComparator[] {
- new IntComparator(ascending),
- new LongComparator(ascending) },
- new TypeSerializer[] {
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE }) },
- new TypeSerializer[] {
- new TupleSerializer<Tuple2<String, Double>>(
- (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE }),
- new TupleSerializer<Tuple2<Long, Long>>(
- (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE }),
- new TupleSerializer<Tuple2<Integer, Long>>(
- (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[] {
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE }) });
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() {
- return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>(
- (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class,
- new TypeSerializer[]{
- new TupleSerializer<Tuple2<String, Double>> (
- (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- StringSerializer.INSTANCE,
- DoubleSerializer.INSTANCE
- }),
- new TupleSerializer<Tuple2<Long, Long>> (
- (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- LongSerializer.INSTANCE,
- LongSerializer.INSTANCE
- }),
- new TupleSerializer<Tuple2<Integer, Long>> (
- (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class,
- new TypeSerializer[]{
- IntSerializer.INSTANCE,
- LongSerializer.INSTANCE
- })
- });
- }
-
- @Override
- protected Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>[] getSortedTestData() {
- return this.dataISD;
- }
-
- @Override
- protected void deepEquals(
- String message,
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> should,
- Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>> is) {
-
- for (int x = 0; x < should.getArity(); x++) {
- // Check whether field is of type Tuple2 because assertEquals must be called on the non Tuple2 fields.
- if(should.getField(x) instanceof Tuple2) {
- this.deepEquals(message, (Tuple2<?,?>) should.getField(x), (Tuple2<?,?>)is.getField(x));
- }
- else {
- assertEquals(message, should.getField(x), is.getField(x));
- }
- }// For
- }
-
- protected void deepEquals(String message, Tuple2<?,?> should, Tuple2<?,?> is) {
- for (int x = 0; x < should.getArity(); x++) {
- assertEquals(message, should.getField(x), is.getField(x));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java
deleted file mode 100644
index 017eb44..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTest.java
+++ /dev/null
@@ -1,238 +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.java.typeutils.runtime;
-
-import java.util.ArrayList;
-import java.util.Random;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.api.java.tuple.Tuple0;
-import org.apache.flink.api.java.tuple.Tuple1;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple5;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.Book;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.BookAuthor;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject1;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.ComplexNestedObject2;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest.SimpleTypes;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.util.StringUtils;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TupleSerializerTest {
-
- @Test
- public void testTuple0() {
- Tuple0[] testTuples = new Tuple0[] { Tuple0.INSTANCE, Tuple0.INSTANCE, Tuple0.INSTANCE };
-
- runTests(testTuples);
- }
-
- @Test
- public void testTuple1Int() {
- @SuppressWarnings({"unchecked", "rawtypes"})
- Tuple1<Integer>[] testTuples = new Tuple1[] {
- new Tuple1<Integer>(42), new Tuple1<Integer>(1), new Tuple1<Integer>(0), new Tuple1<Integer>(-1),
- new Tuple1<Integer>(Integer.MAX_VALUE), new Tuple1<Integer>(Integer.MIN_VALUE)
- };
-
- runTests(testTuples);
- }
-
- @Test
- public void testTuple1String() {
- Random rnd = new Random(68761564135413L);
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- Tuple1<String>[] testTuples = new Tuple1[] {
- new Tuple1<String>(StringUtils.getRandomString(rnd, 10, 100)),
- new Tuple1<String>("abc"),
- new Tuple1<String>(""),
- new Tuple1<String>(StringUtils.getRandomString(rnd, 30, 170)),
- new Tuple1<String>(StringUtils.getRandomString(rnd, 15, 50)),
- new Tuple1<String>("")
- };
-
- runTests(testTuples);
- }
-
- @Test
- public void testTuple1StringArray() {
- Random rnd = new Random(289347567856686223L);
-
- String[] arr1 = new String[] {"abc", "",
- StringUtils.getRandomString(rnd, 10, 100),
- StringUtils.getRandomString(rnd, 15, 50),
- StringUtils.getRandomString(rnd, 30, 170),
- StringUtils.getRandomString(rnd, 14, 15),
- ""};
-
- String[] arr2 = new String[] {"foo", "",
- StringUtils.getRandomString(rnd, 10, 100),
- StringUtils.getRandomString(rnd, 1000, 5000),
- StringUtils.getRandomString(rnd, 30000, 35000),
- StringUtils.getRandomString(rnd, 100*1024, 105*1024),
- "bar"};
-
- @SuppressWarnings("unchecked")
- Tuple1<String[]>[] testTuples = new Tuple1[] {
- new Tuple1<String[]>(arr1),
- new Tuple1<String[]>(arr2)
- };
-
- runTests(testTuples);
- }
-
- @Test
- public void testTuple2StringDouble() {
- Random rnd = new Random(807346528946L);
-
- @SuppressWarnings("unchecked")
- Tuple2<String, Double>[] testTuples = new Tuple2[] {
- new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
- new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
- new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
- new Tuple2<String, Double>("", rnd.nextDouble()),
- new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble()),
- new Tuple2<String, Double>(StringUtils.getRandomString(rnd, 10, 100), rnd.nextDouble())
- };
-
- runTests(testTuples);
- }
-
- @Test
- public void testTuple2StringStringArray() {
- Random rnd = new Random(289347567856686223L);
-
- String[] arr1 = new String[] {"abc", "",
- StringUtils.getRandomString(rnd, 10, 100),
- StringUtils.getRandomString(rnd, 15, 50),
- StringUtils.getRandomString(rnd, 30, 170),
- StringUtils.getRandomString(rnd, 14, 15),
- ""};
-
- String[] arr2 = new String[] {"foo", "",
- StringUtils.getRandomString(rnd, 10, 100),
- StringUtils.getRandomString(rnd, 1000, 5000),
- StringUtils.getRandomString(rnd, 30000, 35000),
- StringUtils.getRandomString(rnd, 100*1024, 105*1024),
- "bar"};
-
- @SuppressWarnings("unchecked")
- Tuple2<String, String[]>[] testTuples = new Tuple2[] {
- new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr1),
- new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2),
- new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr1),
- new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2),
- new Tuple2<String, String[]>(StringUtils.getRandomString(rnd, 30, 170), arr2)
- };
-
- runTests(testTuples);
- }
-
-
- @Test
- public void testTuple5CustomObjects() {
- Random rnd = new Random(807346528946L);
-
- SimpleTypes a = new SimpleTypes();
- SimpleTypes b = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes c = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes d = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes e = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes f = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
- SimpleTypes g = new SimpleTypes(rnd.nextInt(), rnd.nextLong(), (byte) rnd.nextInt(),
- StringUtils.getRandomString(rnd, 10, 100), (short) rnd.nextInt(), rnd.nextDouble());
-
- ComplexNestedObject1 o1 = new ComplexNestedObject1(5626435);
- ComplexNestedObject1 o2 = new ComplexNestedObject1(76923);
- ComplexNestedObject1 o3 = new ComplexNestedObject1(-1100);
- ComplexNestedObject1 o4 = new ComplexNestedObject1(0);
- ComplexNestedObject1 o5 = new ComplexNestedObject1(44);
-
- ComplexNestedObject2 co1 = new ComplexNestedObject2(rnd);
- ComplexNestedObject2 co2 = new ComplexNestedObject2();
- ComplexNestedObject2 co3 = new ComplexNestedObject2(rnd);
- ComplexNestedObject2 co4 = new ComplexNestedObject2(rnd);
-
- Book b1 = new Book(976243875L, "The Serialization Odysse", 42);
- Book b2 = new Book(0L, "Debugging byte streams", 1337);
- Book b3 = new Book(-1L, "Low level interfaces", 0xC0FFEE);
- Book b4 = new Book(Long.MAX_VALUE, "The joy of bits and bytes", 0xDEADBEEF);
- Book b5 = new Book(Long.MIN_VALUE, "Winnign a prize for creative test strings", 0xBADF00);
- Book b6 = new Book(-2L, "Distributed Systems", 0xABCDEF0123456789L);
-
- ArrayList<String> list = new ArrayList<String>();
- list.add("A");
- list.add("B");
- list.add("C");
- list.add("D");
- list.add("E");
-
- BookAuthor ba1 = new BookAuthor(976243875L, list, "Arno Nym");
-
- ArrayList<String> list2 = new ArrayList<String>();
- BookAuthor ba2 = new BookAuthor(987654321L, list2, "The Saurus");
-
-
- @SuppressWarnings("unchecked")
- Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>[] testTuples = new Tuple5[] {
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(a, b1, o1, ba1, co1),
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(b, b2, o2, ba2, co2),
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(c, b3, o3, ba1, co3),
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(d, b2, o4, ba1, co4),
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(e, b4, o5, ba2, co4),
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(f, b5, o1, ba2, co4),
- new Tuple5<SimpleTypes, Book, ComplexNestedObject1, BookAuthor, ComplexNestedObject2>(g, b6, o4, ba1, co2)
- };
-
- runTests(testTuples);
- }
-
- private <T extends Tuple> void runTests(T... instances) {
- try {
- TupleTypeInfo<T> tupleTypeInfo = (TupleTypeInfo<T>) TypeExtractor.getForObject(instances[0]);
- TypeSerializer<T> serializer = tupleTypeInfo.createSerializer(new ExecutionConfig());
-
- Class<T> tupleClass = tupleTypeInfo.getTypeClass();
-
- int length = -1;
- if(tupleClass == Tuple0.class) {
- length = 1;
- }
- TupleSerializerTestInstance<T> test = new TupleSerializerTestInstance<T>(serializer, tupleClass, length, instances);
- test.testAll();
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java
deleted file mode 100644
index a196984..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerTestInstance.java
+++ /dev/null
@@ -1,79 +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.java.typeutils.runtime;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.junit.Assert;
-
-public class TupleSerializerTestInstance<T extends Tuple> extends SerializerTestInstance<T> {
-
- public TupleSerializerTestInstance(TypeSerializer<T> serializer, Class<T> typeClass, int length, T[] testData) {
- super(serializer, typeClass, length, testData);
- }
-
- protected void deepEquals(String message, T shouldTuple, T isTuple) {
- Assert.assertEquals(shouldTuple.getArity(), isTuple.getArity());
-
- for (int i = 0; i < shouldTuple.getArity(); i++) {
- Object should = shouldTuple.getField(i);
- Object is = isTuple.getField(i);
-
- if (should.getClass().isArray()) {
- if (should instanceof boolean[]) {
- Assert.assertTrue(message, Arrays.equals((boolean[]) should, (boolean[]) is));
- }
- else if (should instanceof byte[]) {
- assertArrayEquals(message, (byte[]) should, (byte[]) is);
- }
- else if (should instanceof short[]) {
- assertArrayEquals(message, (short[]) should, (short[]) is);
- }
- else if (should instanceof int[]) {
- assertArrayEquals(message, (int[]) should, (int[]) is);
- }
- else if (should instanceof long[]) {
- assertArrayEquals(message, (long[]) should, (long[]) is);
- }
- else if (should instanceof float[]) {
- assertArrayEquals(message, (float[]) should, (float[]) is, 0.0f);
- }
- else if (should instanceof double[]) {
- assertArrayEquals(message, (double[]) should, (double[]) is, 0.0);
- }
- else if (should instanceof char[]) {
- assertArrayEquals(message, (char[]) should, (char[]) is);
- }
- else {
- assertArrayEquals(message, (Object[]) should, (Object[]) is);
- }
- }
- else {
- assertEquals(message, should, is);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java
deleted file mode 100644
index cf9874d..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorTest.java
+++ /dev/null
@@ -1,53 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.types.StringValue;
-
-public class ValueComparatorTest extends ComparatorTestBase<StringValue> {
-
- StringValue[] data = new StringValue[]{
- new StringValue(""),
- new StringValue("Lorem Ipsum Dolor Omit Longer"),
- new StringValue("aaaa"),
- new StringValue("abcd"),
- new StringValue("abce"),
- new StringValue("abdd"),
- new StringValue("accd"),
- new StringValue("bbcd")
- };
-
- @Override
- protected TypeComparator<StringValue> createComparator(boolean ascending) {
- return new ValueComparator<StringValue>(ascending, StringValue.class);
- }
-
- @Override
- protected TypeSerializer<StringValue> createSerializer() {
- return new ValueSerializer<StringValue>(StringValue.class);
- }
-
- @Override
- protected StringValue[] getSortedTestData() {
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java
deleted file mode 100644
index a2c3e1e..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueComparatorUUIDTest.java
+++ /dev/null
@@ -1,46 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-import java.util.UUID;
-
-public class ValueComparatorUUIDTest extends ComparatorTestBase<ValueID> {
- @Override
- protected TypeComparator<ValueID> createComparator(boolean ascending) {
- return new ValueComparator<>(ascending, ValueID.class);
- }
-
- @Override
- protected TypeSerializer<ValueID> createSerializer() {
- return new ValueSerializer<>(ValueID.class);
- }
-
- @Override
- protected ValueID[] getSortedTestData() {
- return new ValueID[] {
- new ValueID(new UUID(0, 0)),
- new ValueID(new UUID(1, 0)),
- new ValueID(new UUID(1, 1))
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java
deleted file mode 100644
index d644485..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueID.java
+++ /dev/null
@@ -1,72 +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.java.typeutils.runtime;
-
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.types.Value;
-
-import java.io.IOException;
-import java.util.UUID;
-
-public class ValueID implements Value, Comparable<ValueID> {
- private static final long serialVersionUID = -562791433077971752L;
-
- private UUID id;
-
- public ValueID() {
- id = UUID.randomUUID();
- }
-
- public ValueID(UUID id) {
- this.id = id;
- }
-
- @Override
- public int compareTo(ValueID o) {
- return id.compareTo(o.id);
- }
-
- @Override
- public void write(DataOutputView out) throws IOException {
- out.writeLong(id.getMostSignificantBits());
- out.writeLong(id.getLeastSignificantBits());
- }
-
- @Override
- public void read(DataInputView in) throws IOException {
- id = new UUID(in.readLong(), in.readLong());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ValueID) {
- ValueID other = (ValueID) obj;
-
- return id.equals(other.id);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java
deleted file mode 100644
index 9c07a5e..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUUIDTest.java
+++ /dev/null
@@ -1,50 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.SerializerTestBase;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-import java.util.UUID;
-
-public class ValueSerializerUUIDTest extends SerializerTestBase<ValueID> {
- @Override
- protected TypeSerializer<ValueID> createSerializer() {
- return new ValueSerializer<>(ValueID.class);
- }
-
- @Override
- protected int getLength() {
- return -1;
- }
-
- @Override
- protected Class<ValueID> getTypeClass() {
- return ValueID.class;
- }
-
- @Override
- protected ValueID[] getTestData() {
- return new ValueID[] {
- new ValueID(new UUID(0, 0)),
- new ValueID(new UUID(1, 0)),
- new ValueID(new UUID(1, 1))
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java
deleted file mode 100644
index f5a90b7..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorTest.java
+++ /dev/null
@@ -1,53 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-public class WritableComparatorTest extends ComparatorTestBase<StringArrayWritable> {
-
- StringArrayWritable[] data = new StringArrayWritable[]{
- new StringArrayWritable(new String[]{}),
- new StringArrayWritable(new String[]{""}),
- new StringArrayWritable(new String[]{"a","a"}),
- new StringArrayWritable(new String[]{"a","b"}),
- new StringArrayWritable(new String[]{"c","c"}),
- new StringArrayWritable(new String[]{"d","f"}),
- new StringArrayWritable(new String[]{"d","m"}),
- new StringArrayWritable(new String[]{"z","x"}),
- new StringArrayWritable(new String[]{"a","a", "a"})
- };
-
- @Override
- protected TypeComparator<StringArrayWritable> createComparator(boolean ascending) {
- return new WritableComparator<StringArrayWritable>(ascending, StringArrayWritable.class);
- }
-
- @Override
- protected TypeSerializer<StringArrayWritable> createSerializer() {
- return new WritableSerializer<StringArrayWritable>(StringArrayWritable.class);
- }
-
- @Override
- protected StringArrayWritable[] getSortedTestData() {
- return data;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java
deleted file mode 100644
index 94e759d..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableComparatorUUIDTest.java
+++ /dev/null
@@ -1,46 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.ComparatorTestBase;
-import org.apache.flink.api.common.typeutils.TypeComparator;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-import java.util.UUID;
-
-public class WritableComparatorUUIDTest extends ComparatorTestBase<WritableID> {
- @Override
- protected TypeComparator<WritableID> createComparator(boolean ascending) {
- return new WritableComparator<>(ascending, WritableID.class);
- }
-
- @Override
- protected TypeSerializer<WritableID> createSerializer() {
- return new WritableSerializer<>(WritableID.class);
- }
-
- @Override
- protected WritableID[] getSortedTestData() {
- return new WritableID[] {
- new WritableID(new UUID(0, 0)),
- new WritableID(new UUID(1, 0)),
- new WritableID(new UUID(1, 1))
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java
deleted file mode 100644
index 4274cf6..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableID.java
+++ /dev/null
@@ -1,78 +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.java.typeutils.runtime;
-
-import org.apache.hadoop.io.WritableComparable;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.UUID;
-
-public class WritableID implements WritableComparable<WritableID> {
- private UUID uuid;
-
- public WritableID() {
- this.uuid = UUID.randomUUID();
- }
-
- public WritableID(UUID uuid) {
- this.uuid = uuid;
- }
-
- @Override
- public int compareTo(WritableID o) {
- return this.uuid.compareTo(o.uuid);
- }
-
- @Override
- public void write(DataOutput dataOutput) throws IOException {
- dataOutput.writeLong(uuid.getMostSignificantBits());
- dataOutput.writeLong(uuid.getLeastSignificantBits());
- }
-
- @Override
- public void readFields(DataInput dataInput) throws IOException {
- this.uuid = new UUID(dataInput.readLong(), dataInput.readLong());
- }
-
- @Override
- public String toString() {
- return uuid.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- WritableID id = (WritableID) o;
-
- return !(uuid != null ? !uuid.equals(id.uuid) : id.uuid != null);
- }
-
- @Override
- public int hashCode() {
- return uuid != null ? uuid.hashCode() : 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java
deleted file mode 100644
index bb5f4d4..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerTest.java
+++ /dev/null
@@ -1,50 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeutils.SerializerTestInstance;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.typeutils.WritableTypeInfo;
-import org.junit.Test;
-
-public class WritableSerializerTest {
-
- @Test
- public void testStringArrayWritable() {
- StringArrayWritable[] data = new StringArrayWritable[]{
- new StringArrayWritable(new String[]{}),
- new StringArrayWritable(new String[]{""}),
- new StringArrayWritable(new String[]{"a","a"}),
- new StringArrayWritable(new String[]{"a","b"}),
- new StringArrayWritable(new String[]{"c","c"}),
- new StringArrayWritable(new String[]{"d","f"}),
- new StringArrayWritable(new String[]{"d","m"}),
- new StringArrayWritable(new String[]{"z","x"}),
- new StringArrayWritable(new String[]{"a","a", "a"})
- };
-
- WritableTypeInfo<StringArrayWritable> writableTypeInfo = (WritableTypeInfo<StringArrayWritable>) TypeExtractor.getForObject(data[0]);
- WritableSerializer<StringArrayWritable> writableSerializer = (WritableSerializer<StringArrayWritable>) writableTypeInfo.createSerializer(new ExecutionConfig());
-
- SerializerTestInstance<StringArrayWritable> testInstance = new SerializerTestInstance<StringArrayWritable>(writableSerializer,writableTypeInfo.getTypeClass(), -1, data);
-
- testInstance.testAll();
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java
deleted file mode 100644
index 2af7730..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/WritableSerializerUUIDTest.java
+++ /dev/null
@@ -1,50 +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.java.typeutils.runtime;
-
-import org.apache.flink.api.common.typeutils.SerializerTestBase;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-
-import java.util.UUID;
-
-public class WritableSerializerUUIDTest extends SerializerTestBase<WritableID> {
- @Override
- protected TypeSerializer<WritableID> createSerializer() {
- return new WritableSerializer<>(WritableID.class);
- }
-
- @Override
- protected int getLength() {
- return -1;
- }
-
- @Override
- protected Class<WritableID> getTypeClass() {
- return WritableID.class;
- }
-
- @Override
- protected WritableID[] getTestData() {
- return new WritableID[] {
- new WritableID(new UUID(0, 0)),
- new WritableID(new UUID(1, 0)),
- new WritableID(new UUID(1, 1))
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java
deleted file mode 100644
index 7572408..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoClearedBufferTest.java
+++ /dev/null
@@ -1,287 +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.java.typeutils.runtime.kryo;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.Serializer;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataInputViewStreamWrapper;
-import org.apache.flink.core.memory.DataOutputView;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Arrays;
-
-public class KryoClearedBufferTest {
-
- /**
- * Tests that the kryo output buffer is cleared in case of an exception. Flink uses the
- * EOFException to signal that a buffer is full. In such a case, the record which was tried
- * to be written will be rewritten. Therefore, eventually buffered data of this record has
- * to be cleared.
- */
- @Test
- public void testOutputBufferedBeingClearedInCaseOfException() throws Exception {
- ExecutionConfig executionConfig = new ExecutionConfig();
- executionConfig.registerTypeWithKryoSerializer(TestRecord.class, new TestRecordSerializer());
- executionConfig.registerKryoType(TestRecord.class);
-
- KryoSerializer<TestRecord> kryoSerializer = new KryoSerializer<TestRecord>(
- TestRecord.class,
- executionConfig);
-
- int size = 94;
- int bufferSize = 150;
-
- TestRecord testRecord = new TestRecord(size);
-
- TestDataOutputView target = new TestDataOutputView(bufferSize);
-
- kryoSerializer.serialize(testRecord, target);
-
- try {
- kryoSerializer.serialize(testRecord, target);
- Assert.fail("Expected an EOFException.");
- } catch(EOFException eofException) {
- // expected exception
- // now the Kryo Output should have been cleared
- }
-
- TestRecord actualRecord = kryoSerializer.deserialize(
- new DataInputViewStreamWrapper(new ByteArrayInputStream(target.getBuffer())));
-
- Assert.assertEquals(testRecord, actualRecord);
-
- target.clear();
-
- // if the kryo output has been cleared then we can serialize our test record into the target
- // because the target buffer 150 bytes can host one TestRecord (total serialization size 100)
- kryoSerializer.serialize(testRecord, target);
-
- byte[] buffer = target.getBuffer();
- int counter = 0;
-
- for (int i = 0; i < buffer.length; i++) {
- if(buffer[i] == 42) {
- counter++;
- }
- }
-
- Assert.assertEquals(size, counter);
- }
-
- public static class TestRecord {
- private byte[] buffer;
-
- public TestRecord(int size) {
- buffer = new byte[size];
-
- Arrays.fill(buffer, (byte)42);
- }
-
- public TestRecord(byte[] buffer){
- this.buffer = buffer;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof TestRecord) {
- TestRecord record = (TestRecord) obj;
-
- return Arrays.equals(buffer, record.buffer);
- } else {
- return false;
- }
- }
- }
-
- public static class TestRecordSerializer extends Serializer<TestRecord> implements Serializable {
-
- private static final long serialVersionUID = 6971996565421454985L;
-
- @Override
- public void write(Kryo kryo, Output output, TestRecord object) {
- output.writeInt(object.buffer.length);
- output.write(object.buffer);
- }
-
- @Override
- public TestRecord read(Kryo kryo, Input input, Class<TestRecord> type) {
- int length = input.readInt();
- byte[] buffer = input.readBytes(length);
-
- return new TestRecord(buffer);
- }
- }
-
- public static class TestDataOutputView implements DataOutputView {
-
- private byte[] buffer;
- private int position;
-
- public TestDataOutputView(int size) {
- buffer = new byte[size];
- position = 0;
- }
-
- public void clear() {
- position = 0;
- }
-
- public byte[] getBuffer() {
- return buffer;
- }
-
- public void checkSize(int numBytes) throws EOFException {
- if (position + numBytes > buffer.length) {
- throw new EOFException();
- }
- }
-
- @Override
- public void skipBytesToWrite(int numBytes) throws IOException {
- checkSize(numBytes);
-
- position += numBytes;
- }
-
- @Override
- public void write(DataInputView source, int numBytes) throws IOException {
- checkSize(numBytes);
-
- byte[] tempBuffer = new byte[numBytes];
-
- source.read(tempBuffer);
-
- System.arraycopy(tempBuffer, 0, buffer, position, numBytes);
-
- position += numBytes;
- }
-
- @Override
- public void write(int b) throws IOException {
- checkSize(4);
-
- position += 4;
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- checkSize(b.length);
-
- System.arraycopy(b, 0, buffer, position, b.length);
- position += b.length;
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- checkSize(len);
-
- System.arraycopy(b, off, buffer, position, len);
-
- position += len;
- }
-
- @Override
- public void writeBoolean(boolean v) throws IOException {
- checkSize(1);
- position += 1;
- }
-
- @Override
- public void writeByte(int v) throws IOException {
- checkSize(1);
-
- buffer[position] = (byte)v;
-
- position++;
- }
-
- @Override
- public void writeShort(int v) throws IOException {
- checkSize(2);
-
- position += 2;
- }
-
- @Override
- public void writeChar(int v) throws IOException {
- checkSize(1);
- position++;
- }
-
- @Override
- public void writeInt(int v) throws IOException {
- checkSize(4);
-
- position += 4;
- }
-
- @Override
- public void writeLong(long v) throws IOException {
- checkSize(8);
- position += 8;
- }
-
- @Override
- public void writeFloat(float v) throws IOException {
- checkSize(4);
- position += 4;
- }
-
- @Override
- public void writeDouble(double v) throws IOException {
- checkSize(8);
- position += 8;
- }
-
- @Override
- public void writeBytes(String s) throws IOException {
- byte[] sBuffer = s.getBytes();
- checkSize(sBuffer.length);
- System.arraycopy(sBuffer, 0, buffer, position, sBuffer.length);
- position += sBuffer.length;
- }
-
- @Override
- public void writeChars(String s) throws IOException {
- byte[] sBuffer = s.getBytes();
- checkSize(sBuffer.length);
- System.arraycopy(sBuffer, 0, buffer, position, sBuffer.length);
- position += sBuffer.length;
- }
-
- @Override
- public void writeUTF(String s) throws IOException {
- byte[] sBuffer = s.getBytes();
- checkSize(sBuffer.length);
- System.arraycopy(sBuffer, 0, buffer, position, sBuffer.length);
- position += sBuffer.length;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java
deleted file mode 100644
index 9d3eef1..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericArraySerializerTest.java
+++ /dev/null
@@ -1,30 +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.java.typeutils.runtime.kryo;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericArraySerializerTest;
-
-public class KryoGenericArraySerializerTest extends AbstractGenericArraySerializerTest {
- @Override
- protected <T> TypeSerializer<T> createComponentSerializer(Class<T> type) {
- return new KryoSerializer<T>(type, new ExecutionConfig());
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java
deleted file mode 100644
index 19aed78..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeComparatorTest.java
+++ /dev/null
@@ -1,30 +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.java.typeutils.runtime.kryo;
-
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeComparatorTest;
-
-public class KryoGenericTypeComparatorTest extends AbstractGenericTypeComparatorTest {
- @Override
- protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
- return new KryoSerializer<T>(type, new ExecutionConfig());
- }
-}
\ No newline at end of file
[23/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java
deleted file mode 100644
index b423a3b..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple15Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple15;
-
-public class Tuple15Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> {
-
- private List<Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> tuples = new ArrayList<Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>>();
-
- public Tuple15Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14){
- tuples.add(new Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple15<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>[] build(){
- return tuples.toArray(new Tuple15[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java
deleted file mode 100644
index c698730..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple16Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple16;
-
-public class Tuple16Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> {
-
- private List<Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> tuples = new ArrayList<Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>();
-
- public Tuple16Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15){
- tuples.add(new Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple16<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>[] build(){
- return tuples.toArray(new Tuple16[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java
deleted file mode 100644
index bad64f2..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple17Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple17;
-
-public class Tuple17Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> {
-
- private List<Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>> tuples = new ArrayList<Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>>();
-
- public Tuple17Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16){
- tuples.add(new Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple17<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>[] build(){
- return tuples.toArray(new Tuple17[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java
deleted file mode 100644
index 14a79f8..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple18Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple18;
-
-public class Tuple18Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> {
-
- private List<Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>> tuples = new ArrayList<Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>>();
-
- public Tuple18Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17){
- tuples.add(new Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple18<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>[] build(){
- return tuples.toArray(new Tuple18[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java
deleted file mode 100644
index 9acfc2f..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple19Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple19;
-
-public class Tuple19Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> {
-
- private List<Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> tuples = new ArrayList<Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>>();
-
- public Tuple19Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18){
- tuples.add(new Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple19<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>[] build(){
- return tuples.toArray(new Tuple19[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java
deleted file mode 100644
index a395cd1..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple1Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple1;
-
-public class Tuple1Builder<T0> {
-
- private List<Tuple1<T0>> tuples = new ArrayList<Tuple1<T0>>();
-
- public Tuple1Builder<T0> add(T0 value0){
- tuples.add(new Tuple1<T0>(value0));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple1<T0>[] build(){
- return tuples.toArray(new Tuple1[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java
deleted file mode 100644
index 8c7dd1d..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple20Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple20;
-
-public class Tuple20Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> {
-
- private List<Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>> tuples = new ArrayList<Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>>();
-
- public Tuple20Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19){
- tuples.add(new Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple20<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>[] build(){
- return tuples.toArray(new Tuple20[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java
deleted file mode 100644
index ba18345..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple21Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple21;
-
-public class Tuple21Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> {
-
- private List<Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>> tuples = new ArrayList<Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>>();
-
- public Tuple21Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20){
- tuples.add(new Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple21<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>[] build(){
- return tuples.toArray(new Tuple21[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java
deleted file mode 100644
index a4903c8..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple22Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple22;
-
-public class Tuple22Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> {
-
- private List<Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>> tuples = new ArrayList<Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>>();
-
- public Tuple22Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21){
- tuples.add(new Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>[] build(){
- return tuples.toArray(new Tuple22[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java
deleted file mode 100644
index a7a8102..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple23Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple23;
-
-public class Tuple23Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> {
-
- private List<Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>> tuples = new ArrayList<Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>>();
-
- public Tuple23Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22){
- tuples.add(new Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple23<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>[] build(){
- return tuples.toArray(new Tuple23[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java
deleted file mode 100644
index 6509518..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple24Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple24;
-
-public class Tuple24Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> {
-
- private List<Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>> tuples = new ArrayList<Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>>();
-
- public Tuple24Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23){
- tuples.add(new Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple24<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>[] build(){
- return tuples.toArray(new Tuple24[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java
deleted file mode 100644
index 3632eec..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple25Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple25;
-
-public class Tuple25Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> {
-
- private List<Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>> tuples = new ArrayList<Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>>();
-
- public Tuple25Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13, T14 value14, T15 value15, T16 value16, T17 value17, T18 value18, T19 value19, T20 value20, T21 value21, T22 value22, T23 value23, T24 value24){
- tuples.add(new Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13, value14, value15, value16, value17, value18, value19, value20, value21, value22, value23, value24));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple25<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>[] build(){
- return tuples.toArray(new Tuple25[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java
deleted file mode 100644
index adf697f..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple2Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple2;
-
-public class Tuple2Builder<T0, T1> {
-
- private List<Tuple2<T0, T1>> tuples = new ArrayList<Tuple2<T0, T1>>();
-
- public Tuple2Builder<T0, T1> add(T0 value0, T1 value1){
- tuples.add(new Tuple2<T0, T1>(value0, value1));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple2<T0, T1>[] build(){
- return tuples.toArray(new Tuple2[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java
deleted file mode 100644
index 7a0dee0..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple3Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple3;
-
-public class Tuple3Builder<T0, T1, T2> {
-
- private List<Tuple3<T0, T1, T2>> tuples = new ArrayList<Tuple3<T0, T1, T2>>();
-
- public Tuple3Builder<T0, T1, T2> add(T0 value0, T1 value1, T2 value2){
- tuples.add(new Tuple3<T0, T1, T2>(value0, value1, value2));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple3<T0, T1, T2>[] build(){
- return tuples.toArray(new Tuple3[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java
deleted file mode 100644
index 5caad15..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple4Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple4;
-
-public class Tuple4Builder<T0, T1, T2, T3> {
-
- private List<Tuple4<T0, T1, T2, T3>> tuples = new ArrayList<Tuple4<T0, T1, T2, T3>>();
-
- public Tuple4Builder<T0, T1, T2, T3> add(T0 value0, T1 value1, T2 value2, T3 value3){
- tuples.add(new Tuple4<T0, T1, T2, T3>(value0, value1, value2, value3));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple4<T0, T1, T2, T3>[] build(){
- return tuples.toArray(new Tuple4[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java
deleted file mode 100644
index 1895aca..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple5Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple5;
-
-public class Tuple5Builder<T0, T1, T2, T3, T4> {
-
- private List<Tuple5<T0, T1, T2, T3, T4>> tuples = new ArrayList<Tuple5<T0, T1, T2, T3, T4>>();
-
- public Tuple5Builder<T0, T1, T2, T3, T4> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4){
- tuples.add(new Tuple5<T0, T1, T2, T3, T4>(value0, value1, value2, value3, value4));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple5<T0, T1, T2, T3, T4>[] build(){
- return tuples.toArray(new Tuple5[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java
deleted file mode 100644
index 625ec8f..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple6Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple6;
-
-public class Tuple6Builder<T0, T1, T2, T3, T4, T5> {
-
- private List<Tuple6<T0, T1, T2, T3, T4, T5>> tuples = new ArrayList<Tuple6<T0, T1, T2, T3, T4, T5>>();
-
- public Tuple6Builder<T0, T1, T2, T3, T4, T5> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5){
- tuples.add(new Tuple6<T0, T1, T2, T3, T4, T5>(value0, value1, value2, value3, value4, value5));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple6<T0, T1, T2, T3, T4, T5>[] build(){
- return tuples.toArray(new Tuple6[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java
deleted file mode 100644
index 2cdde39..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple7Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple7;
-
-public class Tuple7Builder<T0, T1, T2, T3, T4, T5, T6> {
-
- private List<Tuple7<T0, T1, T2, T3, T4, T5, T6>> tuples = new ArrayList<Tuple7<T0, T1, T2, T3, T4, T5, T6>>();
-
- public Tuple7Builder<T0, T1, T2, T3, T4, T5, T6> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6){
- tuples.add(new Tuple7<T0, T1, T2, T3, T4, T5, T6>(value0, value1, value2, value3, value4, value5, value6));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple7<T0, T1, T2, T3, T4, T5, T6>[] build(){
- return tuples.toArray(new Tuple7[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java
deleted file mode 100644
index c5feb43..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple8Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple8;
-
-public class Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> {
-
- private List<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>> tuples = new ArrayList<Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>>();
-
- public Tuple8Builder<T0, T1, T2, T3, T4, T5, T6, T7> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7){
- tuples.add(new Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>(value0, value1, value2, value3, value4, value5, value6, value7));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>[] build(){
- return tuples.toArray(new Tuple8[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java b/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java
deleted file mode 100644
index 2665d7d..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/tuple/builder/Tuple9Builder.java
+++ /dev/null
@@ -1,46 +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.
- */
-
-
-// --------------------------------------------------------------
-// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
-// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
-// --------------------------------------------------------------
-
-
-package org.apache.flink.api.java.tuple.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.java.tuple.Tuple9;
-
-public class Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> {
-
- private List<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>> tuples = new ArrayList<Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>>();
-
- public Tuple9Builder<T0, T1, T2, T3, T4, T5, T6, T7, T8> add(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8){
- tuples.add(new Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>(value0, value1, value2, value3, value4, value5, value6, value7, value8));
- return this;
- }
-
- @SuppressWarnings("unchecked")
- public Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>[] build(){
- return tuples.toArray(new Tuple9[tuples.size()]);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java b/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
index 264b75b..0cc5dcf 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
@@ -27,7 +27,7 @@ public class Tuple2Test {
@Test
public void testSwapValues() {
- Tuple2<String, Integer> toSwap = new Tuple2<String, Integer>(new String("Test case"), 25);
+ Tuple2<String, Integer> toSwap = new Tuple2<>("Test case", 25);
Tuple2<Integer, String> swapped = toSwap.swap();
Assert.assertEquals(swapped.f0, toSwap.f1);
@@ -37,7 +37,7 @@ public class Tuple2Test {
@Test(expected = NullFieldException.class)
public void testGetFieldNotNull() {
- Tuple2<String, Integer> tuple = new Tuple2<String, Integer>(new String("Test case"), null);
+ Tuple2<String, Integer> tuple = new Tuple2<>("Test case", null);
Assert.assertEquals("Test case", tuple.getFieldNotNull(0));
tuple.getFieldNotNull(1);
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-java/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java b/flink-java/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java
new file mode 100644
index 0000000..8ac9c59
--- /dev/null
+++ b/flink-java/src/test/java/org/apache/flink/api/java/tuple/TupleGenerator.java
@@ -0,0 +1,498 @@
+/*
+ * 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.java.tuple;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Scanner;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
+/**
+ * Source code generator for tuple classes and classes which depend on the arity of tuples.
+ */
+class TupleGenerator {
+
+ // Parameters for tuple classes
+
+ private static final String ROOT_DIRECTORY = "./flink-java/src/main/java";
+
+ private static final String GEN_TYPE_PREFIX = "T";
+
+ // Parameters for tuple-dependent classes
+ private static final String BEGIN_INDICATOR = "BEGIN_OF_TUPLE_DEPENDENT_CODE";
+
+ private static final String END_INDICATOR = "END_OF_TUPLE_DEPENDENT_CODE";
+
+ // Parameters for CsvReader
+ private static final String CSV_READER_PACKAGE = "org.apache.flink.api.java.io";
+
+ private static final String CSV_READER_CLASSNAME = "CsvReader";
+
+ // Parameters for ProjectOperator
+ private static final String PROJECT_OPERATOR_PACKAGE = "org.apache.flink.api.java.operators";
+
+ private static final String PROJECT_OPERATOR_CLASSNAME = "ProjectOperator";
+
+ // Parameters for JoinOperator
+ private static final String JOIN_OPERATOR_PACKAGE = "org.apache.flink.api.java.operators";
+
+ private static final String JOIN_OPERATOR_CLASSNAME = "JoinOperator";
+
+ // parameters for CrossOperator
+ private static final String CROSS_OPERATOR_PACKAGE = "org.apache.flink.api.java.operators";
+
+ private static final String CROSS_OPERATOR_CLASSNAME = "CrossOperator";
+
+ // min. and max. tuple arity
+ private static final int FIRST = 1;
+
+ private static final int LAST = 25;
+
+ public static void main(String[] args) throws Exception {
+ System.err.println("Current directory "+System.getProperty("user.dir"));
+ String rootDir = ROOT_DIRECTORY;
+ if(args.length > 0) {
+ rootDir = args[0] + "/" + ROOT_DIRECTORY;
+ }
+ System.err.println("Using root directory: "+rootDir);
+ File root = new File(rootDir);
+
+ modifyCsvReader(root);
+
+ modifyProjectOperator(root);
+
+ modifyJoinProjectOperator(root);
+
+ modifyCrossProjectOperator(root);
+
+ }
+
+ private static File getPackage(File root, String packageString) {
+ File dir = new File(root, packageString.replace('.', '/'));
+ if (!dir.exists() && dir.isDirectory()) {
+ System.err.println("None existent directory: " + dir.getAbsolutePath());
+ System.exit(1);
+ }
+ return dir;
+ }
+
+ private static void insertCodeIntoFile(String code, File file) throws IOException {
+ String fileContent = Files.toString(file, Charsets.UTF_8);
+
+ try (Scanner s = new Scanner(fileContent)) {
+ StringBuilder sb = new StringBuilder();
+ String line;
+
+ boolean indicatorFound = false;
+
+ // add file beginning
+ while (s.hasNextLine() && (line = s.nextLine()) != null) {
+ sb.append(line).append("\n");
+ if (line.contains(BEGIN_INDICATOR)) {
+ indicatorFound = true;
+ break;
+ }
+ }
+
+ if(!indicatorFound) {
+ System.out.println("No indicator found in '" + file + "'. Will skip code generation.");
+ s.close();
+ return;
+ }
+
+ // add generator signature
+ sb.append("\t// GENERATED FROM ").append(TupleGenerator.class.getName()).append(".\n");
+
+ // add tuple dependent code
+ sb.append(code).append("\n");
+
+ // skip generated code
+ while (s.hasNextLine() && (line = s.nextLine()) != null) {
+ if (line.contains(END_INDICATOR)) {
+ sb.append(line).append("\n");
+ break;
+ }
+ }
+
+ // add file ending
+ while (s.hasNextLine() && (line = s.nextLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ s.close();
+ Files.write(sb.toString(), file, Charsets.UTF_8);
+ }
+ }
+
+ private static void modifyCrossProjectOperator(File root) throws IOException {
+ // generate code
+ StringBuilder sb = new StringBuilder();
+
+ // method begin
+ sb.append("\n");
+
+ // method comment
+ sb.append("\t\t/**\n");
+ sb.append("\t\t * Chooses a projectTupleX according to the length of\n");
+ sb.append("\t\t * {@link org.apache.flink.api.java.operators.CrossOperator.CrossProjection#fieldIndexes} \n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @return The projected DataSet.\n");
+ sb.append("\t\t */\n");
+
+ // method signature
+ sb.append("\t\t@SuppressWarnings(\"unchecked\")\n");
+ sb.append("\t\tpublic <OUT extends Tuple> ProjectCross<I1, I2, OUT> projectTupleX() {\n");
+ sb.append("\t\t\tProjectCross<I1, I2, OUT> projectionCross = null;\n\n");
+ sb.append("\t\t\tswitch (fieldIndexes.length) {\n");
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+ sb.append("\t\t\tcase " + numFields +":" + " projectionCross = (ProjectCross<I1, I2, OUT>) projectTuple"+numFields+"(); break;\n");
+ }
+ sb.append("\t\t\tdefault: throw new IllegalStateException(\"Excessive arity in tuple.\");\n");
+ sb.append("\t\t\t}\n\n");
+ sb.append("\t\t\treturn projectionCross;\n");
+
+ // method end
+ sb.append("\t\t}\n");
+
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+
+ // method begin
+ sb.append("\n");
+
+ // method comment
+ sb.append("\t\t/**\n");
+ sb.append("\t\t * Projects a pair of crossed elements to a {@link Tuple} with the previously selected fields. \n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @return The projected data set.\n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @see Tuple\n");
+ sb.append("\t\t * @see DataSet\n");
+ sb.append("\t\t */\n");
+
+ // method signature
+ sb.append("\t\tpublic <");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append("> ProjectCross<I1, I2, Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> projectTuple"+numFields+"(");
+ sb.append(") {\n");
+
+ // extract field types
+ sb.append("\t\t\tTypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);\n");
+
+ // create new tuple type info
+ sb.append("\t\t\tTupleTypeInfo<Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> tType = new TupleTypeInfo<Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(fTypes);\n\n");
+
+ // create and return new project operator
+ sb.append("\t\t\treturn new ProjectCross<I1, I2, Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(this.ds1, this.ds2, this.fieldIndexes, this.isFieldInFirst, tType, this, hint);\n");
+
+ // method end
+ sb.append("\t\t}\n");
+
+ }
+
+ // insert code into file
+ File dir = getPackage(root, CROSS_OPERATOR_PACKAGE);
+ File projectOperatorClass = new File(dir, CROSS_OPERATOR_CLASSNAME + ".java");
+ insertCodeIntoFile(sb.toString(), projectOperatorClass);
+ }
+
+ private static void modifyProjectOperator(File root) throws IOException {
+ // generate code
+ StringBuilder sb = new StringBuilder();
+
+ // method begin
+ sb.append("\n");
+
+ // method comment
+ sb.append("\t\t/**\n");
+ sb.append("\t\t * Chooses a projectTupleX according to the length of\n");
+ sb.append("\t\t * {@link org.apache.flink.api.java.operators.ProjectOperator.Projection#fieldIndexes} \n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @return The projected DataSet.\n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @see org.apache.flink.api.java.operators.ProjectOperator.Projection\n");
+ sb.append("\t\t */\n");
+
+ // method signature
+ sb.append("\t\t@SuppressWarnings(\"unchecked\")\n");
+ sb.append("\t\tpublic <OUT extends Tuple> ProjectOperator<T, OUT> projectTupleX() {\n");
+ sb.append("\t\t\tProjectOperator<T, OUT> projOperator;\n\n");
+ sb.append("\t\t\tswitch (fieldIndexes.length) {\n");
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+ sb.append("\t\t\tcase " + numFields +":" + " projOperator = (ProjectOperator<T, OUT>) projectTuple"+numFields+"(); break;\n");
+ }
+ sb.append("\t\t\tdefault: throw new IllegalStateException(\"Excessive arity in tuple.\");\n");
+ sb.append("\t\t\t}\n\n");
+ sb.append("\t\t\treturn projOperator;\n");
+
+ // method end
+ sb.append("\t\t}\n");
+
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+
+ // method begin
+ sb.append("\n");
+
+ // method comment
+ sb.append("\t\t/**\n");
+ sb.append("\t\t * Projects a {@link Tuple} {@link DataSet} to the previously selected fields. \n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @return The projected DataSet.\n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @see Tuple\n");
+ sb.append("\t\t * @see DataSet\n");
+ sb.append("\t\t */\n");
+
+ // method signature
+ sb.append("\t\tpublic <");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append("> ProjectOperator<T, Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> projectTuple"+numFields+"(");
+ sb.append(") {\n");
+
+ // extract field types
+ sb.append("\t\t\tTypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, ds.getType());\n");
+
+ // create new tuple type info
+ sb.append("\t\t\tTupleTypeInfo<Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> tType = new TupleTypeInfo<Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(fTypes);\n\n");
+
+ // create and return new project operator
+ sb.append("\t\t\treturn new ProjectOperator<T, Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(this.ds, this.fieldIndexes, tType);\n");
+
+ // method end
+ sb.append("\t\t}\n");
+
+ }
+
+ // insert code into file
+ File dir = getPackage(root, PROJECT_OPERATOR_PACKAGE);
+ File projectOperatorClass = new File(dir, PROJECT_OPERATOR_CLASSNAME + ".java");
+ insertCodeIntoFile(sb.toString(), projectOperatorClass);
+ }
+
+ private static void modifyJoinProjectOperator(File root) throws IOException {
+ // generate code
+ StringBuilder sb = new StringBuilder();
+
+ // method begin
+ sb.append("\n");
+
+ // method comment
+ sb.append("\t\t/**\n");
+ sb.append("\t\t * Chooses a projectTupleX according to the length of\n");
+ sb.append("\t\t * {@link org.apache.flink.api.java.operators.JoinOperator.JoinProjection#fieldIndexes}\n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @return The projected DataSet.\n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @see org.apache.flink.api.java.operators.JoinOperator.ProjectJoin\n");
+ sb.append("\t\t */\n");
+
+ // method signature
+ sb.append("\t\t@SuppressWarnings(\"unchecked\")\n");
+ sb.append("\t\tpublic <OUT extends Tuple> ProjectJoin<I1, I2, OUT> projectTupleX() {\n");
+ sb.append("\t\t\tProjectJoin<I1, I2, OUT> projectJoin = null;\n\n");
+ sb.append("\t\t\tswitch (fieldIndexes.length) {\n");
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+ sb.append("\t\t\tcase " + numFields +":" + " projectJoin = (ProjectJoin<I1, I2, OUT>) projectTuple"+numFields+"(); break;\n");
+ }
+ sb.append("\t\t\tdefault: throw new IllegalStateException(\"Excessive arity in tuple.\");\n");
+ sb.append("\t\t\t}\n\n");
+ sb.append("\t\t\treturn projectJoin;\n");
+
+ // method end
+ sb.append("\t\t}\n");
+
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+
+ // method begin
+ sb.append("\n");
+
+ // method comment
+ sb.append("\t\t/**\n");
+ sb.append("\t\t * Projects a pair of joined elements to a {@link Tuple} with the previously selected fields. \n");
+ sb.append("\t\t * Requires the classes of the fields of the resulting tuples. \n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @return The projected data set.\n");
+ sb.append("\t\t * \n");
+ sb.append("\t\t * @see Tuple\n");
+ sb.append("\t\t * @see DataSet\n");
+ sb.append("\t\t */\n");
+
+ // method signature
+ sb.append("\t\tpublic <");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append("> ProjectJoin<I1, I2, Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> projectTuple"+numFields+"(");
+ sb.append(") {\n");
+
+ // extract field types
+ sb.append("\t\t\tTypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes);\n");
+
+ // create new tuple type info
+ sb.append("\t\t\tTupleTypeInfo<Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> tType = new TupleTypeInfo<Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(fTypes);\n\n");
+
+ // create and return new project operator
+ sb.append("\t\t\treturn new ProjectJoin<I1, I2, Tuple"+numFields+"<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(this.ds1, this.ds2, this.keys1, this.keys2, this.hint, this.fieldIndexes, this.isFieldInFirst, tType, this);\n");
+
+ // method end
+ sb.append("\t\t}\n");
+
+ }
+
+ // insert code into file
+ File dir = getPackage(root, JOIN_OPERATOR_PACKAGE);
+ File projectOperatorClass = new File(dir, JOIN_OPERATOR_CLASSNAME + ".java");
+ insertCodeIntoFile(sb.toString(), projectOperatorClass);
+ }
+
+ private static void modifyCsvReader(File root) throws IOException {
+ // generate code
+ StringBuilder sb = new StringBuilder(1000);
+ for (int numFields = FIRST; numFields <= LAST; numFields++) {
+
+ // method begin
+ sb.append("\n");
+
+ // java doc
+ sb.append("\t/**\n");
+ sb.append("\t * Specifies the types for the CSV fields. This method parses the CSV data to a ").append(numFields).append("-tuple\n");
+ sb.append("\t * which has fields of the specified types.\n");
+ sb.append("\t * This method is overloaded for each possible length of the tuples to support type safe\n");
+ sb.append("\t * creation of data sets through CSV parsing.\n");
+ sb.append("\t *\n");
+
+ for (int pos = 0; pos < numFields; pos++) {
+ sb.append("\t * @param type").append(pos);
+ sb.append(" The type of CSV field ").append(pos).append(" and the type of field ");
+ sb.append(pos).append(" in the returned tuple type.\n");
+ }
+ sb.append("\t * @return The {@link org.apache.flink.api.java.DataSet} representing the parsed CSV data.\n");
+ sb.append("\t */\n");
+
+ // method signature
+ sb.append("\tpublic <");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append("> DataSource<Tuple" + numFields + "<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> types(");
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append("Class<");
+ sb.append(GEN_TYPE_PREFIX + i);
+ sb.append("> type" + i);
+ }
+ sb.append(") {\n");
+
+ // get TupleTypeInfo
+ sb.append("\t\tTupleTypeInfo<Tuple" + numFields + "<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> types = TupleTypeInfo.getBasicAndBasicValueTupleTypeInfo(");
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append("type" + i);
+ }
+ sb.append(");\n");
+
+ // create csv input format
+ sb.append("\t\tCsvInputFormat<Tuple" + numFields + "<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">> inputFormat = new TupleCsvInputFormat<Tuple" + numFields + "<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(path, types, this.includedMask);\n");
+
+ // configure input format
+ sb.append("\t\tconfigureInputFormat(inputFormat);\n");
+
+ // return
+ sb.append("\t\treturn new DataSource<Tuple" + numFields + "<");
+ appendTupleTypeGenerics(sb, numFields);
+ sb.append(">>(executionContext, inputFormat, types, Utils.getCallLocationName());\n");
+
+ // end of method
+ sb.append("\t}\n");
+ }
+
+ // insert code into file
+ File dir = getPackage(root, CSV_READER_PACKAGE);
+ File csvReaderClass = new File(dir, CSV_READER_CLASSNAME + ".java");
+ insertCodeIntoFile(sb.toString(), csvReaderClass);
+ }
+
+ private static void appendTupleTypeGenerics(StringBuilder sb, int numFields) {
+ for (int i = 0; i < numFields; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(GEN_TYPE_PREFIX + i);
+ }
+ }
+
+
+ private static String HEADER =
+ "/*\n"
+ + " * Licensed to the Apache Software Foundation (ASF) under one\n"
+ + " * or more contributor license agreements. See the NOTICE file\n"
+ + " * distributed with this work for additional information\n"
+ + " * regarding copyright ownership. The ASF licenses this file\n"
+ + " * to you under the Apache License, Version 2.0 (the\n"
+ + " * \"License\"); you may not use this file except in compliance\n"
+ + " * with the License. You may obtain a copy of the License at\n"
+ + " *\n"
+ + " * http://www.apache.org/licenses/LICENSE-2.0\n"
+ + " *\n"
+ + " * Unless required by applicable law or agreed to in writing, software\n"
+ + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"
+ + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
+ + " * See the License for the specific language governing permissions and\n"
+ + " * limitations under the License.\n"
+ + " */" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "// --------------------------------------------------------------\n" +
+ "// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!\n" +
+ "// GENERATED FROM " + TupleGenerator.class.getName() + ".\n" +
+ "// --------------------------------------------------------------\n\n\n";
+}
\ No newline at end of file
[22/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
[FLINK-3303] [core] Move all type utilities to flink-core
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/21a71586
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/21a71586
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/21a71586
Branch: refs/heads/master
Commit: 21a715867d655bb61df9a9f7eef37e42b99e206a
Parents: 7081836
Author: Stephan Ewen <se...@apache.org>
Authored: Sun Jan 31 23:28:32 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 16:55:44 2016 +0100
----------------------------------------------------------------------
flink-core/pom.xml | 47 +-
.../apache/flink/api/common/operators/Keys.java | 459 +++++
.../flink/api/java/functions/KeySelector.java | 63 +
.../flink/api/java/typeutils/AvroTypeInfo.java | 78 +
.../api/java/typeutils/EitherTypeInfo.java | 122 ++
.../flink/api/java/typeutils/EnumTypeInfo.java | 122 ++
.../api/java/typeutils/GenericTypeInfo.java | 116 ++
.../java/typeutils/InputTypeConfigurable.java | 42 +
.../api/java/typeutils/MissingTypeInfo.java | 121 ++
.../api/java/typeutils/ObjectArrayTypeInfo.java | 141 ++
.../flink/api/java/typeutils/PojoField.java | 108 +
.../flink/api/java/typeutils/PojoTypeInfo.java | 406 ++++
.../api/java/typeutils/ResultTypeQueryable.java | 37 +
.../flink/api/java/typeutils/TupleTypeInfo.java | 248 +++
.../api/java/typeutils/TupleTypeInfoBase.java | 252 +++
.../flink/api/java/typeutils/TypeExtractor.java | 1692 +++++++++++++++
.../api/java/typeutils/TypeInfoParser.java | 383 ++++
.../flink/api/java/typeutils/ValueTypeInfo.java | 183 ++
.../api/java/typeutils/WritableTypeInfo.java | 139 ++
.../java/typeutils/runtime/AvroSerializer.java | 201 ++
.../runtime/CopyableValueComparator.java | 167 ++
.../runtime/CopyableValueSerializer.java | 129 ++
.../typeutils/runtime/DataInputDecoder.java | 229 +++
.../typeutils/runtime/DataInputViewStream.java | 71 +
.../typeutils/runtime/DataOutputEncoder.java | 190 ++
.../typeutils/runtime/DataOutputViewStream.java | 41 +
.../typeutils/runtime/EitherSerializer.java | 193 ++
.../runtime/GenericTypeComparator.java | 177 ++
.../api/java/typeutils/runtime/KryoUtils.java | 87 +
.../java/typeutils/runtime/NoFetchingInput.java | 141 ++
.../java/typeutils/runtime/PojoComparator.java | 354 ++++
.../java/typeutils/runtime/PojoSerializer.java | 592 ++++++
.../runtime/RuntimeComparatorFactory.java | 75 +
.../runtime/RuntimePairComparatorFactory.java | 44 +
.../runtime/RuntimeSerializerFactory.java | 124 ++
.../typeutils/runtime/Tuple0Serializer.java | 121 ++
.../java/typeutils/runtime/TupleComparator.java | 157 ++
.../typeutils/runtime/TupleComparatorBase.java | 279 +++
.../java/typeutils/runtime/TupleSerializer.java | 158 ++
.../typeutils/runtime/TupleSerializerBase.java | 102 +
.../java/typeutils/runtime/ValueComparator.java | 183 ++
.../java/typeutils/runtime/ValueSerializer.java | 152 ++
.../typeutils/runtime/WritableComparator.java | 189 ++
.../typeutils/runtime/WritableSerializer.java | 153 ++
.../typeutils/runtime/kryo/KryoSerializer.java | 382 ++++
.../typeutils/runtime/kryo/Serializers.java | 227 ++
.../common/operators/ExpressionKeysTest.java | 481 +++++
.../operators/SelectorFunctionKeysTest.java | 154 ++
.../apache/flink/api/java/tuple/Tuple2Test.java | 44 +
.../api/java/typeutils/CompositeTypeTest.java | 179 ++
.../api/java/typeutils/EitherTypeInfoTest.java | 61 +
.../api/java/typeutils/EnumTypeInfoTest.java | 51 +
.../api/java/typeutils/GenericTypeInfoTest.java | 47 +
.../api/java/typeutils/MissingTypeInfoTest.java | 47 +
.../java/typeutils/ObjectArrayTypeInfoTest.java | 58 +
.../java/typeutils/PojoTypeExtractionTest.java | 812 ++++++++
.../api/java/typeutils/PojoTypeInfoTest.java | 153 ++
.../java/typeutils/PojoTypeInformationTest.java | 98 +
.../api/java/typeutils/TupleTypeInfoTest.java | 96 +
.../TypeExtractorInputFormatsTest.java | 231 +++
.../api/java/typeutils/TypeExtractorTest.java | 1907 +++++++++++++++++
.../api/java/typeutils/TypeInfoParserTest.java | 338 +++
.../api/java/typeutils/ValueTypeInfoTest.java | 87 +
.../java/typeutils/WritableTypeInfoTest.java | 74 +
.../AbstractGenericArraySerializerTest.java | 187 ++
.../AbstractGenericTypeComparatorTest.java | 376 ++++
.../AbstractGenericTypeSerializerTest.java | 364 ++++
.../runtime/AvroGenericArraySerializerTest.java | 28 +
.../runtime/AvroGenericTypeComparatorTest.java | 28 +
.../runtime/AvroGenericTypeSerializerTest.java | 29 +
.../runtime/AvroSerializerEmptyArrayTest.java | 189 ++
.../runtime/CopyableValueComparatorTest.java | 53 +
.../typeutils/runtime/EitherSerializerTest.java | 113 +
.../runtime/GenericPairComparatorTest.java | 89 +
.../MultidimensionalArraySerializerTest.java | 120 ++
.../typeutils/runtime/PojoComparatorTest.java | 63 +
.../typeutils/runtime/PojoContainingTuple.java | 44 +
.../runtime/PojoGenericTypeSerializerTest.java | 33 +
.../typeutils/runtime/PojoSerializerTest.java | 243 +++
.../runtime/PojoSubclassComparatorTest.java | 76 +
.../runtime/PojoSubclassSerializerTest.java | 196 ++
.../typeutils/runtime/StringArrayWritable.java | 83 +
.../SubclassFromInterfaceSerializerTest.java | 171 ++
.../runtime/TestDataOutputSerializer.java | 308 +++
.../runtime/TupleComparatorILD2Test.java | 73 +
.../runtime/TupleComparatorILD3Test.java | 75 +
.../runtime/TupleComparatorILDC3Test.java | 75 +
.../runtime/TupleComparatorILDX1Test.java | 71 +
.../runtime/TupleComparatorILDXC2Test.java | 73 +
.../runtime/TupleComparatorISD1Test.java | 69 +
.../runtime/TupleComparatorISD2Test.java | 73 +
.../runtime/TupleComparatorISD3Test.java | 75 +
.../runtime/TupleComparatorTTT1Test.java | 139 ++
.../runtime/TupleComparatorTTT2Test.java | 145 ++
.../runtime/TupleComparatorTTT3Test.java | 154 ++
.../typeutils/runtime/TupleSerializerTest.java | 238 +++
.../runtime/TupleSerializerTestInstance.java | 79 +
.../typeutils/runtime/ValueComparatorTest.java | 53 +
.../runtime/ValueComparatorUUIDTest.java | 46 +
.../api/java/typeutils/runtime/ValueID.java | 72 +
.../runtime/ValueSerializerUUIDTest.java | 50 +
.../runtime/WritableComparatorTest.java | 53 +
.../runtime/WritableComparatorUUIDTest.java | 46 +
.../api/java/typeutils/runtime/WritableID.java | 78 +
.../runtime/WritableSerializerTest.java | 50 +
.../runtime/WritableSerializerUUIDTest.java | 50 +
.../runtime/kryo/KryoClearedBufferTest.java | 287 +++
.../kryo/KryoGenericArraySerializerTest.java | 30 +
.../kryo/KryoGenericTypeComparatorTest.java | 30 +
.../kryo/KryoGenericTypeSerializerTest.java | 168 ++
.../kryo/KryoWithCustomSerializersTest.java | 75 +
.../typeutils/runtime/kryo/SerializersTest.java | 103 +
.../tuple/base/TupleComparatorTestBase.java | 43 +
.../tuple/base/TuplePairComparatorTestBase.java | 109 +
flink-java/pom.xml | 32 +-
.../java/org/apache/flink/api/java/DataSet.java | 2 +-
.../java/org/apache/flink/api/java/Utils.java | 19 -
.../flink/api/java/functions/KeySelector.java | 63 -
.../api/java/functions/SemanticPropUtil.java | 2 +-
.../flink/api/java/io/SplitDataProperties.java | 2 +-
.../api/java/operators/AggregateOperator.java | 1 +
.../api/java/operators/CoGroupOperator.java | 23 +-
.../api/java/operators/CoGroupRawOperator.java | 3 +-
.../flink/api/java/operators/DataSink.java | 1 +
.../api/java/operators/DeltaIteration.java | 1 +
.../java/operators/DeltaIterationResultSet.java | 1 +
.../api/java/operators/DistinctOperator.java | 7 +-
.../java/operators/GroupCombineOperator.java | 11 +-
.../api/java/operators/GroupReduceOperator.java | 11 +-
.../flink/api/java/operators/Grouping.java | 1 +
.../flink/api/java/operators/JoinOperator.java | 15 +-
.../flink/api/java/operators/KeyFunctions.java | 119 ++
.../apache/flink/api/java/operators/Keys.java | 550 -----
.../api/java/operators/PartitionOperator.java | 9 +-
.../api/java/operators/ReduceOperator.java | 9 +-
.../java/operators/SortPartitionOperator.java | 1 +
.../api/java/operators/SortedGrouping.java | 3 +-
.../api/java/operators/UdfOperatorUtils.java | 1 +
.../api/java/operators/UnsortedGrouping.java | 1 +
.../operators/join/JoinOperatorSetsBase.java | 2 +-
.../PlanBothUnwrappingCoGroupOperator.java | 2 +-
.../PlanLeftUnwrappingCoGroupOperator.java | 2 +-
.../PlanRightUnwrappingCoGroupOperator.java | 2 +-
.../PlanUnwrappingGroupCombineOperator.java | 2 +-
.../PlanUnwrappingReduceGroupOperator.java | 2 +-
.../PlanUnwrappingReduceOperator.java | 2 +-
...lanUnwrappingSortedGroupCombineOperator.java | 2 +-
...PlanUnwrappingSortedReduceGroupOperator.java | 2 +-
.../apache/flink/api/java/sca/UdfAnalyzer.java | 4 +-
.../flink/api/java/typeutils/AvroTypeInfo.java | 78 -
.../apache/flink/api/java/typeutils/Either.java | 185 --
.../api/java/typeutils/EitherTypeInfo.java | 121 --
.../flink/api/java/typeutils/EnumTypeInfo.java | 122 --
.../api/java/typeutils/GenericTypeInfo.java | 116 --
.../java/typeutils/InputTypeConfigurable.java | 42 -
.../api/java/typeutils/MissingTypeInfo.java | 121 --
.../api/java/typeutils/ObjectArrayTypeInfo.java | 141 --
.../flink/api/java/typeutils/PojoField.java | 108 -
.../flink/api/java/typeutils/PojoTypeInfo.java | 405 ----
.../api/java/typeutils/ResultTypeQueryable.java | 37 -
.../flink/api/java/typeutils/TupleTypeInfo.java | 248 ---
.../api/java/typeutils/TupleTypeInfoBase.java | 251 ---
.../flink/api/java/typeutils/TypeExtractor.java | 1687 ---------------
.../api/java/typeutils/TypeInfoParser.java | 383 ----
.../flink/api/java/typeutils/ValueTypeInfo.java | 183 --
.../api/java/typeutils/WritableTypeInfo.java | 139 --
.../java/typeutils/runtime/AvroSerializer.java | 201 --
.../runtime/CopyableValueComparator.java | 167 --
.../runtime/CopyableValueSerializer.java | 129 --
.../typeutils/runtime/DataInputDecoder.java | 229 ---
.../typeutils/runtime/DataInputViewStream.java | 71 -
.../typeutils/runtime/DataOutputEncoder.java | 190 --
.../typeutils/runtime/DataOutputViewStream.java | 41 -
.../typeutils/runtime/EitherSerializer.java | 193 --
.../runtime/GenericTypeComparator.java | 177 --
.../api/java/typeutils/runtime/KryoUtils.java | 87 -
.../java/typeutils/runtime/NoFetchingInput.java | 141 --
.../java/typeutils/runtime/PojoComparator.java | 354 ----
.../java/typeutils/runtime/PojoSerializer.java | 592 ------
.../runtime/RuntimeComparatorFactory.java | 75 -
.../runtime/RuntimePairComparatorFactory.java | 44 -
.../runtime/RuntimeSerializerFactory.java | 124 --
.../typeutils/runtime/Tuple0Serializer.java | 121 --
.../java/typeutils/runtime/TupleComparator.java | 157 --
.../typeutils/runtime/TupleComparatorBase.java | 279 ---
.../java/typeutils/runtime/TupleSerializer.java | 158 --
.../typeutils/runtime/TupleSerializerBase.java | 102 -
.../java/typeutils/runtime/ValueComparator.java | 183 --
.../java/typeutils/runtime/ValueSerializer.java | 152 --
.../typeutils/runtime/WritableComparator.java | 189 --
.../typeutils/runtime/WritableSerializer.java | 153 --
.../typeutils/runtime/kryo/KryoSerializer.java | 382 ----
.../typeutils/runtime/kryo/Serializers.java | 229 ---
.../flink/api/java/TypeExtractionTest.java | 117 ++
.../api/java/operators/ExpressionKeysTest.java | 479 -----
.../flink/api/java/operators/NamesTest.java | 4 +-
.../operators/SelectorFunctionKeysTest.java | 153 --
.../flink/api/java/sca/UdfAnalyzerTest.java | 2 +-
.../apache/flink/api/java/tuple/Tuple2Test.java | 45 -
.../type/extractor/PojoTypeExtractionTest.java | 876 --------
.../type/extractor/PojoTypeInformationTest.java | 98 -
.../TypeExtractorInputFormatsTest.java | 234 ---
.../java/type/extractor/TypeExtractorTest.java | 1931 ------------------
.../api/java/typeutils/CompositeTypeTest.java | 179 --
.../api/java/typeutils/EitherTypeInfoTest.java | 60 -
.../api/java/typeutils/EnumTypeInfoTest.java | 51 -
.../api/java/typeutils/GenericTypeInfoTest.java | 47 -
.../api/java/typeutils/MissingTypeInfoTest.java | 47 -
.../java/typeutils/ObjectArrayTypeInfoTest.java | 58 -
.../api/java/typeutils/PojoTypeInfoTest.java | 153 --
.../api/java/typeutils/TupleTypeInfoTest.java | 96 -
.../api/java/typeutils/TypeInfoParserTest.java | 338 ---
.../api/java/typeutils/ValueTypeInfoTest.java | 87 -
.../java/typeutils/WritableTypeInfoTest.java | 74 -
.../AbstractGenericArraySerializerTest.java | 187 --
.../AbstractGenericTypeComparatorTest.java | 376 ----
.../AbstractGenericTypeSerializerTest.java | 364 ----
.../runtime/AvroGenericArraySerializerTest.java | 28 -
.../runtime/AvroGenericTypeComparatorTest.java | 28 -
.../runtime/AvroGenericTypeSerializerTest.java | 29 -
.../runtime/AvroSerializerEmptyArrayTest.java | 189 --
.../runtime/CopyableValueComparatorTest.java | 53 -
.../typeutils/runtime/EitherSerializerTest.java | 113 -
.../runtime/GenericPairComparatorTest.java | 89 -
.../MultidimensionalArraySerializerTest.java | 120 --
.../typeutils/runtime/PojoComparatorTest.java | 63 -
.../typeutils/runtime/PojoContainingTuple.java | 44 -
.../runtime/PojoGenericTypeSerializerTest.java | 33 -
.../typeutils/runtime/PojoSerializerTest.java | 243 ---
.../runtime/PojoSubclassComparatorTest.java | 76 -
.../runtime/PojoSubclassSerializerTest.java | 196 --
.../typeutils/runtime/StringArrayWritable.java | 83 -
.../SubclassFromInterfaceSerializerTest.java | 171 --
.../runtime/TestDataOutputSerializer.java | 308 ---
.../runtime/TupleComparatorILD2Test.java | 73 -
.../runtime/TupleComparatorILD3Test.java | 75 -
.../runtime/TupleComparatorILDC3Test.java | 75 -
.../runtime/TupleComparatorILDX1Test.java | 71 -
.../runtime/TupleComparatorILDXC2Test.java | 73 -
.../runtime/TupleComparatorISD1Test.java | 69 -
.../runtime/TupleComparatorISD2Test.java | 73 -
.../runtime/TupleComparatorISD3Test.java | 75 -
.../runtime/TupleComparatorTTT1Test.java | 139 --
.../runtime/TupleComparatorTTT2Test.java | 145 --
.../runtime/TupleComparatorTTT3Test.java | 154 --
.../typeutils/runtime/TupleSerializerTest.java | 238 ---
.../runtime/TupleSerializerTestInstance.java | 79 -
.../typeutils/runtime/ValueComparatorTest.java | 53 -
.../runtime/ValueComparatorUUIDTest.java | 46 -
.../api/java/typeutils/runtime/ValueID.java | 72 -
.../runtime/ValueSerializerUUIDTest.java | 50 -
.../runtime/WritableComparatorTest.java | 53 -
.../runtime/WritableComparatorUUIDTest.java | 46 -
.../api/java/typeutils/runtime/WritableID.java | 78 -
.../runtime/WritableSerializerTest.java | 50 -
.../runtime/WritableSerializerUUIDTest.java | 50 -
.../runtime/kryo/KryoClearedBufferTest.java | 287 ---
.../kryo/KryoGenericArraySerializerTest.java | 30 -
.../kryo/KryoGenericTypeComparatorTest.java | 30 -
.../kryo/KryoGenericTypeSerializerTest.java | 168 --
.../kryo/KryoWithCustomSerializersTest.java | 75 -
.../typeutils/runtime/kryo/SerializersTest.java | 103 -
.../tuple/base/TupleComparatorTestBase.java | 43 -
.../tuple/base/TuplePairComparatorTestBase.java | 109 -
.../flink/python/api/PythonPlanBinder.java | 2 +-
.../api/java/table/JavaBatchTranslator.scala | 5 +-
.../scala/operators/ScalaAggregateOperator.java | 2 +-
.../apache/flink/api/scala/CoGroupDataSet.scala | 4 +-
.../org/apache/flink/api/scala/DataSet.scala | 21 +-
.../apache/flink/api/scala/GroupedDataSet.scala | 4 +-
.../api/scala/UnfinishedCoGroupOperation.scala | 2 +
.../apache/flink/api/scala/joinDataSet.scala | 3 +
.../api/scala/typeutils/CaseClassTypeInfo.scala | 3 +-
.../api/scala/unfinishedKeyPairOperation.scala | 4 +-
.../streaming/api/datastream/DataStream.java | 2 +-
.../streaming/util/keys/KeySelectorUtil.java | 2 +-
.../streaming/api/AggregationFunctionTest.java | 2 +-
.../scala/operators/CoGroupOperatorTest.scala | 3 +-
.../scala/operators/GroupCombineITCase.scala | 10 +-
.../api/scala/operators/JoinOperatorTest.scala | 3 +-
.../scala/types/TypeInformationGenTest.scala | 4 +-
281 files changed, 20419 insertions(+), 20528 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/pom.xml
----------------------------------------------------------------------
diff --git a/flink-core/pom.xml b/flink-core/pom.xml
index adc9a9b..ba1050c 100644
--- a/flink-core/pom.xml
+++ b/flink-core/pom.xml
@@ -40,12 +40,6 @@ under the License.
<artifactId>flink-annotations</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>${shading-artifact.name}</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>commons-collections</groupId>
@@ -56,20 +50,61 @@ under the License.
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
+ <!-- managed version -->
</dependency>
+ <!-- Avro is needed for the interoperability with Avro types for serialization -->
+ <dependency>
+ <groupId>org.apache.avro</groupId>
+ <artifactId>avro</artifactId>
+ <!-- managed version -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.xerial.snappy</groupId>
+ <artifactId>snappy-java</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Hadoop is only needed here for serialization interoperability with the Writable type -->
+ <dependency>
+ <groupId>org.apache.flink</groupId>
+ <artifactId>${shading-artifact.name}</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
+ <!-- test depedencies -->
+
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.joda</groupId>
+ <artifactId>joda-convert</artifactId>
+ <version>1.7</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/common/operators/Keys.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/common/operators/Keys.java b/flink-core/src/main/java/org/apache/flink/api/common/operators/Keys.java
new file mode 100644
index 0000000..6d681de
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/common/operators/Keys.java
@@ -0,0 +1,459 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.common.base.Joiner;
+
+import org.apache.flink.api.common.InvalidProgramException;
+import org.apache.flink.api.common.functions.Partitioner;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
+import org.apache.flink.api.java.functions.KeySelector;
+import org.apache.flink.api.java.typeutils.GenericTypeInfo;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+
+import com.google.common.base.Preconditions;
+
+public abstract class Keys<T> {
+
+ public abstract int getNumberOfKeyFields();
+
+ public abstract int[] computeLogicalKeyPositions();
+
+ protected abstract TypeInformation<?>[] getKeyFieldTypes();
+
+ public abstract <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo);
+
+ public boolean isEmpty() {
+ return getNumberOfKeyFields() == 0;
+ }
+
+ /**
+ * Check if two sets of keys are compatible to each other (matching types, key counts)
+ */
+ public boolean areCompatible(Keys<?> other) throws IncompatibleKeysException {
+
+ TypeInformation<?>[] thisKeyFieldTypes = this.getKeyFieldTypes();
+ TypeInformation<?>[] otherKeyFieldTypes = other.getKeyFieldTypes();
+
+ if (thisKeyFieldTypes.length != otherKeyFieldTypes.length) {
+ throw new IncompatibleKeysException(IncompatibleKeysException.SIZE_MISMATCH_MESSAGE);
+ } else {
+ for (int i = 0; i < thisKeyFieldTypes.length; i++) {
+ if (!thisKeyFieldTypes[i].equals(otherKeyFieldTypes[i])) {
+ throw new IncompatibleKeysException(thisKeyFieldTypes[i], otherKeyFieldTypes[i] );
+ }
+ }
+ }
+ return true;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Specializations for expression-based / extractor-based grouping
+ // --------------------------------------------------------------------------------------------
+
+
+ public static class SelectorFunctionKeys<T, K> extends Keys<T> {
+
+ private final KeySelector<T, K> keyExtractor;
+ private final TypeInformation<T> inputType;
+ private final TypeInformation<K> keyType;
+ private final List<FlatFieldDescriptor> keyFields;
+
+ public SelectorFunctionKeys(KeySelector<T, K> keyExtractor, TypeInformation<T> inputType, TypeInformation<K> keyType) {
+
+ if (keyExtractor == null) {
+ throw new NullPointerException("Key extractor must not be null.");
+ }
+ if (keyType == null) {
+ throw new NullPointerException("Key type must not be null.");
+ }
+ if (!keyType.isKeyType()) {
+ throw new InvalidProgramException("Return type "+keyType+" of KeySelector "+keyExtractor.getClass()+" is not a valid key type");
+ }
+
+ this.keyExtractor = keyExtractor;
+ this.inputType = inputType;
+ this.keyType = keyType;
+
+ if (keyType instanceof CompositeType) {
+ this.keyFields = ((CompositeType<T>)keyType).getFlatFields(ExpressionKeys.SELECT_ALL_CHAR);
+ }
+ else {
+ this.keyFields = new ArrayList<>(1);
+ this.keyFields.add(new FlatFieldDescriptor(0, keyType));
+ }
+ }
+
+ public TypeInformation<K> getKeyType() {
+ return keyType;
+ }
+
+ public TypeInformation<T> getInputType() {
+ return inputType;
+ }
+
+ public KeySelector<T, K> getKeyExtractor() {
+ return keyExtractor;
+ }
+
+ @Override
+ public int getNumberOfKeyFields() {
+ return keyFields.size();
+ }
+
+ @Override
+ public int[] computeLogicalKeyPositions() {
+ int[] logicalKeys = new int[keyFields.size()];
+ for (int i = 0; i < keyFields.size(); i++) {
+ logicalKeys[i] = keyFields.get(i).getPosition();
+ }
+ return logicalKeys;
+ }
+
+ @Override
+ protected TypeInformation<?>[] getKeyFieldTypes() {
+ TypeInformation<?>[] fieldTypes = new TypeInformation[keyFields.size()];
+ for (int i = 0; i < keyFields.size(); i++) {
+ fieldTypes[i] = keyFields.get(i).getType();
+ }
+ return fieldTypes;
+ }
+
+ @Override
+ public <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo) {
+
+ if (keyFields.size() != 1) {
+ throw new InvalidProgramException("Custom partitioners can only be used with keys that have one key field.");
+ }
+
+ if (typeInfo == null) {
+ // try to extract key type from partitioner
+ try {
+ typeInfo = TypeExtractor.getPartitionerTypes(partitioner);
+ }
+ catch (Throwable t) {
+ // best effort check, so we ignore exceptions
+ }
+ }
+
+ // only check if type is known and not a generic type
+ if (typeInfo != null && !(typeInfo instanceof GenericTypeInfo)) {
+ // check equality of key and partitioner type
+ if (!keyType.equals(typeInfo)) {
+ throw new InvalidProgramException("The partitioner is incompatible with the key type. "
+ + "Partitioner type: " + typeInfo + " , key type: " + keyType);
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Key function (Type: " + keyType + ")";
+ }
+ }
+
+
+ /**
+ * Represents (nested) field access through string and integer-based keys
+ */
+ public static class ExpressionKeys<T> extends Keys<T> {
+
+ public static final String SELECT_ALL_CHAR = "*";
+ public static final String SELECT_ALL_CHAR_SCALA = "_";
+
+ // Flattened fields representing keys fields
+ private List<FlatFieldDescriptor> keyFields;
+
+ /**
+ * ExpressionKeys that is defined by the full data type.
+ */
+ public ExpressionKeys(TypeInformation<T> type) {
+ this(SELECT_ALL_CHAR, type);
+ }
+
+ /**
+ * Create int-based (non-nested) field position keys on a tuple type.
+ */
+ public ExpressionKeys(int keyPosition, TypeInformation<T> type) {
+ this(new int[]{keyPosition}, type, false);
+ }
+
+ /**
+ * Create int-based (non-nested) field position keys on a tuple type.
+ */
+ public ExpressionKeys(int[] keyPositions, TypeInformation<T> type) {
+ this(keyPositions, type, false);
+ }
+
+ /**
+ * Create int-based (non-nested) field position keys on a tuple type.
+ */
+ public ExpressionKeys(int[] keyPositions, TypeInformation<T> type, boolean allowEmpty) {
+
+ if (!type.isTupleType() || !(type instanceof CompositeType)) {
+ throw new InvalidProgramException("Specifying keys via field positions is only valid " +
+ "for tuple data types. Type: " + type);
+ }
+ if (type.getArity() == 0) {
+ throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity());
+ }
+ if (!allowEmpty && (keyPositions == null || keyPositions.length == 0)) {
+ throw new IllegalArgumentException("The grouping fields must not be empty.");
+ }
+
+ this.keyFields = new ArrayList<>();
+
+ if (keyPositions == null || keyPositions.length == 0) {
+ // use all tuple fields as key fields
+ keyPositions = createIncrIntArray(type.getArity());
+ } else {
+ rangeCheckFields(keyPositions, type.getArity() - 1);
+ }
+ Preconditions.checkArgument(keyPositions.length > 0, "Grouping fields can not be empty at this point");
+
+ // extract key field types
+ CompositeType<T> cType = (CompositeType<T>)type;
+ this.keyFields = new ArrayList<>(type.getTotalFields());
+
+ // for each key position, find all (nested) field types
+ String[] fieldNames = cType.getFieldNames();
+ ArrayList<FlatFieldDescriptor> tmpList = new ArrayList<>();
+ for (int keyPos : keyPositions) {
+ tmpList.clear();
+ // get all flat fields
+ cType.getFlatFields(fieldNames[keyPos], 0, tmpList);
+ // check if fields are of key type
+ for(FlatFieldDescriptor ffd : tmpList) {
+ if(!ffd.getType().isKeyType()) {
+ throw new InvalidProgramException("This type (" + ffd.getType() + ") cannot be used as key.");
+ }
+ }
+ this.keyFields.addAll(tmpList);
+ }
+ }
+
+ /**
+ * Create String-based (nested) field expression keys on a composite type.
+ */
+ public ExpressionKeys(String keyExpression, TypeInformation<T> type) {
+ this(new String[]{keyExpression}, type);
+ }
+
+ /**
+ * Create String-based (nested) field expression keys on a composite type.
+ */
+ public ExpressionKeys(String[] keyExpressions, TypeInformation<T> type) {
+ Preconditions.checkNotNull(keyExpressions, "Field expression cannot be null.");
+
+ this.keyFields = new ArrayList<>(keyExpressions.length);
+
+ if (type instanceof CompositeType){
+ CompositeType<T> cType = (CompositeType<T>) type;
+
+ // extract the keys on their flat position
+ for (String keyExpr : keyExpressions) {
+ if (keyExpr == null) {
+ throw new InvalidProgramException("Expression key may not be null.");
+ }
+ // strip off whitespace
+ keyExpr = keyExpr.trim();
+
+ List<FlatFieldDescriptor> flatFields = cType.getFlatFields(keyExpr);
+
+ if (flatFields.size() == 0) {
+ throw new InvalidProgramException("Unable to extract key from expression '" + keyExpr + "' on key " + cType);
+ }
+ // check if all nested fields can be used as keys
+ for (FlatFieldDescriptor field : flatFields) {
+ if (!field.getType().isKeyType()) {
+ throw new InvalidProgramException("This type (" + field.getType() + ") cannot be used as key.");
+ }
+ }
+ // add flat fields to key fields
+ keyFields.addAll(flatFields);
+ }
+ }
+ else {
+ if (!type.isKeyType()) {
+ throw new InvalidProgramException("This type (" + type + ") cannot be used as key.");
+ }
+
+ // check that all key expressions are valid
+ for (String keyExpr : keyExpressions) {
+ if (keyExpr == null) {
+ throw new InvalidProgramException("Expression key may not be null.");
+ }
+ // strip off whitespace
+ keyExpr = keyExpr.trim();
+ // check that full type is addressed
+ if (!(SELECT_ALL_CHAR.equals(keyExpr) || SELECT_ALL_CHAR_SCALA.equals(keyExpr))) {
+ throw new InvalidProgramException(
+ "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for non-composite types.");
+ }
+ // add full type as key
+ keyFields.add(new FlatFieldDescriptor(0, type));
+ }
+ }
+ }
+
+ @Override
+ public int getNumberOfKeyFields() {
+ if(keyFields == null) {
+ return 0;
+ }
+ return keyFields.size();
+ }
+
+ @Override
+ public int[] computeLogicalKeyPositions() {
+ int[] logicalKeys = new int[keyFields.size()];
+ for (int i = 0; i < keyFields.size(); i++) {
+ logicalKeys[i] = keyFields.get(i).getPosition();
+ }
+ return logicalKeys;
+ }
+
+ @Override
+ protected TypeInformation<?>[] getKeyFieldTypes() {
+ TypeInformation<?>[] fieldTypes = new TypeInformation[keyFields.size()];
+ for (int i = 0; i < keyFields.size(); i++) {
+ fieldTypes[i] = keyFields.get(i).getType();
+ }
+ return fieldTypes;
+ }
+
+ @Override
+ public <E> void validateCustomPartitioner(Partitioner<E> partitioner, TypeInformation<E> typeInfo) {
+
+ if (keyFields.size() != 1) {
+ throw new InvalidProgramException("Custom partitioners can only be used with keys that have one key field.");
+ }
+
+ if (typeInfo == null) {
+ // try to extract key type from partitioner
+ try {
+ typeInfo = TypeExtractor.getPartitionerTypes(partitioner);
+ }
+ catch (Throwable t) {
+ // best effort check, so we ignore exceptions
+ }
+ }
+
+ if (typeInfo != null && !(typeInfo instanceof GenericTypeInfo)) {
+ // only check type compatibility if type is known and not a generic type
+
+ TypeInformation<?> keyType = keyFields.get(0).getType();
+ if (!keyType.equals(typeInfo)) {
+ throw new InvalidProgramException("The partitioner is incompatible with the key type. "
+ + "Partitioner type: " + typeInfo + " , key type: " + keyType);
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ Joiner join = Joiner.on('.');
+ return "ExpressionKeys: " + join.join(keyFields);
+ }
+
+ public static boolean isSortKey(int fieldPos, TypeInformation<?> type) {
+
+ if (!type.isTupleType() || !(type instanceof CompositeType)) {
+ throw new InvalidProgramException("Specifying keys via field positions is only valid " +
+ "for tuple data types. Type: " + type);
+ }
+ if (type.getArity() == 0) {
+ throw new InvalidProgramException("Tuple size must be greater than 0. Size: " + type.getArity());
+ }
+
+ if(fieldPos < 0 || fieldPos >= type.getArity()) {
+ throw new IndexOutOfBoundsException("Tuple position is out of range: " + fieldPos);
+ }
+
+ TypeInformation<?> sortKeyType = ((CompositeType<?>)type).getTypeAt(fieldPos);
+ return sortKeyType.isSortKeyType();
+ }
+
+ public static boolean isSortKey(String fieldExpr, TypeInformation<?> type) {
+
+ TypeInformation<?> sortKeyType;
+
+ fieldExpr = fieldExpr.trim();
+ if (SELECT_ALL_CHAR.equals(fieldExpr) || SELECT_ALL_CHAR_SCALA.equals(fieldExpr)) {
+ sortKeyType = type;
+ }
+ else {
+ if (type instanceof CompositeType) {
+ sortKeyType = ((CompositeType<?>) type).getTypeAt(fieldExpr);
+ }
+ else {
+ throw new InvalidProgramException(
+ "Field expression must be equal to '" + SELECT_ALL_CHAR + "' or '" + SELECT_ALL_CHAR_SCALA + "' for atomic types.");
+ }
+ }
+
+ return sortKeyType.isSortKeyType();
+ }
+
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+
+
+ // --------------------------------------------------------------------------------------------
+ // Utilities
+ // --------------------------------------------------------------------------------------------
+
+
+ private static int[] createIncrIntArray(int numKeys) {
+ int[] keyFields = new int[numKeys];
+ for (int i = 0; i < numKeys; i++) {
+ keyFields[i] = i;
+ }
+ return keyFields;
+ }
+
+ private static void rangeCheckFields(int[] fields, int maxAllowedField) {
+
+ for (int f : fields) {
+ if (f < 0 || f > maxAllowedField) {
+ throw new IndexOutOfBoundsException("Tuple position is out of range: " + f);
+ }
+ }
+ }
+
+ public static class IncompatibleKeysException extends Exception {
+ private static final long serialVersionUID = 1L;
+ public static final String SIZE_MISMATCH_MESSAGE = "The number of specified keys is different.";
+
+ public IncompatibleKeysException(String message) {
+ super(message);
+ }
+
+ public IncompatibleKeysException(TypeInformation<?> typeInformation, TypeInformation<?> typeInformation2) {
+ super(typeInformation+" and "+typeInformation2+" are not compatible");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/functions/KeySelector.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/functions/KeySelector.java b/flink-core/src/main/java/org/apache/flink/api/java/functions/KeySelector.java
new file mode 100644
index 0000000..3d06c59
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/functions/KeySelector.java
@@ -0,0 +1,63 @@
+/*
+ * 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.java.functions;
+
+import org.apache.flink.api.common.functions.Function;
+
+import java.io.Serializable;
+
+/**
+ * The {@link KeySelector} allows to use arbitrary objects for operations such as
+ * reduce, reduceGroup, join, coGoup, etc.
+ *
+ * The extractor takes an object and returns the key for that object.
+ *
+ * @param <IN> Type of objects to extract the key from.
+ * @param <KEY> Type of key.
+ */
+public interface KeySelector<IN, KEY> extends Function, Serializable {
+
+ /**
+ * User-defined function that extracts the key from an arbitrary object.
+ *
+ * For example for a class:
+ * <pre>
+ * public class Word {
+ * String word;
+ * int count;
+ * }
+ * </pre>
+ * The key extractor could return the word as
+ * a key to group all Word objects by the String they contain.
+ *
+ * The code would look like this
+ * <pre>
+ * public String getKey(Word w) {
+ * return w.word;
+ * }
+ * </pre>
+ *
+ * @param value The object to get the key from.
+ * @return The extracted key.
+ *
+ * @throws Exception Throwing an exception will cause the execution of the respective task to fail,
+ * and trigger recovery or cancellation of the program.
+ */
+ KEY getKey(IN value) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java
new file mode 100644
index 0000000..5f74513
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroTypeInfo.java
@@ -0,0 +1,78 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.avro.specific.SpecificRecordBase;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Special type information to generate a special AvroTypeInfo for Avro POJOs (implementing SpecificRecordBase, the typed Avro POJOs)
+ *
+ * Proceeding: It uses a regular pojo type analysis and replaces all {@code GenericType<CharSequence>}
+ * with a {@code GenericType<avro.Utf8>}.
+ * All other types used by Avro are standard Java types.
+ * Only strings are represented as CharSequence fields and represented as Utf8 classes at runtime.
+ * CharSequence is not comparable. To make them nicely usable with field expressions, we replace them here
+ * by generic type infos containing Utf8 classes (which are comparable),
+ *
+ * This class is checked by the AvroPojoTest.
+ * @param <T>
+ */
+public class AvroTypeInfo<T extends SpecificRecordBase> extends PojoTypeInfo<T> {
+ public AvroTypeInfo(Class<T> typeClass) {
+ super(typeClass, generateFieldsFromAvroSchema(typeClass));
+ }
+
+ private static <T extends SpecificRecordBase> List<PojoField> generateFieldsFromAvroSchema(Class<T> typeClass) {
+ PojoTypeExtractor pte = new PojoTypeExtractor();
+ TypeInformation ti = pte.analyzePojo(typeClass, new ArrayList<Type>(), null, null, null);
+
+ if(!(ti instanceof PojoTypeInfo)) {
+ throw new IllegalStateException("Expecting type to be a PojoTypeInfo");
+ }
+ PojoTypeInfo pti = (PojoTypeInfo) ti;
+ List<PojoField> newFields = new ArrayList<PojoField>(pti.getTotalFields());
+
+ for(int i = 0; i < pti.getArity(); i++) {
+ PojoField f = pti.getPojoFieldAt(i);
+ TypeInformation newType = f.getTypeInformation();
+ // check if type is a CharSequence
+ if(newType instanceof GenericTypeInfo) {
+ if((newType).getTypeClass().equals(CharSequence.class)) {
+ // replace the type by a org.apache.avro.util.Utf8
+ newType = new GenericTypeInfo(org.apache.avro.util.Utf8.class);
+ }
+ }
+ PojoField newField = new PojoField(f.getField(), newType);
+ newFields.add(newField);
+ }
+ return newFields;
+ }
+
+ private static class PojoTypeExtractor extends TypeExtractor {
+ private PojoTypeExtractor() {
+ super();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java
new file mode 100644
index 0000000..74d850b
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EitherTypeInfo.java
@@ -0,0 +1,122 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.EitherSerializer;
+import org.apache.flink.types.Either;
+
+/**
+ * A {@link TypeInformation} for the {@link Either} type of the Java API.
+ *
+ * @param <L> the Left value type
+ * @param <R> the Right value type
+ */
+public class EitherTypeInfo<L, R> extends TypeInformation<Either<L, R>> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final TypeInformation<L> leftType;
+
+ private final TypeInformation<R> rightType;
+
+ public EitherTypeInfo(TypeInformation<L> leftType, TypeInformation<R> rightType) {
+ this.leftType = leftType;
+ this.rightType = rightType;
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return 1;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return 1;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<Either<L, R>> getTypeClass() {
+ return (Class<Either<L, R>>) (Class<?>) Either.class;
+ }
+
+ @Override
+ public boolean isKeyType() {
+ return false;
+ }
+
+ @Override
+ public TypeSerializer<Either<L, R>> createSerializer(ExecutionConfig config) {
+ return new EitherSerializer<L, R>(leftType.createSerializer(config),
+ rightType.createSerializer(config));
+ }
+
+ @Override
+ public String toString() {
+ return "Either <" + leftType.toString() + ", " + rightType.toString() + ">";
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof EitherTypeInfo) {
+ EitherTypeInfo<L, R> other = (EitherTypeInfo<L, R>) obj;
+
+ return other.canEqual(this) &&
+ leftType.equals(other.leftType) &&
+ rightType.equals(other.rightType);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 17 * leftType.hashCode() + rightType.hashCode();
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof EitherTypeInfo;
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public TypeInformation<L> getLeftType() {
+ return leftType;
+ }
+
+ public TypeInformation<R> getRightType() {
+ return rightType;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java
new file mode 100644
index 0000000..de59c36
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/EnumTypeInfo.java
@@ -0,0 +1,122 @@
+/*
+ * 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.java.typeutils;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.AtomicType;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.EnumComparator;
+import org.apache.flink.api.common.typeutils.base.EnumSerializer;
+
+/**
+ * A {@link TypeInformation} for java enumeration types.
+ *
+ * @param <T> The type represented by this type information.
+ */
+public class EnumTypeInfo<T extends Enum<T>> extends TypeInformation<T> implements AtomicType<T> {
+
+ private static final long serialVersionUID = 8936740290137178660L;
+
+ private final Class<T> typeClass;
+
+ public EnumTypeInfo(Class<T> typeClass) {
+ Preconditions.checkNotNull(typeClass, "Enum type class must not be null.");
+
+ if (!Enum.class.isAssignableFrom(typeClass) ) {
+ throw new IllegalArgumentException("EnumTypeInfo can only be used for subclasses of " + Enum.class.getName());
+ }
+
+ this.typeClass = typeClass;
+ }
+
+ @Override
+ public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
+ return new EnumComparator<T>(sortOrderAscending);
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return 1;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return 1;
+ }
+
+ @Override
+ public Class<T> getTypeClass() {
+ return this.typeClass;
+ }
+
+ @Override
+ public boolean isKeyType() {
+ return true;
+ }
+
+ @Override
+ public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
+ return new EnumSerializer<T>(typeClass);
+ }
+
+ // ------------------------------------------------------------------------
+ // Standard utils
+ // ------------------------------------------------------------------------
+
+ @Override
+ public String toString() {
+ return "EnumTypeInfo<" + typeClass.getName() + ">";
+ }
+
+ @Override
+ public int hashCode() {
+ return typeClass.hashCode();
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof EnumTypeInfo;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof EnumTypeInfo) {
+ @SuppressWarnings("unchecked")
+ EnumTypeInfo<T> enumTypeInfo = (EnumTypeInfo<T>) obj;
+
+ return enumTypeInfo.canEqual(this) &&
+ typeClass == enumTypeInfo.typeClass;
+ } else {
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java
new file mode 100644
index 0000000..7e7aa68
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/GenericTypeInfo.java
@@ -0,0 +1,116 @@
+/*
+ * 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.java.typeutils;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.AtomicType;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.GenericTypeComparator;
+import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
+
+
+public class GenericTypeInfo<T> extends TypeInformation<T> implements AtomicType<T> {
+
+ private static final long serialVersionUID = -7959114120287706504L;
+
+ private final Class<T> typeClass;
+
+ public GenericTypeInfo(Class<T> typeClass) {
+ this.typeClass = Preconditions.checkNotNull(typeClass);
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return 1;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return 1;
+ }
+
+ @Override
+ public Class<T> getTypeClass() {
+ return typeClass;
+ }
+
+ @Override
+ public boolean isKeyType() {
+ return Comparable.class.isAssignableFrom(typeClass);
+ }
+
+ @Override
+ public TypeSerializer<T> createSerializer(ExecutionConfig config) {
+ return new KryoSerializer<T>(this.typeClass, config);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
+ if (isKeyType()) {
+ @SuppressWarnings("rawtypes")
+ GenericTypeComparator comparator = new GenericTypeComparator(sortOrderAscending, createSerializer(executionConfig), this.typeClass);
+ return (TypeComparator<T>) comparator;
+ }
+
+ throw new UnsupportedOperationException("Types that do not implement java.lang.Comparable cannot be used as keys.");
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return typeClass.hashCode();
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof GenericTypeInfo;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof GenericTypeInfo) {
+ @SuppressWarnings("unchecked")
+ GenericTypeInfo<T> genericTypeInfo = (GenericTypeInfo<T>) obj;
+
+ return typeClass == genericTypeInfo.typeClass;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "GenericType<" + typeClass.getCanonicalName() + ">";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java
new file mode 100644
index 0000000..f8b4247
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/InputTypeConfigurable.java
@@ -0,0 +1,42 @@
+/*
+ * 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.java.typeutils;
+
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+
+/**
+ * {@link org.apache.flink.api.common.io.OutputFormat}s can implement this interface to be configured
+ * with the data type they will operate on. The method {@link #setInputType(org.apache.flink.api
+ * .common.typeinfo.TypeInformation, org.apache.flink.api.common.ExecutionConfig)} will be
+ * called when the output format is used with an output method such as
+ * {@link org.apache.flink.api.java.DataSet#output(org.apache.flink.api.common.io.OutputFormat)}.
+ */
+public interface InputTypeConfigurable {
+
+ /**
+ * Method that is called on an {@link org.apache.flink.api.common.io.OutputFormat} when it is passed to
+ * the DataSet's output method. May be used to configures the output format based on the data type.
+ *
+ * @param type The data type of the input.
+ * @param executionConfig
+ */
+ void setInputType(TypeInformation<?> type, ExecutionConfig executionConfig);
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java
new file mode 100644
index 0000000..1dd7f01
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/MissingTypeInfo.java
@@ -0,0 +1,121 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.functions.InvalidTypesException;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+
+/**
+ * A special type information signifying that the type extraction failed. It contains
+ * additional error information.
+ */
+public class MissingTypeInfo extends TypeInformation<InvalidTypesException> {
+
+ private static final long serialVersionUID = -4212082837126702723L;
+
+ private final String functionName;
+ private final InvalidTypesException typeException;
+
+
+ public MissingTypeInfo(String functionName) {
+ this(functionName, new InvalidTypesException("An unknown error occured."));
+ }
+
+ public MissingTypeInfo(String functionName, InvalidTypesException typeException) {
+ this.functionName = functionName;
+ this.typeException = typeException;
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public String getFunctionName() {
+ return functionName;
+ }
+
+ public InvalidTypesException getTypeException() {
+ return typeException;
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean isBasicType() {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+
+ @Override
+ public boolean isTupleType() {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+
+ @Override
+ public int getArity() {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+
+ @Override
+ public Class<InvalidTypesException> getTypeClass() {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+
+ @Override
+ public boolean isKeyType() {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+
+ @Override
+ public TypeSerializer<InvalidTypesException> createSerializer(ExecutionConfig executionConfig) {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "<" + functionName + ", " + typeException.getMessage() + ">";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof MissingTypeInfo) {
+ MissingTypeInfo missingTypeInfo = (MissingTypeInfo) obj;
+
+ return missingTypeInfo.canEqual(this) &&
+ functionName.equals(missingTypeInfo.functionName) &&
+ typeException.equals(missingTypeInfo.typeException);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * functionName.hashCode() + typeException.hashCode();
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof MissingTypeInfo;
+ }
+
+ @Override
+ public int getTotalFields() {
+ throw new UnsupportedOperationException("The missing type information cannot be used as a type information.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
new file mode 100644
index 0000000..150c976
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
@@ -0,0 +1,141 @@
+/*
+ * 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.java.typeutils;
+
+import java.lang.reflect.Array;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.GenericArraySerializer;
+
+public class ObjectArrayTypeInfo<T, C> extends TypeInformation<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> arrayType;
+ private final TypeInformation<C> componentInfo;
+
+ private ObjectArrayTypeInfo(Class<T> arrayType, TypeInformation<C> componentInfo) {
+ this.arrayType = Preconditions.checkNotNull(arrayType);
+ this.componentInfo = Preconditions.checkNotNull(componentInfo);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return 1;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return 1;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<T> getTypeClass() {
+ return arrayType;
+ }
+
+ public TypeInformation<C> getComponentInfo() {
+ return componentInfo;
+ }
+
+ @Override
+ public boolean isKeyType() {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
+ return (TypeSerializer<T>) new GenericArraySerializer<C>(
+ componentInfo.getTypeClass(),
+ componentInfo.createSerializer(executionConfig));
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName() + "<" + this.componentInfo + ">";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ObjectArrayTypeInfo) {
+ @SuppressWarnings("unchecked")
+ ObjectArrayTypeInfo<T, C> objectArrayTypeInfo = (ObjectArrayTypeInfo<T, C>)obj;
+
+ return objectArrayTypeInfo.canEqual(this) &&
+ arrayType == objectArrayTypeInfo.arrayType &&
+ componentInfo.equals(objectArrayTypeInfo.componentInfo);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof ObjectArrayTypeInfo;
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * this.arrayType.hashCode() + this.componentInfo.hashCode();
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static <T, C> ObjectArrayTypeInfo<T, C> getInfoFor(Class<T> arrayClass, TypeInformation<C> componentInfo) {
+ Preconditions.checkNotNull(arrayClass);
+ Preconditions.checkNotNull(componentInfo);
+ Preconditions.checkArgument(arrayClass.isArray(), "Class " + arrayClass + " must be an array.");
+
+ return new ObjectArrayTypeInfo<T, C>(arrayClass, componentInfo);
+ }
+
+ /**
+ * Creates a new {@link org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo} from a
+ * {@link TypeInformation} for the component type.
+ *
+ * <p>
+ * This must be used in cases where the complete type of the array is not available as a
+ * {@link java.lang.reflect.Type} or {@link java.lang.Class}.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T, C> ObjectArrayTypeInfo<T, C> getInfoFor(TypeInformation<C> componentInfo) {
+ Preconditions.checkNotNull(componentInfo);
+
+ return new ObjectArrayTypeInfo<T, C>(
+ (Class<T>)Array.newInstance(componentInfo.getTypeClass(), 0).getClass(),
+ componentInfo);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java
new file mode 100644
index 0000000..1b008c0
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoField.java
@@ -0,0 +1,108 @@
+/*
+ * 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.java.typeutils;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+
+/**
+ * Represent a field definition for {@link PojoTypeInfo} type of objects.
+ */
+public class PojoField implements Serializable {
+
+ private static final long serialVersionUID = 1975295846436559363L;
+
+ private transient Field field;
+ private final TypeInformation<?> type;
+
+ public PojoField(Field field, TypeInformation<?> type) {
+ this.field = Preconditions.checkNotNull(field);
+ this.type = Preconditions.checkNotNull(type);
+ }
+
+ public Field getField() {
+ return field;
+ }
+
+ public TypeInformation<?> getTypeInformation() {
+ return type;
+ }
+
+ private void writeObject(ObjectOutputStream out)
+ throws IOException, ClassNotFoundException {
+ out.defaultWriteObject();
+ out.writeObject(field.getDeclaringClass());
+ out.writeUTF(field.getName());
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ Class<?> clazz = (Class<?>)in.readObject();
+ String fieldName = in.readUTF();
+ field = null;
+ // try superclasses as well
+ while (clazz != null) {
+ try {
+ field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ break;
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ if (field == null) {
+ throw new RuntimeException("Class resolved at TaskManager is not compatible with class read during Plan setup."
+ + " (" + fieldName + ")");
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "PojoField " + field.getDeclaringClass() + "." + field.getName() + " (" + type + ")";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof PojoField) {
+ PojoField other = (PojoField) obj;
+
+ return other.canEqual(this) && type.equals(other.type) &&
+ Objects.equals(field, other.field);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(field, type);
+ }
+
+ public boolean canEqual(Object obj) {
+ return obj instanceof PojoField;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
new file mode 100644
index 0000000..cc0d239
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/PojoTypeInfo.java
@@ -0,0 +1,406 @@
+/*
+ * 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.java.typeutils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.operators.Keys.ExpressionKeys;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.runtime.AvroSerializer;
+import org.apache.flink.api.java.typeutils.runtime.PojoComparator;
+import org.apache.flink.api.java.typeutils.runtime.PojoSerializer;
+
+import com.google.common.base.Joiner;
+import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer;
+
+/**
+ * TypeInformation for "Java Beans"-style types. Flink refers to them as POJOs,
+ * since the conditions are slightly different from Java Beans.
+ * A type is considered a FLink POJO type, if it fulfills the conditions below.
+ * <ul>
+ * <li>It is a public class, and standalone (not a non-static inner class)</li>
+ * <li>It has a public no-argument constructor.</li>
+ * <li>All fields are either public, or have public getters and setters.</li>
+ * </ul>
+ *
+ * @param <T> The type represented by this type information.
+ */
+public class PojoTypeInfo<T> extends CompositeType<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final static String REGEX_FIELD = "[\\p{L}_\\$][\\p{L}\\p{Digit}_\\$]*";
+ private final static String REGEX_NESTED_FIELDS = "("+REGEX_FIELD+")(\\.(.+))?";
+ private final static String REGEX_NESTED_FIELDS_WILDCARD = REGEX_NESTED_FIELDS
+ +"|\\"+ExpressionKeys.SELECT_ALL_CHAR
+ +"|\\"+ExpressionKeys.SELECT_ALL_CHAR_SCALA;
+
+ private static final Pattern PATTERN_NESTED_FIELDS = Pattern.compile(REGEX_NESTED_FIELDS);
+ private static final Pattern PATTERN_NESTED_FIELDS_WILDCARD = Pattern.compile(REGEX_NESTED_FIELDS_WILDCARD);
+
+ private final PojoField[] fields;
+
+ private final int totalFields;
+
+ public PojoTypeInfo(Class<T> typeClass, List<PojoField> fields) {
+ super(typeClass);
+
+ Preconditions.checkArgument(Modifier.isPublic(typeClass.getModifiers()),
+ "POJO " + typeClass + " is not public");
+
+ this.fields = fields.toArray(new PojoField[fields.size()]);
+
+ Arrays.sort(this.fields, new Comparator<PojoField>() {
+ @Override
+ public int compare(PojoField o1, PojoField o2) {
+ return o1.getField().getName().compareTo(o2.getField().getName());
+ }
+ });
+
+ int counterFields = 0;
+
+ for(PojoField field : fields) {
+ counterFields += field.getTypeInformation().getTotalFields();
+ }
+
+ totalFields = counterFields;
+ }
+
+ @Override
+ public boolean isBasicType() {
+ return false;
+ }
+
+
+ @Override
+ public boolean isTupleType() {
+ return false;
+ }
+
+ @Override
+ public int getArity() {
+ return fields.length;
+ }
+
+ @Override
+ public int getTotalFields() {
+ return totalFields;
+ }
+
+ @Override
+ public boolean isSortKeyType() {
+ // Support for sorting POJOs that implement Comparable is not implemented yet.
+ // Since the order of fields in a POJO type is not well defined, sorting on fields
+ // gives only some undefined order.
+ return false;
+ }
+
+
+ @Override
+ public void getFlatFields(String fieldExpression, int offset, List<FlatFieldDescriptor> result) {
+
+ Matcher matcher = PATTERN_NESTED_FIELDS_WILDCARD.matcher(fieldExpression);
+ if(!matcher.matches()) {
+ throw new InvalidFieldReferenceException("Invalid POJO field reference \""+fieldExpression+"\".");
+ }
+
+ String field = matcher.group(0);
+ if(field.equals(ExpressionKeys.SELECT_ALL_CHAR) || field.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
+ // handle select all
+ int keyPosition = 0;
+ for(PojoField pField : fields) {
+ if(pField.getTypeInformation() instanceof CompositeType) {
+ CompositeType<?> cType = (CompositeType<?>)pField.getTypeInformation();
+ cType.getFlatFields(String.valueOf(ExpressionKeys.SELECT_ALL_CHAR), offset + keyPosition, result);
+ keyPosition += cType.getTotalFields()-1;
+ } else {
+ result.add(
+ new NamedFlatFieldDescriptor(
+ pField.getField().getName(),
+ offset + keyPosition,
+ pField.getTypeInformation()));
+ }
+ keyPosition++;
+ }
+ return;
+ } else {
+ field = matcher.group(1);
+ }
+
+ // get field
+ int fieldPos = -1;
+ TypeInformation<?> fieldType = null;
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].getField().getName().equals(field)) {
+ fieldPos = i;
+ fieldType = fields[i].getTypeInformation();
+ break;
+ }
+ }
+ if (fieldPos == -1) {
+ throw new InvalidFieldReferenceException("Unable to find field \""+field+"\" in type "+this+".");
+ }
+ String tail = matcher.group(3);
+ if(tail == null) {
+ if(fieldType instanceof CompositeType) {
+ // forward offset
+ for(int i=0; i<fieldPos; i++) {
+ offset += this.getTypeAt(i).getTotalFields();
+ }
+ // add all fields of composite type
+ ((CompositeType<?>) fieldType).getFlatFields("*", offset, result);
+ } else {
+ // we found the field to add
+ // compute flat field position by adding skipped fields
+ int flatFieldPos = offset;
+ for(int i=0; i<fieldPos; i++) {
+ flatFieldPos += this.getTypeAt(i).getTotalFields();
+ }
+ result.add(new FlatFieldDescriptor(flatFieldPos, fieldType));
+ }
+ } else {
+ if(fieldType instanceof CompositeType<?>) {
+ // forward offset
+ for(int i=0; i<fieldPos; i++) {
+ offset += this.getTypeAt(i).getTotalFields();
+ }
+ ((CompositeType<?>) fieldType).getFlatFields(tail, offset, result);
+ } else {
+ throw new InvalidFieldReferenceException("Nested field expression \""+tail+"\" not possible on atomic type "+fieldType+".");
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
+
+ Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
+ if(!matcher.matches()) {
+ if (fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR) || fieldExpression.startsWith(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
+ throw new InvalidFieldReferenceException("Wildcard expressions are not allowed here.");
+ } else {
+ throw new InvalidFieldReferenceException("Invalid format of POJO field expression \""+fieldExpression+"\".");
+ }
+ }
+
+ String field = matcher.group(1);
+ // get field
+ int fieldPos = -1;
+ TypeInformation<?> fieldType = null;
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].getField().getName().equals(field)) {
+ fieldPos = i;
+ fieldType = fields[i].getTypeInformation();
+ break;
+ }
+ }
+ if (fieldPos == -1) {
+ throw new InvalidFieldReferenceException("Unable to find field \""+field+"\" in type "+this+".");
+ }
+
+ String tail = matcher.group(3);
+ if(tail == null) {
+ // we found the type
+ return (TypeInformation<X>) fieldType;
+ } else {
+ if(fieldType instanceof CompositeType<?>) {
+ return ((CompositeType<?>) fieldType).getTypeAt(tail);
+ } else {
+ throw new InvalidFieldReferenceException("Nested field expression \""+tail+"\" not possible on atomic type "+fieldType+".");
+ }
+ }
+ }
+
+ @Override
+ public <X> TypeInformation<X> getTypeAt(int pos) {
+ if (pos < 0 || pos >= this.fields.length) {
+ throw new IndexOutOfBoundsException();
+ }
+ @SuppressWarnings("unchecked")
+ TypeInformation<X> typed = (TypeInformation<X>) fields[pos].getTypeInformation();
+ return typed;
+ }
+
+ @Override
+ protected TypeComparatorBuilder<T> createTypeComparatorBuilder() {
+ return new PojoTypeComparatorBuilder();
+ }
+
+ // used for testing. Maybe use mockito here
+ public PojoField getPojoFieldAt(int pos) {
+ if (pos < 0 || pos >= this.fields.length) {
+ throw new IndexOutOfBoundsException();
+ }
+ return this.fields[pos];
+ }
+
+ public String[] getFieldNames() {
+ String[] result = new String[fields.length];
+ for (int i = 0; i < fields.length; i++) {
+ result[i] = fields[i].getField().getName();
+ }
+ return result;
+ }
+
+ @Override
+ public int getFieldIndex(String fieldName) {
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].getField().getName().equals(fieldName)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public TypeSerializer<T> createSerializer(ExecutionConfig config) {
+ if(config.isForceKryoEnabled()) {
+ return new KryoSerializer<T>(getTypeClass(), config);
+ }
+ if(config.isForceAvroEnabled()) {
+ return new AvroSerializer<T>(getTypeClass());
+ }
+
+ TypeSerializer<?>[] fieldSerializers = new TypeSerializer<?>[fields.length ];
+ Field[] reflectiveFields = new Field[fields.length];
+
+ for (int i = 0; i < fields.length; i++) {
+ fieldSerializers[i] = fields[i].getTypeInformation().createSerializer(config);
+ reflectiveFields[i] = fields[i].getField();
+ }
+
+ return new PojoSerializer<T>(getTypeClass(), fieldSerializers, reflectiveFields, config);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof PojoTypeInfo) {
+ @SuppressWarnings("unchecked")
+ PojoTypeInfo<T> pojoTypeInfo = (PojoTypeInfo<T>)obj;
+
+ return pojoTypeInfo.canEqual(this) &&
+ super.equals(pojoTypeInfo) &&
+ Arrays.equals(fields, pojoTypeInfo.fields) &&
+ totalFields == pojoTypeInfo.totalFields;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * (31 * Arrays.hashCode(fields) + totalFields) + super.hashCode();
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof PojoTypeInfo;
+ }
+
+ @Override
+ public String toString() {
+ List<String> fieldStrings = new ArrayList<String>();
+ for (PojoField field : fields) {
+ fieldStrings.add(field.getField().getName() + ": " + field.getTypeInformation().toString());
+ }
+ return "PojoType<" + getTypeClass().getName()
+ + ", fields = [" + Joiner.on(", ").join(fieldStrings) + "]"
+ + ">";
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ private class PojoTypeComparatorBuilder implements TypeComparatorBuilder<T> {
+
+ private ArrayList<TypeComparator> fieldComparators;
+ private ArrayList<Field> keyFields;
+
+ public PojoTypeComparatorBuilder() {
+ fieldComparators = new ArrayList<TypeComparator>();
+ keyFields = new ArrayList<Field>();
+ }
+
+
+ @Override
+ public void initializeTypeComparatorBuilder(int size) {
+ fieldComparators.ensureCapacity(size);
+ keyFields.ensureCapacity(size);
+ }
+
+ @Override
+ public void addComparatorField(int fieldId, TypeComparator<?> comparator) {
+ fieldComparators.add(comparator);
+ keyFields.add(fields[fieldId].getField());
+ }
+
+ @Override
+ public TypeComparator<T> createTypeComparator(ExecutionConfig config) {
+ Preconditions.checkState(
+ keyFields.size() > 0,
+ "No keys were defined for the PojoTypeComparatorBuilder.");
+
+ Preconditions.checkState(
+ fieldComparators.size() > 0,
+ "No type comparators were defined for the PojoTypeComparatorBuilder.");
+
+ Preconditions.checkState(
+ keyFields.size() == fieldComparators.size(),
+ "Number of key fields and field comparators is not equal.");
+
+ return new PojoComparator<T>(
+ keyFields.toArray(new Field[keyFields.size()]),
+ fieldComparators.toArray(new TypeComparator[fieldComparators.size()]),
+ createSerializer(config),
+ getTypeClass());
+ }
+ }
+
+ public static class NamedFlatFieldDescriptor extends FlatFieldDescriptor {
+
+ private String fieldName;
+
+ public NamedFlatFieldDescriptor(String name, int keyPosition, TypeInformation<?> type) {
+ super(keyPosition, type);
+ this.fieldName = name;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ @Override
+ public String toString() {
+ return "NamedFlatFieldDescriptor [name="+fieldName+" position="+getPosition()+" typeInfo="+getType()+"]";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java
new file mode 100644
index 0000000..5e0cbed
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/ResultTypeQueryable.java
@@ -0,0 +1,37 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+
+/**
+ * This interface can be implemented by functions and input formats to tell the framework
+ * about their produced data type. This method acts as an alternative to the reflection analysis
+ * that is otherwise performed and is useful in situations where the produced data type may vary
+ * depending on parametrization.
+ */
+public interface ResultTypeQueryable<T> {
+
+ /**
+ * Gets the data type (as a {@link TypeInformation}) produced by this function or input format.
+ *
+ * @return The data type produced by this function or input format.
+ */
+ TypeInformation<T> getProducedType();
+}
[17/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeExtractionTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeExtractionTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeExtractionTest.java
new file mode 100644
index 0000000..bc11848
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeExtractionTest.java
@@ -0,0 +1,812 @@
+/*
+ * 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.java.typeutils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
+import org.apache.flink.api.java.tuple.Tuple1;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.api.java.typeutils.TypeInfoParserTest.MyWritable;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.collect.HashMultiset;
+
+/**
+ * Pojo Type tests
+ *
+ * A Pojo is a bean-style class with getters, setters and empty ctor
+ * OR a class with all fields public (or for every private field, there has to be a public getter/setter)
+ * everything else is a generic type (that can't be used for field selection)
+ */
+public class PojoTypeExtractionTest {
+
+ public static class HasDuplicateField extends WC {
+ @SuppressWarnings("unused")
+ private int count; // duplicate
+ }
+
+ @Test(expected=RuntimeException.class)
+ public void testDuplicateFieldException() {
+ TypeExtractor.createTypeInfo(HasDuplicateField.class);
+ }
+
+ // test with correct pojo types
+ public static class WC { // is a pojo
+ public ComplexNestedClass complex; // is a pojo
+ private int count; // is a BasicType
+
+ public WC() {
+ }
+ public int getCount() {
+ return count;
+ }
+ public void setCount(int c) {
+ this.count = c;
+ }
+ }
+ public static class ComplexNestedClass { // pojo
+ public static int ignoreStaticField;
+ public transient int ignoreTransientField;
+ public Date date; // generic type
+ public Integer someNumberWithÜnicödeNäme; // BasicType
+ public float someFloat; // BasicType
+ public Tuple3<Long, Long, String> word; //Tuple Type with three basic types
+ public Object nothing; // generic type
+ public MyWritable hadoopCitizen; // writableType
+ public List<String> collection;
+ }
+
+ // all public test
+ public static class AllPublic extends ComplexNestedClass {
+ public ArrayList<String> somethingFancy; // generic type
+ public HashMultiset<Integer> fancyIds; // generic type
+ public String[] fancyArray; // generic type
+ }
+
+ public static class ParentSettingGenerics extends PojoWithGenerics<Integer, Long> {
+ public String field3;
+ }
+ public static class PojoWithGenerics<T1, T2> {
+ public int key;
+ public T1 field1;
+ public T2 field2;
+ }
+
+ public static class ComplexHierarchyTop extends ComplexHierarchy<Tuple1<String>> {}
+ public static class ComplexHierarchy<T> extends PojoWithGenerics<FromTuple,T> {}
+
+ // extends from Tuple and adds a field
+ public static class FromTuple extends Tuple3<String, String, Long> {
+ private static final long serialVersionUID = 1L;
+ public int special;
+ }
+
+ public static class IncorrectPojo {
+ private int isPrivate;
+ public int getIsPrivate() {
+ return isPrivate;
+ }
+ // setter is missing (intentional)
+ }
+
+ // correct pojo
+ public static class BeanStylePojo {
+ public String abc;
+ private int field;
+ public int getField() {
+ return this.field;
+ }
+ public void setField(int f) {
+ this.field = f;
+ }
+ }
+ public static class WrongCtorPojo {
+ public int a;
+ public WrongCtorPojo(int a) {
+ this.a = a;
+ }
+ }
+
+ public static class PojoWithGenericFields {
+ private Collection<String> users;
+ private boolean favorited;
+
+ public boolean isFavorited() {
+ return favorited;
+ }
+
+ public void setFavorited(boolean favorited) {
+ this.favorited = favorited;
+ }
+
+ public Collection<String> getUsers() {
+ return users;
+ }
+
+ public void setUsers(Collection<String> users) {
+ this.users = users;
+ }
+ }
+ @Test
+ public void testPojoWithGenericFields() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(PojoWithGenericFields.class);
+
+ Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
+ }
+
+
+ // in this test, the location of the getters and setters is mixed across the type hierarchy.
+ public static class TypedPojoGetterSetterCheck extends GenericPojoGetterSetterCheck<String> {
+ public void setPackageProtected(String in) {
+ this.packageProtected = in;
+ }
+ }
+ public static class GenericPojoGetterSetterCheck<T> {
+ T packageProtected;
+ public T getPackageProtected() {
+ return packageProtected;
+ }
+ }
+
+ @Test
+ public void testIncorrectPojos() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(IncorrectPojo.class);
+ Assert.assertTrue(typeForClass instanceof GenericTypeInfo<?>);
+
+ typeForClass = TypeExtractor.createTypeInfo(WrongCtorPojo.class);
+ Assert.assertTrue(typeForClass instanceof GenericTypeInfo<?>);
+ }
+
+ @Test
+ public void testCorrectPojos() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(BeanStylePojo.class);
+ Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
+
+ typeForClass = TypeExtractor.createTypeInfo(TypedPojoGetterSetterCheck.class);
+ Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
+ }
+
+ @Test
+ public void testPojoWC() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(WC.class);
+ checkWCPojoAsserts(typeForClass);
+
+ WC t = new WC();
+ t.complex = new ComplexNestedClass();
+ TypeInformation<?> typeForObject = TypeExtractor.getForObject(t);
+ checkWCPojoAsserts(typeForObject);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void checkWCPojoAsserts(TypeInformation<?> typeInfo) {
+ Assert.assertFalse(typeInfo.isBasicType());
+ Assert.assertFalse(typeInfo.isTupleType());
+ Assert.assertEquals(10, typeInfo.getTotalFields());
+ Assert.assertTrue(typeInfo instanceof PojoTypeInfo);
+ PojoTypeInfo<?> pojoType = (PojoTypeInfo<?>) typeInfo;
+
+ List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
+ String[] fields = {"count",
+ "complex.date",
+ "complex.hadoopCitizen",
+ "complex.collection",
+ "complex.nothing",
+ "complex.someFloat",
+ "complex.someNumberWithÜnicödeNäme",
+ "complex.word.f0",
+ "complex.word.f1",
+ "complex.word.f2"};
+ int[] positions = {9,
+ 1,
+ 2,
+ 0,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8};
+ Assert.assertEquals(fields.length, positions.length);
+ for(int i = 0; i < fields.length; i++) {
+ pojoType.getFlatFields(fields[i], 0, ffd);
+ Assert.assertEquals("Too many keys returned", 1, ffd.size());
+ Assert.assertEquals("position of field "+fields[i]+" wrong", positions[i], ffd.get(0).getPosition());
+ ffd.clear();
+ }
+
+ pojoType.getFlatFields("complex.word.*", 0, ffd);
+ Assert.assertEquals(3, ffd.size());
+ // check if it returns 5,6,7
+ for(FlatFieldDescriptor ffdE : ffd) {
+ final int pos = ffdE.getPosition();
+ Assert.assertTrue(pos <= 8 );
+ Assert.assertTrue(6 <= pos );
+ if(pos == 6) {
+ Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 7) {
+ Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 8) {
+ Assert.assertEquals(String.class, ffdE.getType().getTypeClass());
+ }
+ }
+ ffd.clear();
+
+ // scala style full tuple selection for pojos
+ pojoType.getFlatFields("complex.word._", 0, ffd);
+ Assert.assertEquals(3, ffd.size());
+ ffd.clear();
+
+ pojoType.getFlatFields("complex.*", 0, ffd);
+ Assert.assertEquals(9, ffd.size());
+ // check if it returns 0-7
+ for(FlatFieldDescriptor ffdE : ffd) {
+ final int pos = ffdE.getPosition();
+ Assert.assertTrue(ffdE.getPosition() <= 8 );
+ Assert.assertTrue(0 <= ffdE.getPosition() );
+
+ if(pos == 0) {
+ Assert.assertEquals(List.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 1) {
+ Assert.assertEquals(Date.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 2) {
+ Assert.assertEquals(MyWritable.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 3) {
+ Assert.assertEquals(Object.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 4) {
+ Assert.assertEquals(Float.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 5) {
+ Assert.assertEquals(Integer.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 6) {
+ Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 7) {
+ Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 8) {
+ Assert.assertEquals(String.class, ffdE.getType().getTypeClass());
+ }
+ if(pos == 9) {
+ Assert.assertEquals(Integer.class, ffdE.getType().getTypeClass());
+ }
+ }
+ ffd.clear();
+
+ pojoType.getFlatFields("*", 0, ffd);
+ Assert.assertEquals(10, ffd.size());
+ // check if it returns 0-8
+ for(FlatFieldDescriptor ffdE : ffd) {
+ Assert.assertTrue(ffdE.getPosition() <= 9 );
+ Assert.assertTrue(0 <= ffdE.getPosition() );
+ if(ffdE.getPosition() == 9) {
+ Assert.assertEquals(Integer.class, ffdE.getType().getTypeClass());
+ }
+ }
+ ffd.clear();
+
+ TypeInformation<?> typeComplexNested = pojoType.getTypeAt(0); // ComplexNestedClass complex
+ Assert.assertTrue(typeComplexNested instanceof PojoTypeInfo);
+
+ Assert.assertEquals(7, typeComplexNested.getArity());
+ Assert.assertEquals(9, typeComplexNested.getTotalFields());
+ PojoTypeInfo<?> pojoTypeComplexNested = (PojoTypeInfo<?>) typeComplexNested;
+
+ boolean dateSeen = false, intSeen = false, floatSeen = false,
+ tupleSeen = false, objectSeen = false, writableSeen = false, collectionSeen = false;
+ for(int i = 0; i < pojoTypeComplexNested.getArity(); i++) {
+ PojoField field = pojoTypeComplexNested.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("date")) {
+ if(dateSeen) {
+ Assert.fail("already seen");
+ }
+ dateSeen = true;
+ Assert.assertEquals(BasicTypeInfo.DATE_TYPE_INFO, field.getTypeInformation());
+ Assert.assertEquals(Date.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("someNumberWithÜnicödeNäme")) {
+ if(intSeen) {
+ Assert.fail("already seen");
+ }
+ intSeen = true;
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ Assert.assertEquals(Integer.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("someFloat")) {
+ if(floatSeen) {
+ Assert.fail("already seen");
+ }
+ floatSeen = true;
+ Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, field.getTypeInformation());
+ Assert.assertEquals(Float.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("word")) {
+ if(tupleSeen) {
+ Assert.fail("already seen");
+ }
+ tupleSeen = true;
+ Assert.assertTrue(field.getTypeInformation() instanceof TupleTypeInfo<?>);
+ Assert.assertEquals(Tuple3.class, field.getTypeInformation().getTypeClass());
+ // do some more advanced checks on the tuple
+ TupleTypeInfo<?> tupleTypeFromComplexNested = (TupleTypeInfo<?>) field.getTypeInformation();
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tupleTypeFromComplexNested.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tupleTypeFromComplexNested.getTypeAt(1));
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tupleTypeFromComplexNested.getTypeAt(2));
+ } else if(name.equals("nothing")) {
+ if(objectSeen) {
+ Assert.fail("already seen");
+ }
+ objectSeen = true;
+ Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.getTypeInformation());
+ Assert.assertEquals(Object.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("hadoopCitizen")) {
+ if(writableSeen) {
+ Assert.fail("already seen");
+ }
+ writableSeen = true;
+ Assert.assertEquals(new WritableTypeInfo<MyWritable>(MyWritable.class), field.getTypeInformation());
+ Assert.assertEquals(MyWritable.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("collection")) {
+ if(collectionSeen) {
+ Assert.fail("already seen");
+ }
+ collectionSeen = true;
+ Assert.assertEquals(new GenericTypeInfo(List.class), field.getTypeInformation());
+
+ } else {
+ Assert.fail("field "+field+" is not expected");
+ }
+ }
+ Assert.assertTrue("Field was not present", dateSeen);
+ Assert.assertTrue("Field was not present", intSeen);
+ Assert.assertTrue("Field was not present", floatSeen);
+ Assert.assertTrue("Field was not present", tupleSeen);
+ Assert.assertTrue("Field was not present", objectSeen);
+ Assert.assertTrue("Field was not present", writableSeen);
+ Assert.assertTrue("Field was not present", collectionSeen);
+
+ TypeInformation<?> typeAtOne = pojoType.getTypeAt(1); // int count
+ Assert.assertTrue(typeAtOne instanceof BasicTypeInfo);
+
+ Assert.assertEquals(typeInfo.getTypeClass(), WC.class);
+ Assert.assertEquals(typeInfo.getArity(), 2);
+ }
+
+ @Test
+ public void testPojoAllPublic() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(AllPublic.class);
+ checkAllPublicAsserts(typeForClass);
+
+ TypeInformation<?> typeForObject = TypeExtractor.getForObject(new AllPublic() );
+ checkAllPublicAsserts(typeForObject);
+ }
+
+ private void checkAllPublicAsserts(TypeInformation<?> typeInformation) {
+ Assert.assertTrue(typeInformation instanceof PojoTypeInfo);
+ Assert.assertEquals(10, typeInformation.getArity());
+ Assert.assertEquals(12, typeInformation.getTotalFields());
+ // check if the three additional fields are identified correctly
+ boolean arrayListSeen = false, multisetSeen = false, strArraySeen = false;
+ PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeInformation;
+ for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
+ PojoField field = pojoTypeForClass.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("somethingFancy")) {
+ if(arrayListSeen) {
+ Assert.fail("already seen");
+ }
+ arrayListSeen = true;
+ Assert.assertTrue(field.getTypeInformation() instanceof GenericTypeInfo);
+ Assert.assertEquals(ArrayList.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("fancyIds")) {
+ if(multisetSeen) {
+ Assert.fail("already seen");
+ }
+ multisetSeen = true;
+ Assert.assertTrue(field.getTypeInformation() instanceof GenericTypeInfo);
+ Assert.assertEquals(HashMultiset.class, field.getTypeInformation().getTypeClass());
+ } else if(name.equals("fancyArray")) {
+ if(strArraySeen) {
+ Assert.fail("already seen");
+ }
+ strArraySeen = true;
+ Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, field.getTypeInformation());
+ Assert.assertEquals(String[].class, field.getTypeInformation().getTypeClass());
+ } else if(Arrays.asList("date", "someNumberWithÜnicödeNäme", "someFloat", "word", "nothing", "hadoopCitizen", "collection").contains(name)) {
+ // ignore these, they are inherited from the ComplexNestedClass
+ }
+ else {
+ Assert.fail("field "+field+" is not expected");
+ }
+ }
+ Assert.assertTrue("Field was not present", arrayListSeen);
+ Assert.assertTrue("Field was not present", multisetSeen);
+ Assert.assertTrue("Field was not present", strArraySeen);
+ }
+
+ @Test
+ public void testPojoExtendingTuple() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(FromTuple.class);
+ checkFromTuplePojo(typeForClass);
+
+ FromTuple ft = new FromTuple();
+ ft.f0 = ""; ft.f1 = ""; ft.f2 = 0L;
+ TypeInformation<?> typeForObject = TypeExtractor.getForObject(ft);
+ checkFromTuplePojo(typeForObject);
+ }
+
+ private void checkFromTuplePojo(TypeInformation<?> typeInformation) {
+ Assert.assertTrue(typeInformation instanceof PojoTypeInfo<?>);
+ Assert.assertEquals(4, typeInformation.getTotalFields());
+ PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeInformation;
+ for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
+ PojoField field = pojoTypeForClass.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("special")) {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ } else if(name.equals("f0") || name.equals("f1")) {
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
+ } else if(name.equals("f2")) {
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.getTypeInformation());
+ } else {
+ Assert.fail("unexpected field");
+ }
+ }
+ }
+
+ @Test
+ public void testPojoWithGenerics() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(ParentSettingGenerics.class);
+ Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
+ PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
+ for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
+ PojoField field = pojoTypeForClass.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("field1")) {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("field2")) {
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("field3")) {
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("key")) {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ } else {
+ Assert.fail("Unexpected field "+field);
+ }
+ }
+ }
+
+ /**
+ * Test if the TypeExtractor is accepting untyped generics,
+ * making them GenericTypes
+ */
+ @Test
+ public void testPojoWithGenericsSomeFieldsGeneric() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(PojoWithGenerics.class);
+ Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
+ PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
+ for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
+ PojoField field = pojoTypeForClass.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("field1")) {
+ Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.getTypeInformation());
+ } else if (name.equals("field2")) {
+ Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.getTypeInformation());
+ } else if (name.equals("key")) {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ } else {
+ Assert.fail("Unexpected field "+field);
+ }
+ }
+ }
+
+
+ @Test
+ public void testPojoWithComplexHierarchy() {
+ TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(ComplexHierarchyTop.class);
+ Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
+ PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
+ for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
+ PojoField field = pojoTypeForClass.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("field1")) {
+ Assert.assertTrue(field.getTypeInformation() instanceof PojoTypeInfo<?>); // From tuple is pojo (not tuple type!)
+ } else if (name.equals("field2")) {
+ Assert.assertTrue(field.getTypeInformation() instanceof TupleTypeInfo<?>);
+ Assert.assertTrue( ((TupleTypeInfo<?>)field.getTypeInformation()).getTypeAt(0).equals(BasicTypeInfo.STRING_TYPE_INFO) );
+ } else if (name.equals("key")) {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ } else {
+ Assert.fail("Unexpected field "+field);
+ }
+ }
+ }
+
+ public static class MyMapper<T> implements MapFunction<PojoWithGenerics<Long, T>, PojoWithGenerics<T,T>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public PojoWithGenerics<T, T> map(PojoWithGenerics<Long, T> value)
+ throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference1() {
+ MapFunction<?, ?> function = new MyMapper<String>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoWithGenerics<key=int,field1=Long,field2=String>"));
+
+ Assert.assertTrue(ti instanceof PojoTypeInfo<?>);
+ PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
+ for(int i = 0; i < pti.getArity(); i++) {
+ PojoField field = pti.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("field1")) {
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("field2")) {
+ Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("key")) {
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
+ } else {
+ Assert.fail("Unexpected field "+field);
+ }
+ }
+ }
+
+ public static class PojoTuple<A, B, C> extends Tuple3<B, C, Long> {
+ private static final long serialVersionUID = 1L;
+
+ public A extraField;
+ }
+
+ public static class MyMapper2<D, E> implements MapFunction<Tuple2<E, D>, PojoTuple<E, D, D>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public PojoTuple<E, D, D> map(Tuple2<E, D> value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference2() {
+ MapFunction<?, ?> function = new MyMapper2<Boolean, Character>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("Tuple2<Character,Boolean>"));
+ Assert.assertTrue(ti instanceof PojoTypeInfo<?>);
+ PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
+ for(int i = 0; i < pti.getArity(); i++) {
+ PojoField field = pti.getPojoFieldAt(i);
+ String name = field.getField().getName();
+ if(name.equals("extraField")) {
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("f0")) {
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("f1")) {
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, field.getTypeInformation());
+ } else if (name.equals("f2")) {
+ Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.getTypeInformation());
+ } else {
+ Assert.fail("Unexpected field "+field);
+ }
+ }
+ }
+
+ public static class MyMapper3<D, E> implements MapFunction<PojoTuple<E, D, D>, Tuple2<E, D>> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Tuple2<E, D> map(PojoTuple<E, D, D> value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference3() {
+ MapFunction<?, ?> function = new MyMapper3<Boolean, Character>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoTuple<extraField=char,f0=boolean,f1=boolean,f2=long>"));
+
+ Assert.assertTrue(ti instanceof TupleTypeInfo<?>);
+ TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
+ Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(0));
+ Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(1));
+ }
+
+ public static class PojoWithParameterizedFields1<Z> {
+ public Tuple2<Z, Z> field;
+ }
+
+ public static class MyMapper4<A> implements MapFunction<PojoWithParameterizedFields1<A>, A> {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public A map(PojoWithParameterizedFields1<A> value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference4() {
+ MapFunction<?, ?> function = new MyMapper4<Byte>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoWithParameterizedFields1<field=Tuple2<byte,byte>>"));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, ti);
+ }
+
+ public static class PojoWithParameterizedFields2<Z> {
+ public PojoWithGenerics<Z, Z> field;
+ }
+
+ public static class MyMapper5<A> implements MapFunction<PojoWithParameterizedFields2<A>, A> {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public A map(PojoWithParameterizedFields2<A> value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference5() {
+ MapFunction<?, ?> function = new MyMapper5<Byte>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoWithParameterizedFields2<"
+ + "field=org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoWithGenerics<key=int,field1=byte,field2=byte>"
+ + ">"));
+ Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, ti);
+ }
+
+ public static class PojoWithParameterizedFields3<Z> {
+ public Z[] field;
+ }
+
+ public static class MyMapper6<A> implements MapFunction<PojoWithParameterizedFields3<A>, A> {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public A map(PojoWithParameterizedFields3<A> value) throws Exception {
+ return null;
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference6() {
+ MapFunction<?, ?> function = new MyMapper6<Integer>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoWithParameterizedFields3<"
+ + "field=int[]"
+ + ">"));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
+ }
+
+ public static class MyMapper7<A> implements MapFunction<PojoWithParameterizedFields4<A>, A> {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public A map(PojoWithParameterizedFields4<A> value) throws Exception {
+ return null;
+ }
+ }
+
+ public static class PojoWithParameterizedFields4<Z> {
+ public Tuple1<Z>[] field;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testGenericPojoTypeInference7() {
+ MapFunction<?, ?> function = new MyMapper7<Integer>();
+
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
+ TypeInfoParser.parse("org.apache.flink.api.java.typeutils.PojoTypeExtractionTest$PojoWithParameterizedFields4<"
+ + "field=Tuple1<int>[]"
+ + ">"));
+ Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
+ }
+
+ public static class RecursivePojo1 {
+ public RecursivePojo1 field;
+ }
+
+ public static class RecursivePojo2 {
+ public Tuple1<RecursivePojo2> field;
+ }
+
+ public static class RecursivePojo3 {
+ public NestedPojo field;
+ }
+
+ public static class NestedPojo {
+ public RecursivePojo3 field;
+ }
+
+ @Test
+ public void testRecursivePojo1() {
+ TypeInformation<?> ti = TypeExtractor.createTypeInfo(RecursivePojo1.class);
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ Assert.assertEquals(GenericTypeInfo.class, ((PojoTypeInfo) ti).getPojoFieldAt(0).getTypeInformation().getClass());
+ }
+
+ @Test
+ public void testRecursivePojo2() {
+ TypeInformation<?> ti = TypeExtractor.createTypeInfo(RecursivePojo2.class);
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ PojoField pf = ((PojoTypeInfo) ti).getPojoFieldAt(0);
+ Assert.assertTrue(pf.getTypeInformation() instanceof TupleTypeInfo);
+ Assert.assertEquals(GenericTypeInfo.class, ((TupleTypeInfo) pf.getTypeInformation()).getTypeAt(0).getClass());
+ }
+
+ @Test
+ public void testRecursivePojo3() {
+ TypeInformation<?> ti = TypeExtractor.createTypeInfo(RecursivePojo3.class);
+ Assert.assertTrue(ti instanceof PojoTypeInfo);
+ PojoField pf = ((PojoTypeInfo) ti).getPojoFieldAt(0);
+ Assert.assertTrue(pf.getTypeInformation() instanceof PojoTypeInfo);
+ Assert.assertEquals(GenericTypeInfo.class, ((PojoTypeInfo) pf.getTypeInformation()).getPojoFieldAt(0).getTypeInformation().getClass());
+ }
+
+ public static class FooBarPojo {
+ public int foo, bar;
+ public FooBarPojo() {}
+ }
+
+ public static class DuplicateMapper implements MapFunction<FooBarPojo, Tuple2<FooBarPojo, FooBarPojo>> {
+ @Override
+ public Tuple2<FooBarPojo, FooBarPojo> map(FooBarPojo value) throws Exception {
+ return null;
+ }
+ }
+
+ @Test
+ public void testDualUseOfPojo() {
+ MapFunction<?, ?> function = new DuplicateMapper();
+ TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeExtractor.createTypeInfo(FooBarPojo.class));
+ Assert.assertTrue(ti instanceof TupleTypeInfo);
+ TupleTypeInfo<?> tti = ((TupleTypeInfo) ti);
+ Assert.assertTrue(tti.getTypeAt(0) instanceof PojoTypeInfo);
+ Assert.assertTrue(tti.getTypeAt(1) instanceof PojoTypeInfo);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java
new file mode 100644
index 0000000..dbe5115
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInfoTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.java.typeutils;
+
+import static org.junit.Assert.*;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.util.InstantiationUtil;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class PojoTypeInfoTest {
+
+ @Test
+ public void testPojoTypeInfoEquality() {
+ try {
+ TypeInformation<TestPojo> info1 = TypeExtractor.getForClass(TestPojo.class);
+ TypeInformation<TestPojo> info2 = TypeExtractor.getForClass(TestPojo.class);
+
+ assertTrue(info1 instanceof PojoTypeInfo);
+ assertTrue(info2 instanceof PojoTypeInfo);
+
+ assertTrue(info1.equals(info2));
+ assertTrue(info1.hashCode() == info2.hashCode());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testPojoTypeInfoInequality() {
+ try {
+ TypeInformation<TestPojo> info1 = TypeExtractor.getForClass(TestPojo.class);
+ TypeInformation<AlternatePojo> info2 = TypeExtractor.getForClass(AlternatePojo.class);
+
+ assertTrue(info1 instanceof PojoTypeInfo);
+ assertTrue(info2 instanceof PojoTypeInfo);
+
+ assertFalse(info1.equals(info2));
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSerializabilityOfPojoTypeInfo() throws IOException, ClassNotFoundException {
+ PojoTypeInfo<TestPojo> pojoTypeInfo = (PojoTypeInfo<TestPojo>)TypeExtractor.getForClass(TestPojo.class);
+
+ byte[] serializedPojoTypeInfo = InstantiationUtil.serializeObject(pojoTypeInfo);
+ PojoTypeInfo<TestPojo> deserializedPojoTypeInfo = (PojoTypeInfo<TestPojo>)InstantiationUtil.deserializeObject(
+ serializedPojoTypeInfo,
+ getClass().getClassLoader());
+
+ assertEquals(pojoTypeInfo, deserializedPojoTypeInfo);
+ }
+
+ @Test
+ public void testPrimitivePojo() {
+ TypeInformation<PrimitivePojo> info1 = TypeExtractor.getForClass(PrimitivePojo.class);
+
+ assertTrue(info1 instanceof PojoTypeInfo);
+ }
+
+ @Test
+ public void testUnderscorePojo() {
+ TypeInformation<UnderscorePojo> info1 = TypeExtractor.getForClass(UnderscorePojo.class);
+
+ assertTrue(info1 instanceof PojoTypeInfo);
+ }
+
+ public static final class TestPojo {
+
+ public int someInt;
+
+ private String aString;
+
+ public Double[] doubleArray;
+
+
+ public void setaString(String aString) {
+ this.aString = aString;
+ }
+
+ public String getaString() {
+ return aString;
+ }
+ }
+
+ public static final class AlternatePojo {
+
+ public int someInt;
+
+ private String aString;
+
+ public Double[] doubleArray;
+
+
+ public void setaString(String aString) {
+ this.aString = aString;
+ }
+
+ public String getaString() {
+ return aString;
+ }
+ }
+
+ public static final class PrimitivePojo {
+
+ private int someInt;
+
+ public void setSomeInt(Integer someInt) {
+ this.someInt = someInt;
+ }
+
+ public Integer getSomeInt() {
+ return this.someInt;
+ }
+ }
+
+ public static final class UnderscorePojo {
+
+ private int some_int;
+
+ public void setSomeInt(int some_int) {
+ this.some_int = some_int;
+ }
+
+ public Integer getSomeInt() {
+ return this.some_int;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInformationTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInformationTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInformationTest.java
new file mode 100644
index 0000000..51e481d
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/PojoTypeInformationTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.java.typeutils;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.CompositeType;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.junit.Test;
+
+public class PojoTypeInformationTest {
+
+ public static class SimplePojo {
+ public String str;
+ public Boolean Bl;
+ public boolean bl;
+ public Byte Bt;
+ public byte bt;
+ public Short Shrt;
+ public short shrt;
+ public Integer Intgr;
+ public int intgr;
+ public Long Lng;
+ public long lng;
+ public Float Flt;
+ public float flt;
+ public Double Dbl;
+ public double dbl;
+ public Character Ch;
+ public char ch;
+ public int[] primIntArray;
+ public Integer[] intWrapperArray;
+ }
+
+ @Test
+ public void testSimplePojoTypeExtraction() {
+ TypeInformation<SimplePojo> type = TypeExtractor.getForClass(SimplePojo.class);
+ assertTrue("Extracted type is not a composite/pojo type but should be.", type instanceof CompositeType);
+ }
+
+ public static class NestedPojoInner {
+ public String field;
+ }
+
+ public static class NestedPojoOuter {
+ public Integer intField;
+ public NestedPojoInner inner;
+ }
+
+ @Test
+ public void testNestedPojoTypeExtraction() {
+ TypeInformation<NestedPojoOuter> type = TypeExtractor.getForClass(NestedPojoOuter.class);
+ assertTrue("Extracted type is not a Pojo type but should be.", type instanceof CompositeType);
+ }
+
+ public static class Recursive1Pojo {
+ public Integer intField;
+ public Recursive2Pojo rec;
+ }
+
+ public static class Recursive2Pojo {
+ public String strField;
+ public Recursive1Pojo rec;
+ }
+
+ @Test
+ public void testRecursivePojoTypeExtraction() {
+ // This one tests whether a recursive pojo is detected using the set of visited
+ // types in the type extractor. The recursive field will be handled using the generic serializer.
+ TypeInformation<Recursive1Pojo> type = TypeExtractor.getForClass(Recursive1Pojo.class);
+ assertTrue("Extracted type is not a Pojo type but should be.", type instanceof CompositeType);
+ }
+
+ @Test
+ public void testRecursivePojoObjectTypeExtraction() {
+ TypeInformation<Recursive1Pojo> type = TypeExtractor.getForObject(new Recursive1Pojo());
+ assertTrue("Extracted type is not a Pojo type but should be.", type instanceof CompositeType);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java
new file mode 100644
index 0000000..b6cff34
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TupleTypeInfoTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.java.typeutils;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple1;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.util.TestLogger;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TupleTypeInfoTest extends TestLogger {
+
+ @Test
+ public void testTupleTypeInfoSymmetricEqualityRelation() {
+ TupleTypeInfo<Tuple1<Integer>> tupleTypeInfo = new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO);
+
+ TupleTypeInfoBase<Tuple1> anonymousTupleTypeInfo = new TupleTypeInfoBase<Tuple1>(
+ (Class<Tuple1>)Tuple1.class,
+ (TypeInformation<?>)BasicTypeInfo.INT_TYPE_INFO) {
+
+ private static final long serialVersionUID = -7985593598027660836L;
+
+ @Override
+ public TypeSerializer<Tuple1> createSerializer(ExecutionConfig config) {
+ return null;
+ }
+
+ @Override
+ protected TypeComparatorBuilder<Tuple1> createTypeComparatorBuilder() {
+ return null;
+ }
+
+ @Override
+ public String[] getFieldNames() {
+ return new String[0];
+ }
+
+ @Override
+ public int getFieldIndex(String fieldName) {
+ return 0;
+ }
+ };
+
+ boolean tupleVsAnonymous = tupleTypeInfo.equals(anonymousTupleTypeInfo);
+ boolean anonymousVsTuple = anonymousTupleTypeInfo.equals(tupleTypeInfo);
+
+ Assert.assertTrue("Equality relation should be symmetric", tupleVsAnonymous == anonymousVsTuple);
+ }
+
+ @Test
+ public void testTupleTypeInfoEquality() {
+ TupleTypeInfo<Tuple2<Integer, String>> tupleTypeInfo1 = new TupleTypeInfo<>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO);
+
+ TupleTypeInfo<Tuple2<Integer, String>> tupleTypeInfo2 = new TupleTypeInfo<>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO);
+
+ Assert.assertEquals(tupleTypeInfo1, tupleTypeInfo2);
+ Assert.assertEquals(tupleTypeInfo1.hashCode(), tupleTypeInfo2.hashCode());
+ }
+
+ @Test
+ public void testTupleTypeInfoInequality() {
+ TupleTypeInfo<Tuple2<Integer, String>> tupleTypeInfo1 = new TupleTypeInfo<>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ BasicTypeInfo.STRING_TYPE_INFO);
+
+ TupleTypeInfo<Tuple2<Integer, Boolean>> tupleTypeInfo2 = new TupleTypeInfo<>(
+ BasicTypeInfo.INT_TYPE_INFO,
+ BasicTypeInfo.BOOLEAN_TYPE_INFO);
+
+ Assert.assertNotEquals(tupleTypeInfo1, tupleTypeInfo2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorInputFormatsTest.java
----------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorInputFormatsTest.java b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorInputFormatsTest.java
new file mode 100644
index 0000000..a606896
--- /dev/null
+++ b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/TypeExtractorInputFormatsTest.java
@@ -0,0 +1,231 @@
+/*
+ * 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.java.typeutils;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.io.DefaultInputSplitAssigner;
+import org.apache.flink.api.common.io.GenericInputFormat;
+import org.apache.flink.api.common.io.InputFormat;
+import org.apache.flink.api.common.io.statistics.BaseStatistics;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.io.InputSplit;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+@SuppressWarnings("serial")
+public class TypeExtractorInputFormatsTest {
+
+ @Test
+ public void testExtractInputFormatType() {
+ try {
+ InputFormat<?, ?> format = new DummyFloatInputFormat();
+ TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
+ assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, typeInfo);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testExtractDerivedInputFormatType() {
+ try {
+ // simple type
+ {
+ InputFormat<?, ?> format = new DerivedInputFormat();
+ TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
+ assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, typeInfo);
+ }
+
+ // composite type
+ {
+ InputFormat<?, ?> format = new DerivedTupleInputFormat();
+ TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
+
+ assertTrue(typeInfo.isTupleType());
+ assertTrue(typeInfo instanceof TupleTypeInfo);
+
+ @SuppressWarnings("unchecked")
+ TupleTypeInfo<Tuple3<String, Short, Double>> tupleInfo = (TupleTypeInfo<Tuple3<String, Short, Double>>) typeInfo;
+
+ assertEquals(3, tupleInfo.getArity());
+ assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tupleInfo.getTypeAt(0));
+ assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tupleInfo.getTypeAt(1));
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tupleInfo.getTypeAt(2));
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testMultiLevelDerivedInputFormatType() {
+ try {
+
+ // composite type
+ {
+ InputFormat<?, ?> format = new FinalRelativeInputFormat();
+ TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
+
+ assertTrue(typeInfo.isTupleType());
+ assertTrue(typeInfo instanceof TupleTypeInfo);
+
+ @SuppressWarnings("unchecked")
+ TupleTypeInfo<Tuple3<String, Integer, Double>> tupleInfo = (TupleTypeInfo<Tuple3<String, Integer, Double>>) typeInfo;
+
+ assertEquals(3, tupleInfo.getArity());
+ assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tupleInfo.getTypeAt(0));
+ assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleInfo.getTypeAt(1));
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tupleInfo.getTypeAt(2));
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testQueryableFormatType() {
+ try {
+ InputFormat<?, ?> format = new QueryableInputFormat();
+ TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
+ assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, typeInfo);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Test formats
+ // --------------------------------------------------------------------------------------------
+
+ public static final class DummyFloatInputFormat implements InputFormat<Float, InputSplit> {
+
+ @Override
+ public void configure(Configuration parameters) {}
+
+ @Override
+ public BaseStatistics getStatistics(BaseStatistics cachedStatistics) { return null; }
+
+ @Override
+ public InputSplit[] createInputSplits(int minNumSplits) { return null; }
+
+ @Override
+ public DefaultInputSplitAssigner getInputSplitAssigner(InputSplit[] splits) { return null; }
+
+ @Override
+ public void open(InputSplit split) {}
+
+ @Override
+ public boolean reachedEnd() { return false; }
+
+ @Override
+ public Float nextRecord(Float reuse) throws IOException { return null; }
+
+ @Override
+ public void close() {}
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static final class DerivedInputFormat extends GenericInputFormat<Short> {
+
+ @Override
+ public boolean reachedEnd() { return false; }
+
+ @Override
+ public Short nextRecord(Short reuse) { return null; }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static final class DerivedTupleInputFormat extends GenericInputFormat<Tuple3<String, Short, Double>> {
+
+ @Override
+ public boolean reachedEnd() { return false; }
+
+ @Override
+ public Tuple3<String, Short, Double> nextRecord(Tuple3<String, Short, Double> reuse) { return null; }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static class RelativeInputFormat<T> extends GenericInputFormat<Tuple3<String, T, Double>> {
+
+ @Override
+ public boolean reachedEnd() { return false; }
+
+ @Override
+ public Tuple3<String, T, Double> nextRecord(Tuple3<String, T, Double> reuse) { return null; }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static final class FinalRelativeInputFormat extends RelativeInputFormat<Integer> {
+
+ @Override
+ public Tuple3<String, Integer, Double> nextRecord(Tuple3<String, Integer, Double> reuse) { return null; }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ public static final class QueryableInputFormat implements InputFormat<Float, InputSplit>, ResultTypeQueryable<Double> {
+
+ @Override
+ public void configure(Configuration parameters) {}
+
+ @Override
+ public BaseStatistics getStatistics(BaseStatistics cachedStatistics) { return null; }
+
+ @Override
+ public InputSplit[] createInputSplits(int minNumSplits) { return null; }
+
+ @Override
+ public DefaultInputSplitAssigner getInputSplitAssigner(InputSplit[] splits) { return null; }
+
+ @Override
+ public void open(InputSplit split) {}
+
+ @Override
+ public boolean reachedEnd() { return false; }
+
+ @Override
+ public Float nextRecord(Float reuse) throws IOException { return null; }
+
+ @Override
+ public void close() {}
+
+ @Override
+ public TypeInformation<Double> getProducedType() {
+ return BasicTypeInfo.DOUBLE_TYPE_INFO;
+ }
+ }
+}
[32/38] flink git commit: [FLINK-3303] [core] Move Tuple classes to
flink-core
Posted by se...@apache.org.
[FLINK-3303] [core] Move Tuple classes to flink-core
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/7081836e
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/7081836e
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/7081836e
Branch: refs/heads/master
Commit: 7081836e0d640ee640687606bd73b6673d3f2a07
Parents: 5474386
Author: Stephan Ewen <se...@apache.org>
Authored: Sun Jan 31 23:08:18 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 16:55:44 2016 +0100
----------------------------------------------------------------------
.../org/apache/flink/api/java/tuple/Tuple.java | 118 +++
.../org/apache/flink/api/java/tuple/Tuple0.java | 98 +++
.../org/apache/flink/api/java/tuple/Tuple1.java | 154 ++++
.../apache/flink/api/java/tuple/Tuple10.java | 289 ++++++
.../apache/flink/api/java/tuple/Tuple11.java | 304 +++++++
.../apache/flink/api/java/tuple/Tuple12.java | 319 +++++++
.../apache/flink/api/java/tuple/Tuple13.java | 334 +++++++
.../apache/flink/api/java/tuple/Tuple14.java | 349 ++++++++
.../apache/flink/api/java/tuple/Tuple15.java | 364 ++++++++
.../apache/flink/api/java/tuple/Tuple16.java | 379 ++++++++
.../apache/flink/api/java/tuple/Tuple17.java | 394 +++++++++
.../apache/flink/api/java/tuple/Tuple18.java | 409 +++++++++
.../apache/flink/api/java/tuple/Tuple19.java | 424 +++++++++
.../org/apache/flink/api/java/tuple/Tuple2.java | 177 ++++
.../apache/flink/api/java/tuple/Tuple20.java | 439 +++++++++
.../apache/flink/api/java/tuple/Tuple21.java | 454 ++++++++++
.../apache/flink/api/java/tuple/Tuple22.java | 469 ++++++++++
.../apache/flink/api/java/tuple/Tuple23.java | 484 ++++++++++
.../apache/flink/api/java/tuple/Tuple24.java | 499 +++++++++++
.../apache/flink/api/java/tuple/Tuple25.java | 514 +++++++++++
.../org/apache/flink/api/java/tuple/Tuple3.java | 184 ++++
.../org/apache/flink/api/java/tuple/Tuple4.java | 199 +++++
.../org/apache/flink/api/java/tuple/Tuple5.java | 214 +++++
.../org/apache/flink/api/java/tuple/Tuple6.java | 229 +++++
.../org/apache/flink/api/java/tuple/Tuple7.java | 244 +++++
.../org/apache/flink/api/java/tuple/Tuple8.java | 259 ++++++
.../org/apache/flink/api/java/tuple/Tuple9.java | 274 ++++++
.../api/java/tuple/builder/Tuple0Builder.java | 46 +
.../api/java/tuple/builder/Tuple10Builder.java | 46 +
.../api/java/tuple/builder/Tuple11Builder.java | 46 +
.../api/java/tuple/builder/Tuple12Builder.java | 46 +
.../api/java/tuple/builder/Tuple13Builder.java | 46 +
.../api/java/tuple/builder/Tuple14Builder.java | 46 +
.../api/java/tuple/builder/Tuple15Builder.java | 46 +
.../api/java/tuple/builder/Tuple16Builder.java | 46 +
.../api/java/tuple/builder/Tuple17Builder.java | 46 +
.../api/java/tuple/builder/Tuple18Builder.java | 46 +
.../api/java/tuple/builder/Tuple19Builder.java | 46 +
.../api/java/tuple/builder/Tuple1Builder.java | 46 +
.../api/java/tuple/builder/Tuple20Builder.java | 46 +
.../api/java/tuple/builder/Tuple21Builder.java | 46 +
.../api/java/tuple/builder/Tuple22Builder.java | 46 +
.../api/java/tuple/builder/Tuple23Builder.java | 46 +
.../api/java/tuple/builder/Tuple24Builder.java | 46 +
.../api/java/tuple/builder/Tuple25Builder.java | 46 +
.../api/java/tuple/builder/Tuple2Builder.java | 46 +
.../api/java/tuple/builder/Tuple3Builder.java | 46 +
.../api/java/tuple/builder/Tuple4Builder.java | 46 +
.../api/java/tuple/builder/Tuple5Builder.java | 46 +
.../api/java/tuple/builder/Tuple6Builder.java | 46 +
.../api/java/tuple/builder/Tuple7Builder.java | 46 +
.../api/java/tuple/builder/Tuple8Builder.java | 46 +
.../api/java/tuple/builder/Tuple9Builder.java | 46 +
.../flink/api/java/tuple/TupleGenerator.java | 521 +++++++++++
.../org/apache/flink/api/java/tuple/Tuple.java | 118 ---
.../org/apache/flink/api/java/tuple/Tuple0.java | 98 ---
.../org/apache/flink/api/java/tuple/Tuple1.java | 154 ----
.../apache/flink/api/java/tuple/Tuple10.java | 289 ------
.../apache/flink/api/java/tuple/Tuple11.java | 304 -------
.../apache/flink/api/java/tuple/Tuple12.java | 319 -------
.../apache/flink/api/java/tuple/Tuple13.java | 334 -------
.../apache/flink/api/java/tuple/Tuple14.java | 349 --------
.../apache/flink/api/java/tuple/Tuple15.java | 364 --------
.../apache/flink/api/java/tuple/Tuple16.java | 379 --------
.../apache/flink/api/java/tuple/Tuple17.java | 394 ---------
.../apache/flink/api/java/tuple/Tuple18.java | 409 ---------
.../apache/flink/api/java/tuple/Tuple19.java | 424 ---------
.../org/apache/flink/api/java/tuple/Tuple2.java | 177 ----
.../apache/flink/api/java/tuple/Tuple20.java | 439 ---------
.../apache/flink/api/java/tuple/Tuple21.java | 454 ----------
.../apache/flink/api/java/tuple/Tuple22.java | 469 ----------
.../apache/flink/api/java/tuple/Tuple23.java | 484 ----------
.../apache/flink/api/java/tuple/Tuple24.java | 499 -----------
.../apache/flink/api/java/tuple/Tuple25.java | 514 -----------
.../org/apache/flink/api/java/tuple/Tuple3.java | 184 ----
.../org/apache/flink/api/java/tuple/Tuple4.java | 199 -----
.../org/apache/flink/api/java/tuple/Tuple5.java | 214 -----
.../org/apache/flink/api/java/tuple/Tuple6.java | 229 -----
.../org/apache/flink/api/java/tuple/Tuple7.java | 244 -----
.../org/apache/flink/api/java/tuple/Tuple8.java | 259 ------
.../org/apache/flink/api/java/tuple/Tuple9.java | 274 ------
.../flink/api/java/tuple/TupleGenerator.java | 879 -------------------
.../api/java/tuple/builder/Tuple0Builder.java | 46 -
.../api/java/tuple/builder/Tuple10Builder.java | 46 -
.../api/java/tuple/builder/Tuple11Builder.java | 46 -
.../api/java/tuple/builder/Tuple12Builder.java | 46 -
.../api/java/tuple/builder/Tuple13Builder.java | 46 -
.../api/java/tuple/builder/Tuple14Builder.java | 46 -
.../api/java/tuple/builder/Tuple15Builder.java | 46 -
.../api/java/tuple/builder/Tuple16Builder.java | 46 -
.../api/java/tuple/builder/Tuple17Builder.java | 46 -
.../api/java/tuple/builder/Tuple18Builder.java | 46 -
.../api/java/tuple/builder/Tuple19Builder.java | 46 -
.../api/java/tuple/builder/Tuple1Builder.java | 46 -
.../api/java/tuple/builder/Tuple20Builder.java | 46 -
.../api/java/tuple/builder/Tuple21Builder.java | 46 -
.../api/java/tuple/builder/Tuple22Builder.java | 46 -
.../api/java/tuple/builder/Tuple23Builder.java | 46 -
.../api/java/tuple/builder/Tuple24Builder.java | 46 -
.../api/java/tuple/builder/Tuple25Builder.java | 46 -
.../api/java/tuple/builder/Tuple2Builder.java | 46 -
.../api/java/tuple/builder/Tuple3Builder.java | 46 -
.../api/java/tuple/builder/Tuple4Builder.java | 46 -
.../api/java/tuple/builder/Tuple5Builder.java | 46 -
.../api/java/tuple/builder/Tuple6Builder.java | 46 -
.../api/java/tuple/builder/Tuple7Builder.java | 46 -
.../api/java/tuple/builder/Tuple8Builder.java | 46 -
.../api/java/tuple/builder/Tuple9Builder.java | 46 -
.../apache/flink/api/java/tuple/Tuple2Test.java | 4 +-
.../flink/api/java/tuple/TupleGenerator.java | 498 +++++++++++
110 files changed, 10791 insertions(+), 10651 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
new file mode 100644
index 0000000..71b1f61
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple.java
@@ -0,0 +1,118 @@
+/*
+ * 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.java.tuple;
+
+import org.apache.flink.types.NullFieldException;
+
+
+/**
+ * The base class of all tuples. Tuples have a fix length and contain a set of fields,
+ * which may all be of different types. Because Tuples are strongly typed, each distinct
+ * tuple length is represented by its own class. Tuples exists with up to 25 fields and
+ * are described in the classes {@link Tuple1} to {@link Tuple25}.
+ * <p>
+ * The fields in the tuples may be accessed directly a public fields, or via position (zero indexed)
+ * {@link #getField(int)}.
+ * <p>
+ * Tuples are in principle serializable. However, they may contain non-serializable fields,
+ * in which case serialization will fail.
+ */
+public abstract class Tuple implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final int MAX_ARITY = 25;
+
+
+ /**
+ * Gets the field at the specified position.
+ *
+ * @param pos The position of the field, zero indexed.
+ * @return The field at the specified position.
+ * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
+ */
+ public abstract <T> T getField(int pos);
+
+ /**
+ * Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.
+ *
+ * @param pos The position of the field, zero indexed.
+ * @return The field at the specified position.
+ * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
+ * @throws NullFieldException Thrown, if the field at pos is null.
+ */
+ public <T> T getFieldNotNull(int pos){
+ T field = getField(pos);
+ if (field != null) {
+ return field;
+ } else {
+ throw new NullFieldException(pos);
+ }
+ }
+
+ /**
+ * Sets the field at the specified position.
+ *
+ * @param value The value to be assigned to the field at the specified position.
+ * @param pos The position of the field, zero indexed.
+ * @throws IndexOutOfBoundsException Thrown, if the position is negative, or equal to, or larger than the number of fields.
+ */
+ public abstract <T> void setField(T value, int pos);
+
+ /**
+ * Gets the number of field in the tuple (the tuple arity).
+ *
+ * @return The number of fields in the tuple.
+ */
+ public abstract int getArity();
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ public abstract <T extends Tuple> T copy();
+
+ // --------------------------------------------------------------------------------------------
+
+ /**
+ * Gets the class corresponding to the tuple of the given arity (dimensions). For
+ * example, {@code getTupleClass(3)} will return the {@code Tuple3.class}.
+ *
+ * @param arity The arity of the tuple class to get.
+ * @return The tuple class with the given arity.
+ */
+ @SuppressWarnings("unchecked")
+ public static Class<? extends Tuple> getTupleClass(int arity) {
+ if (arity < 0 || arity > MAX_ARITY) {
+ throw new IllegalArgumentException("The tuple arity must be in [0, " + MAX_ARITY + "].");
+ }
+ return (Class<? extends Tuple>) CLASSES[arity];
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // The following lines are generated.
+ // --------------------------------------------------------------------------------------------
+
+ // BEGIN_OF_TUPLE_DEPENDENT_CODE
+ // GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+ private static final Class<?>[] CLASSES = new Class<?>[] {
+ Tuple0.class, Tuple1.class, Tuple2.class, Tuple3.class, Tuple4.class, Tuple5.class, Tuple6.class, Tuple7.class, Tuple8.class, Tuple9.class, Tuple10.class, Tuple11.class, Tuple12.class, Tuple13.class, Tuple14.class, Tuple15.class, Tuple16.class, Tuple17.class, Tuple18.class, Tuple19.class, Tuple20.class, Tuple21.class, Tuple22.class, Tuple23.class, Tuple24.class, Tuple25.class
+ };
+ // END_OF_TUPLE_DEPENDENT_CODE
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java
new file mode 100644
index 0000000..c3386dc
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple0.java
@@ -0,0 +1,98 @@
+/**
+ * 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.java.tuple;
+
+import java.io.ObjectStreamException;
+
+/**
+ * A tuple with 0 fields.
+ *
+ * <p>The Tuple0 is a soft singleton, i.e., there is a "singleton" instance, but it does
+ * not prevent creation of additional instances.</p>
+ *
+ * @see Tuple
+ */
+public class Tuple0 extends Tuple {
+ private static final long serialVersionUID = 1L;
+
+ /** An immutable reusable Tuple0 instance */
+ public static final Tuple0 INSTANCE = new Tuple0();
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int getArity() {
+ return 0;
+ }
+
+ @Override
+ public <T> T getField(int pos) {
+ throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+
+ @Override
+ public <T> void setField(T value, int pos) {
+ throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple0 copy(){
+ return new Tuple0();
+ }
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form "()"
+ *
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "()";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ *
+ * @param o
+ * the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ return this == o || o instanceof Tuple0;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ // singleton deserialization
+ private Object readResolve() throws ObjectStreamException {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java
new file mode 100644
index 0000000..01c5501
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple1.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 1 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ */
+public class Tuple1<T0> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple1() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ */
+ public Tuple1(T0 value0) {
+ this.f0 = value0;
+ }
+
+ @Override
+ public int getArity() { return 1; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ */
+ public void setFields(T0 value0) {
+ this.f0 = value0;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple1)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple1 tuple = (Tuple1) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple1<T0> copy(){
+ return new Tuple1<T0>(this.f0);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0> Tuple1<T0> of(T0 value0) {
+ return new Tuple1<T0>(value0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java
new file mode 100644
index 0000000..ea24f40
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple10.java
@@ -0,0 +1,289 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 10 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ */
+public class Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple10() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ */
+ public Tuple10(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ }
+
+ @Override
+ public int getArity() { return 10; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple10)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple10 tuple = (Tuple10) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> copy(){
+ return new Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9) {
+ return new Tuple10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java
new file mode 100644
index 0000000..b58ae6c
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple11.java
@@ -0,0 +1,304 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 11 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ */
+public class Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple11() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ */
+ public Tuple11(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ }
+
+ @Override
+ public int getArity() { return 11; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple11)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple11 tuple = (Tuple11) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> copy(){
+ return new Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10) {
+ return new Tuple11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java
new file mode 100644
index 0000000..4e7defb
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple12.java
@@ -0,0 +1,319 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 12 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ */
+public class Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple12() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ */
+ public Tuple12(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ }
+
+ @Override
+ public int getArity() { return 12; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple12)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple12 tuple = (Tuple12) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> copy(){
+ return new Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11) {
+ return new Tuple12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java
new file mode 100644
index 0000000..9543912
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple13.java
@@ -0,0 +1,334 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 13 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ */
+public class Tuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple13() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ */
+ public Tuple13(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ }
+
+ @Override
+ public int getArity() { return 13; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple13)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple13 tuple = (Tuple13) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> copy(){
+ return new Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12) {
+ return new Tuple13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/7081836e/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java
new file mode 100644
index 0000000..36d508e
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/tuple/Tuple14.java
@@ -0,0 +1,349 @@
+/*
+ * 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.
+ */
+
+
+// --------------------------------------------------------------
+// THIS IS A GENERATED SOURCE FILE. DO NOT EDIT!
+// GENERATED FROM org.apache.flink.api.java.tuple.TupleGenerator.
+// --------------------------------------------------------------
+
+
+package org.apache.flink.api.java.tuple;
+
+import org.apache.flink.util.StringUtils;
+
+/**
+ * A tuple with 14 fields. Tuples are strongly typed; each field may be of a separate type.
+ * The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position
+ * through the {@link #getField(int)} method. The tuple field positions start at zero.
+ * <p>
+ * Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work
+ * with Tuples to reuse objects in order to reduce pressure on the garbage collector.
+ *
+ * @see Tuple
+ *
+ * @param <T0> The type of field 0
+ * @param <T1> The type of field 1
+ * @param <T2> The type of field 2
+ * @param <T3> The type of field 3
+ * @param <T4> The type of field 4
+ * @param <T5> The type of field 5
+ * @param <T6> The type of field 6
+ * @param <T7> The type of field 7
+ * @param <T8> The type of field 8
+ * @param <T9> The type of field 9
+ * @param <T10> The type of field 10
+ * @param <T11> The type of field 11
+ * @param <T12> The type of field 12
+ * @param <T13> The type of field 13
+ */
+public class Tuple14<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> extends Tuple {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Field 0 of the tuple. */
+ public T0 f0;
+ /** Field 1 of the tuple. */
+ public T1 f1;
+ /** Field 2 of the tuple. */
+ public T2 f2;
+ /** Field 3 of the tuple. */
+ public T3 f3;
+ /** Field 4 of the tuple. */
+ public T4 f4;
+ /** Field 5 of the tuple. */
+ public T5 f5;
+ /** Field 6 of the tuple. */
+ public T6 f6;
+ /** Field 7 of the tuple. */
+ public T7 f7;
+ /** Field 8 of the tuple. */
+ public T8 f8;
+ /** Field 9 of the tuple. */
+ public T9 f9;
+ /** Field 10 of the tuple. */
+ public T10 f10;
+ /** Field 11 of the tuple. */
+ public T11 f11;
+ /** Field 12 of the tuple. */
+ public T12 f12;
+ /** Field 13 of the tuple. */
+ public T13 f13;
+
+ /**
+ * Creates a new tuple where all fields are null.
+ */
+ public Tuple14() {}
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ */
+ public Tuple14(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ }
+
+ @Override
+ public int getArity() { return 14; }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getField(int pos) {
+ switch(pos) {
+ case 0: return (T) this.f0;
+ case 1: return (T) this.f1;
+ case 2: return (T) this.f2;
+ case 3: return (T) this.f3;
+ case 4: return (T) this.f4;
+ case 5: return (T) this.f5;
+ case 6: return (T) this.f6;
+ case 7: return (T) this.f7;
+ case 8: return (T) this.f8;
+ case 9: return (T) this.f9;
+ case 10: return (T) this.f10;
+ case 11: return (T) this.f11;
+ case 12: return (T) this.f12;
+ case 13: return (T) this.f13;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> void setField(T value, int pos) {
+ switch(pos) {
+ case 0:
+ this.f0 = (T0) value;
+ break;
+ case 1:
+ this.f1 = (T1) value;
+ break;
+ case 2:
+ this.f2 = (T2) value;
+ break;
+ case 3:
+ this.f3 = (T3) value;
+ break;
+ case 4:
+ this.f4 = (T4) value;
+ break;
+ case 5:
+ this.f5 = (T5) value;
+ break;
+ case 6:
+ this.f6 = (T6) value;
+ break;
+ case 7:
+ this.f7 = (T7) value;
+ break;
+ case 8:
+ this.f8 = (T8) value;
+ break;
+ case 9:
+ this.f9 = (T9) value;
+ break;
+ case 10:
+ this.f10 = (T10) value;
+ break;
+ case 11:
+ this.f11 = (T11) value;
+ break;
+ case 12:
+ this.f12 = (T12) value;
+ break;
+ case 13:
+ this.f13 = (T13) value;
+ break;
+ default: throw new IndexOutOfBoundsException(String.valueOf(pos));
+ }
+ }
+
+ /**
+ * Sets new values to all fields of the tuple.
+ *
+ * @param value0 The value for field 0
+ * @param value1 The value for field 1
+ * @param value2 The value for field 2
+ * @param value3 The value for field 3
+ * @param value4 The value for field 4
+ * @param value5 The value for field 5
+ * @param value6 The value for field 6
+ * @param value7 The value for field 7
+ * @param value8 The value for field 8
+ * @param value9 The value for field 9
+ * @param value10 The value for field 10
+ * @param value11 The value for field 11
+ * @param value12 The value for field 12
+ * @param value13 The value for field 13
+ */
+ public void setFields(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
+ this.f0 = value0;
+ this.f1 = value1;
+ this.f2 = value2;
+ this.f3 = value3;
+ this.f4 = value4;
+ this.f5 = value5;
+ this.f6 = value6;
+ this.f7 = value7;
+ this.f8 = value8;
+ this.f9 = value9;
+ this.f10 = value10;
+ this.f11 = value11;
+ this.f12 = value12;
+ this.f13 = value13;
+ }
+
+
+ // -------------------------------------------------------------------------------------------------
+ // standard utilities
+ // -------------------------------------------------------------------------------------------------
+
+ /**
+ * Creates a string representation of the tuple in the form
+ * (f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13),
+ * where the individual fields are the value returned by calling {@link Object#toString} on that field.
+ * @return The string representation of the tuple.
+ */
+ @Override
+ public String toString() {
+ return "(" + StringUtils.arrayAwareToString(this.f0)
+ + "," + StringUtils.arrayAwareToString(this.f1)
+ + "," + StringUtils.arrayAwareToString(this.f2)
+ + "," + StringUtils.arrayAwareToString(this.f3)
+ + "," + StringUtils.arrayAwareToString(this.f4)
+ + "," + StringUtils.arrayAwareToString(this.f5)
+ + "," + StringUtils.arrayAwareToString(this.f6)
+ + "," + StringUtils.arrayAwareToString(this.f7)
+ + "," + StringUtils.arrayAwareToString(this.f8)
+ + "," + StringUtils.arrayAwareToString(this.f9)
+ + "," + StringUtils.arrayAwareToString(this.f10)
+ + "," + StringUtils.arrayAwareToString(this.f11)
+ + "," + StringUtils.arrayAwareToString(this.f12)
+ + "," + StringUtils.arrayAwareToString(this.f13)
+ + ")";
+ }
+
+ /**
+ * Deep equality for tuples by calling equals() on the tuple members
+ * @param o the object checked for equality
+ * @return true if this is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if(this == o) { return true; }
+ if (!(o instanceof Tuple14)) { return false; }
+ @SuppressWarnings("rawtypes")
+ Tuple14 tuple = (Tuple14) o;
+ if (f0 != null ? !f0.equals(tuple.f0) : tuple.f0 != null) { return false; }
+ if (f1 != null ? !f1.equals(tuple.f1) : tuple.f1 != null) { return false; }
+ if (f2 != null ? !f2.equals(tuple.f2) : tuple.f2 != null) { return false; }
+ if (f3 != null ? !f3.equals(tuple.f3) : tuple.f3 != null) { return false; }
+ if (f4 != null ? !f4.equals(tuple.f4) : tuple.f4 != null) { return false; }
+ if (f5 != null ? !f5.equals(tuple.f5) : tuple.f5 != null) { return false; }
+ if (f6 != null ? !f6.equals(tuple.f6) : tuple.f6 != null) { return false; }
+ if (f7 != null ? !f7.equals(tuple.f7) : tuple.f7 != null) { return false; }
+ if (f8 != null ? !f8.equals(tuple.f8) : tuple.f8 != null) { return false; }
+ if (f9 != null ? !f9.equals(tuple.f9) : tuple.f9 != null) { return false; }
+ if (f10 != null ? !f10.equals(tuple.f10) : tuple.f10 != null) { return false; }
+ if (f11 != null ? !f11.equals(tuple.f11) : tuple.f11 != null) { return false; }
+ if (f12 != null ? !f12.equals(tuple.f12) : tuple.f12 != null) { return false; }
+ if (f13 != null ? !f13.equals(tuple.f13) : tuple.f13 != null) { return false; }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = f0 != null ? f0.hashCode() : 0;
+ result = 31 * result + (f1 != null ? f1.hashCode() : 0);
+ result = 31 * result + (f2 != null ? f2.hashCode() : 0);
+ result = 31 * result + (f3 != null ? f3.hashCode() : 0);
+ result = 31 * result + (f4 != null ? f4.hashCode() : 0);
+ result = 31 * result + (f5 != null ? f5.hashCode() : 0);
+ result = 31 * result + (f6 != null ? f6.hashCode() : 0);
+ result = 31 * result + (f7 != null ? f7.hashCode() : 0);
+ result = 31 * result + (f8 != null ? f8.hashCode() : 0);
+ result = 31 * result + (f9 != null ? f9.hashCode() : 0);
+ result = 31 * result + (f10 != null ? f10.hashCode() : 0);
+ result = 31 * result + (f11 != null ? f11.hashCode() : 0);
+ result = 31 * result + (f12 != null ? f12.hashCode() : 0);
+ result = 31 * result + (f13 != null ? f13.hashCode() : 0);
+ return result;
+ }
+
+ /**
+ * Shallow tuple copy.
+ * @return A new Tuple with the same fields as this.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> copy(){
+ return new Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(this.f0,
+ this.f1,
+ this.f2,
+ this.f3,
+ this.f4,
+ this.f5,
+ this.f6,
+ this.f7,
+ this.f8,
+ this.f9,
+ this.f10,
+ this.f11,
+ this.f12,
+ this.f13);
+ }
+
+ /**
+ * Creates a new tuple and assigns the given values to the tuple's fields.
+ * This is more convenient than using the constructor, because the compiler can
+ * infer the generic type arguments implicitly. For example:
+ * {@code Tuple3.of(n, x, s)}
+ * instead of
+ * {@code new Tuple3<Integer, Double, String>(n, x, s)}
+ */
+ public static <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8, T9 value9, T10 value10, T11 value11, T12 value12, T13 value13) {
+ return new Tuple14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11, value12, value13);
+ }
+}
[35/38] flink git commit: [hotfix] [streaming] Various cleanups in
StreamTask - Clean up generics - Clean and safe disposal of initialized
resources - Add names to asynchronous materialization threads - Fix
concurrent modification of materializa
Posted by se...@apache.org.
[hotfix] [streaming] Various cleanups in StreamTask
- Clean up generics
- Clean and safe disposal of initialized resources
- Add names to asynchronous materialization threads
- Fix concurrent modification of materialization threads set
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/168532ec
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/168532ec
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/168532ec
Branch: refs/heads/master
Commit: 168532ece09b4be972f3ccad509a1e3376a1ac3a
Parents: bfff86c
Author: Stephan Ewen <se...@apache.org>
Authored: Thu Jan 28 18:58:11 2016 +0100
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Feb 2 17:11:46 2016 +0100
----------------------------------------------------------------------
.../streaming/runtime/tasks/StreamTask.java | 129 +++++++++----------
.../runtime/state/StateBackendITCase.java | 1 -
2 files changed, 63 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/168532ec/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
index e4b6b6e..9ab6c10 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/StreamTask.java
@@ -17,6 +17,8 @@
package org.apache.flink.streaming.runtime.tasks;
+import java.io.Serializable;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -28,13 +30,11 @@ import org.apache.flink.api.common.accumulators.Accumulator;
import org.apache.flink.configuration.ConfigConstants;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.IllegalConfigurationException;
-import org.apache.flink.runtime.accumulators.AccumulatorRegistry;
import org.apache.flink.runtime.execution.CancelTaskException;
import org.apache.flink.runtime.io.network.api.CheckpointBarrier;
import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
import org.apache.flink.runtime.jobgraph.tasks.StatefulTask;
import org.apache.flink.runtime.state.AsynchronousStateHandle;
-import org.apache.flink.runtime.state.StateHandle;
import org.apache.flink.runtime.taskmanager.DispatcherThreadFactory;
import org.apache.flink.runtime.util.event.EventListener;
import org.apache.flink.streaming.api.checkpoint.CheckpointNotifier;
@@ -140,14 +140,14 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
* actual execution Thread. */
private volatile AsynchronousException asyncException;
- protected Set<Thread> asyncCheckpointThreads;
+ /** The currently active background materialization threads */
+ private final Set<Thread> asyncCheckpointThreads = Collections.synchronizedSet(new HashSet<Thread>());
/** Flag to mark the task "in operation", in which case check
* needs to be initialized to true, so that early cancel() before invoke() behaves correctly */
private volatile boolean isRunning;
private long recoveryTimestamp;
-
// ------------------------------------------------------------------------
// Life cycle methods for specific implementations
@@ -167,21 +167,19 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
@Override
public final void invoke() throws Exception {
- // --------------------------------------------------------------------
- // Initialize
- // --------------------------------------------------------------------
- LOG.debug("Initializing {}", getName());
- boolean initializationCompleted = false;
+ boolean disposed = false;
try {
- AccumulatorRegistry accumulatorRegistry = getEnvironment().getAccumulatorRegistry();
+ // -------- Initialize ---------
+ LOG.debug("Initializing {}", getName());
userClassLoader = getUserCodeClassLoader();
configuration = new StreamConfig(getTaskConfiguration());
- accumulatorMap = accumulatorRegistry.getUserMap();
+ accumulatorMap = getEnvironment().getAccumulatorRegistry().getUserMap();
headOperator = configuration.getStreamOperator(userClassLoader);
- operatorChain = new OperatorChain<>(this, headOperator, accumulatorRegistry.getReadWriteReporter());
+ operatorChain = new OperatorChain<>(this, headOperator,
+ getEnvironment().getAccumulatorRegistry().getReadWriteReporter());
if (headOperator != null) {
headOperator.setup(this, configuration, operatorChain.getChainEntryPoint());
@@ -190,37 +188,16 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
timerService = Executors.newSingleThreadScheduledExecutor(
new DispatcherThreadFactory(TRIGGER_THREAD_GROUP, "Time Trigger for " + getName()));
- asyncCheckpointThreads = new HashSet<>();
-
// task specific initialization
init();
-
- initializationCompleted = true;
- }
- finally {
- if (!initializationCompleted) {
- if (timerService != null) {
- timerService.shutdownNow();
- }
- if (operatorChain != null) {
- operatorChain.releaseOutputs();
- }
- }
- }
-
- // --------------------------------------------------------------------
- // Invoke
- // --------------------------------------------------------------------
- LOG.debug("Invoking {}", getName());
-
- boolean disposed = false;
- try {
- // first order of business is to initialize the state backend and to
- // give operators back their state
+
+ // -------- Invoke --------
+ LOG.debug("Invoking {}", getName());
+
+ // first order of business is to give operators back their state
stateBackend = createStateBackend();
stateBackend.initializeForJob(getEnvironment());
-
- restoreStateLazy();
+ restoreState();
// we need to make sure that any triggers scheduled in open() cannot be
// executed before all operators are opened
@@ -255,14 +232,31 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
disposed = true;
}
finally {
+ // clean up everything we initialized
isRunning = false;
- timerService.shutdownNow();
-
- for (Thread checkpointThread: asyncCheckpointThreads) {
- checkpointThread.interrupt();
+ // stop all timers and threads
+ if (timerService != null) {
+ try {
+ timerService.shutdownNow();
+ }
+ catch (Throwable t) {
+ // catch and log the exception to not replace the original exception
+ LOG.error("Could not shut down timer service", t);
+ }
+ }
+
+ // stop all asynchronous checkpoint threads
+ try {
+ for (Thread checkpointThread : asyncCheckpointThreads) {
+ checkpointThread.interrupt();
+ }
+ asyncCheckpointThreads.clear();
+ }
+ catch (Throwable t) {
+ // catch and log the exception to not replace the original exception
+ LOG.error("Could not shut down async checkpoint threads", t);
}
- asyncCheckpointThreads.clear();
// release the output resources. this method should never fail.
if (operatorChain != null) {
@@ -270,13 +264,12 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
}
// we must! perform this cleanup
-
try {
cleanup();
}
catch (Throwable t) {
// catch and log the exception to not replace the original exception
- LOG.error("Error during cleanup of stream task.");
+ LOG.error("Error during cleanup of stream task", t);
}
// if the operators were not disposed before, do a hard dispose
@@ -333,14 +326,16 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
}
private void disposeAllOperators() {
- for (StreamOperator<?> operator : operatorChain.getAllOperators()) {
- try {
- if (operator != null) {
- operator.dispose();
+ if (operatorChain != null) {
+ for (StreamOperator<?> operator : operatorChain.getAllOperators()) {
+ try {
+ if (operator != null) {
+ operator.dispose();
+ }
+ }
+ catch (Throwable t) {
+ LOG.error("Error during disposal of stream operator.", t);
}
- }
- catch (Throwable t) {
- LOG.error("Error during disposal of stream operator.", t);
}
}
}
@@ -360,13 +355,11 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
if (!timerService.isTerminated()) {
LOG.warn("Timer service was not shut down. Shutting down in finalize().");
}
- timerService.shutdown();
+ timerService.shutdownNow();
}
- if (asyncCheckpointThreads != null) {
- for (Thread checkpointThread : asyncCheckpointThreads) {
- checkpointThread.interrupt();
- }
+ for (Thread checkpointThread : asyncCheckpointThreads) {
+ checkpointThread.interrupt();
}
}
@@ -417,7 +410,7 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
this.recoveryTimestamp = recoveryTimestamp;
}
- public void restoreStateLazy() throws Exception {
+ private void restoreState() throws Exception {
if (lazyRestoreState != null) {
LOG.info("Restoring checkpointed state to task {}", getName());
@@ -448,7 +441,6 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
}
@Override
- @SuppressWarnings("unchecked,rawtypes")
public boolean triggerCheckpoint(final long checkpointId, final long timestamp) throws Exception {
LOG.debug("Starting checkpoint {} on task {}", checkpointId, getName());
@@ -497,26 +489,30 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
// start a Thread that does the asynchronous materialization and
// then sends the checkpoint acknowledge
- Thread checkpointThread = new Thread() {
+ String threadName = "Materialize checkpoint " + checkpointId + " for " + getName();
+ Thread checkpointThread = new Thread(threadName) {
@Override
public void run() {
try {
for (StreamTaskState state : states) {
if (state != null) {
if (state.getFunctionState() instanceof AsynchronousStateHandle) {
- AsynchronousStateHandle<?> asyncState = (AsynchronousStateHandle<?>) state.getFunctionState();
- state.setFunctionState((StateHandle) asyncState.materialize());
+ AsynchronousStateHandle<Serializable> asyncState = (AsynchronousStateHandle<Serializable>) state.getFunctionState();
+ state.setFunctionState(asyncState.materialize());
}
if (state.getOperatorState() instanceof AsynchronousStateHandle) {
AsynchronousStateHandle<?> asyncState = (AsynchronousStateHandle<?>) state.getOperatorState();
- state.setOperatorState((StateHandle) asyncState.materialize());
+ state.setOperatorState(asyncState.materialize());
}
}
}
StreamTaskStateList allStates = new StreamTaskStateList(states);
getEnvironment().acknowledgeCheckpoint(checkpointId, allStates);
- } catch (Exception e) {
- LOG.error("Caught exception while materializing asynchronous checkpoints.", e);
+ }
+ catch (Exception e) {
+ if (isRunning()) {
+ LOG.error("Caught exception while materializing asynchronous checkpoints.", e);
+ }
if (asyncException == null) {
asyncException = new AsynchronousException(e);
}
@@ -527,6 +523,7 @@ public abstract class StreamTask<OUT, Operator extends StreamOperator<OUT>>
};
asyncCheckpointThreads.add(checkpointThread);
+ checkpointThread.setDaemon(true);
checkpointThread.start();
}
return true;
http://git-wip-us.apache.org/repos/asf/flink/blob/168532ec/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/state/StateBackendITCase.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/state/StateBackendITCase.java b/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/state/StateBackendITCase.java
index cdfef85..add532f 100644
--- a/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/state/StateBackendITCase.java
+++ b/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/state/StateBackendITCase.java
@@ -35,7 +35,6 @@ import java.io.Serializable;
import static org.junit.Assert.assertTrue;
-
public class StateBackendITCase extends StreamingMultipleProgramsTestBase {
/**
[07/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
deleted file mode 100644
index 276ffc4..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
+++ /dev/null
@@ -1,382 +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.java.typeutils.runtime.kryo;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.KryoException;
-import com.esotericsoftware.kryo.Serializer;
-import com.esotericsoftware.kryo.factories.ReflectionSerializerFactory;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-import com.esotericsoftware.kryo.serializers.JavaSerializer;
-import com.google.common.base.Preconditions;
-
-import org.apache.avro.generic.GenericData;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeutils.TypeSerializer;
-import org.apache.flink.api.java.typeutils.runtime.DataInputViewStream;
-import org.apache.flink.api.java.typeutils.runtime.DataOutputViewStream;
-import org.apache.flink.api.java.typeutils.runtime.NoFetchingInput;
-import org.apache.flink.api.java.typeutils.runtime.kryo.Serializers.SpecificInstanceCollectionSerializerForArrayList;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.objenesis.strategy.StdInstantiatorStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * A type serializer that serializes its type using the Kryo serialization
- * framework (https://github.com/EsotericSoftware/kryo).
- *
- * This serializer is intended as a fallback serializer for the cases that are
- * not covered by the basic types, tuples, and POJOs.
- *
- * @param <T> The type to be serialized.
- */
-public class KryoSerializer<T> extends TypeSerializer<T> {
-
- private static final long serialVersionUID = 3L;
-
- private static final Logger LOG = LoggerFactory.getLogger(KryoSerializer.class);
-
- // ------------------------------------------------------------------------
-
- private final LinkedHashMap<Class<?>, ExecutionConfig.SerializableSerializer<?>> registeredTypesWithSerializers;
- private final LinkedHashMap<Class<?>, Class<? extends Serializer<?>>> registeredTypesWithSerializerClasses;
- private final LinkedHashMap<Class<?>, ExecutionConfig.SerializableSerializer<?>> defaultSerializers;
- private final LinkedHashMap<Class<?>, Class<? extends Serializer<?>>> defaultSerializerClasses;
- private final LinkedHashSet<Class<?>> registeredTypes;
-
- private final Class<T> type;
-
- // ------------------------------------------------------------------------
- // The fields below are lazily initialized after duplication or deserialization.
-
- private transient Kryo kryo;
- private transient T copyInstance;
-
- private transient DataOutputView previousOut;
- private transient DataInputView previousIn;
-
- private transient Input input;
- private transient Output output;
-
- // ------------------------------------------------------------------------
-
- public KryoSerializer(Class<T> type, ExecutionConfig executionConfig){
- this.type = Preconditions.checkNotNull(type);
-
- this.defaultSerializers = executionConfig.getDefaultKryoSerializers();
- this.defaultSerializerClasses = executionConfig.getDefaultKryoSerializerClasses();
- this.registeredTypesWithSerializers = executionConfig.getRegisteredTypesWithKryoSerializers();
- this.registeredTypesWithSerializerClasses = executionConfig.getRegisteredTypesWithKryoSerializerClasses();
- this.registeredTypes = executionConfig.getRegisteredKryoTypes();
- }
-
- /**
- * Copy-constructor that does not copy transient fields. They will be initialized once required.
- */
- protected KryoSerializer(KryoSerializer<T> toCopy) {
- registeredTypesWithSerializers = toCopy.registeredTypesWithSerializers;
- registeredTypesWithSerializerClasses = toCopy.registeredTypesWithSerializerClasses;
- defaultSerializers = toCopy.defaultSerializers;
- defaultSerializerClasses = toCopy.defaultSerializerClasses;
- registeredTypes = toCopy.registeredTypes;
-
- type = toCopy.type;
- if(type == null){
- throw new NullPointerException("Type class cannot be null.");
- }
- }
-
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isImmutableType() {
- return false;
- }
-
- @Override
- public KryoSerializer<T> duplicate() {
- return new KryoSerializer<T>(this);
- }
-
- @Override
- public T createInstance() {
- if(Modifier.isAbstract(type.getModifiers()) || Modifier.isInterface(type.getModifiers()) ) {
- return null;
- } else {
- checkKryoInitialized();
- try {
- return kryo.newInstance(type);
- } catch(Throwable e) {
- return null;
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T copy(T from) {
- if (from == null) {
- return null;
- }
- checkKryoInitialized();
- try {
- return kryo.copy(from);
- }
- catch(KryoException ke) {
- // kryo was unable to copy it, so we do it through serialization:
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- Output output = new Output(baout);
-
- kryo.writeObject(output, from);
-
- output.close();
-
- ByteArrayInputStream bain = new ByteArrayInputStream(baout.toByteArray());
- Input input = new Input(bain);
-
- return (T)kryo.readObject(input, from.getClass());
- }
- }
-
- @Override
- public T copy(T from, T reuse) {
- return copy(from);
- }
-
- @Override
- public int getLength() {
- return -1;
- }
-
- @Override
- public void serialize(T record, DataOutputView target) throws IOException {
- checkKryoInitialized();
- if (target != previousOut) {
- DataOutputViewStream outputStream = new DataOutputViewStream(target);
- output = new Output(outputStream);
- previousOut = target;
- }
-
- // Sanity check: Make sure that the output is cleared/has been flushed by the last call
- // otherwise data might be written multiple times in case of a previous EOFException
- if (output.position() != 0) {
- throw new IllegalStateException("The Kryo Output still contains data from a previous " +
- "serialize call. It has to be flushed or cleared at the end of the serialize call.");
- }
-
- try {
- kryo.writeClassAndObject(output, record);
- output.flush();
- }
- catch (KryoException ke) {
- // make sure that the Kryo output buffer is cleared in case that we can recover from
- // the exception (e.g. EOFException which denotes buffer full)
- output.clear();
-
- Throwable cause = ke.getCause();
- if (cause instanceof EOFException) {
- throw (EOFException) cause;
- }
- else {
- throw ke;
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T deserialize(DataInputView source) throws IOException {
- checkKryoInitialized();
- if (source != previousIn) {
- DataInputViewStream inputStream = new DataInputViewStream(source);
- input = new NoFetchingInput(inputStream);
- previousIn = source;
- }
-
- try {
- return (T) kryo.readClassAndObject(input);
- } catch (KryoException ke) {
- Throwable cause = ke.getCause();
-
- if (cause instanceof EOFException) {
- throw (EOFException) cause;
- } else {
- throw ke;
- }
- }
- }
-
- @Override
- public T deserialize(T reuse, DataInputView source) throws IOException {
- return deserialize(source);
- }
-
- @Override
- public void copy(DataInputView source, DataOutputView target) throws IOException {
- checkKryoInitialized();
- if(this.copyInstance == null){
- this.copyInstance = createInstance();
- }
-
- T tmp = deserialize(copyInstance, source);
- serialize(tmp, target);
- }
-
- // --------------------------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- return Objects.hash(
- type,
- registeredTypes,
- registeredTypesWithSerializerClasses,
- defaultSerializerClasses);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof KryoSerializer) {
- KryoSerializer<?> other = (KryoSerializer<?>) obj;
-
- // we cannot include the Serializers here because they don't implement the equals method
- return other.canEqual(this) &&
- type == other.type &&
- registeredTypes.equals(other.registeredTypes) &&
- registeredTypesWithSerializerClasses.equals(other.registeredTypesWithSerializerClasses) &&
- defaultSerializerClasses.equals(other.defaultSerializerClasses);
- } else {
- return false;
- }
- }
-
- @Override
- public boolean canEqual(Object obj) {
- return obj instanceof KryoSerializer;
- }
-
- // --------------------------------------------------------------------------------------------
-
- /**
- * Returns the Chill Kryo Serializer which is implictly added to the classpath via flink-runtime.
- * Falls back to the default Kryo serializer if it can't be found.
- * @return The Kryo serializer instance.
- */
- private Kryo getKryoInstance() {
-
- try {
- // check if ScalaKryoInstantiator is in class path (coming from Twitter's Chill library).
- // This will be true if Flink's Scala API is used.
- Class<?> chillInstantiatorClazz = Class.forName("com.twitter.chill.ScalaKryoInstantiator");
- Object chillInstantiator = chillInstantiatorClazz.newInstance();
-
- // obtain a Kryo instance through Twitter Chill
- Method m = chillInstantiatorClazz.getMethod("newKryo");
-
- return (Kryo) m.invoke(chillInstantiator);
- } catch (ClassNotFoundException | InstantiationException | NoSuchMethodException |
- IllegalAccessException | InvocationTargetException e) {
-
- LOG.warn("Falling back to default Kryo serializer because Chill serializer couldn't be found.", e);
-
- Kryo.DefaultInstantiatorStrategy initStrategy = new Kryo.DefaultInstantiatorStrategy();
- initStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
-
- Kryo kryo = new Kryo();
- kryo.setInstantiatorStrategy(initStrategy);
-
- return kryo;
- }
- }
-
- private void checkKryoInitialized() {
- if (this.kryo == null) {
- this.kryo = getKryoInstance();
-
- // disable reference tracking. reference tracking is costly, usually unnecessary, and
- // inconsistent with Flink's own serialization (which does not do reference tracking)
- kryo.setReferences(false);
-
- // Throwable and all subclasses should be serialized via java serialization
- kryo.addDefaultSerializer(Throwable.class, new JavaSerializer());
-
- // Add default serializers first, so that they type registrations without a serializer
- // are registered with a default serializer
- for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> entry: defaultSerializers.entrySet()) {
- kryo.addDefaultSerializer(entry.getKey(), entry.getValue().getSerializer());
- }
-
- for (Map.Entry<Class<?>, Class<? extends Serializer<?>>> entry: defaultSerializerClasses.entrySet()) {
- kryo.addDefaultSerializer(entry.getKey(), entry.getValue());
- }
-
- // register the type of our class
- kryo.register(type);
-
- // register given types. we do this first so that any registration of a
- // more specific serializer overrides this
- for (Class<?> type : registeredTypes) {
- kryo.register(type);
- }
-
- // register given serializer classes
- for (Map.Entry<Class<?>, Class<? extends Serializer<?>>> e : registeredTypesWithSerializerClasses.entrySet()) {
- Class<?> typeClass = e.getKey();
- Class<? extends Serializer<?>> serializerClass = e.getValue();
-
- Serializer<?> serializer =
- ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, typeClass);
- kryo.register(typeClass, serializer);
- }
-
- // register given serializers
- for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> e : registeredTypesWithSerializers.entrySet()) {
- kryo.register(e.getKey(), e.getValue().getSerializer());
- }
- // this is needed for Avro but can not be added on demand.
- kryo.register(GenericData.Array.class, new SpecificInstanceCollectionSerializerForArrayList());
-
- kryo.setRegistrationRequired(false);
- kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
- }
- }
-
- // --------------------------------------------------------------------------------------------
- // For testing
- // --------------------------------------------------------------------------------------------
-
- public Kryo getKryo() {
- checkKryoInitialized();
- return this.kryo;
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java
deleted file mode 100644
index 8bac729..0000000
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java
+++ /dev/null
@@ -1,229 +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.java.typeutils.runtime.kryo;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.Serializer;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-import com.esotericsoftware.kryo.serializers.CollectionSerializer;
-import org.apache.avro.Schema;
-import org.apache.avro.generic.GenericData;
-import org.apache.avro.specific.SpecificRecordBase;
-import org.apache.flink.api.common.ExecutionConfig;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.java.Utils;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * Class containing utilities for the serializers of the Flink Runtime.
- *
- * Most of the serializers are automatically added to the system.
- *
- * Note that users can also implement the {@link com.esotericsoftware.kryo.KryoSerializable} interface
- * to provide custom serialization for their classes.
- * Also, there is a Java Annotation for adding a default serializer (@DefaultSerializer) to classes.
- */
-public class Serializers {
-
- public static void recursivelyRegisterType(TypeInformation<?> typeInfo, ExecutionConfig config, Set<Class<?>> alreadySeen) {
- if (typeInfo instanceof GenericTypeInfo) {
- GenericTypeInfo<?> genericTypeInfo = (GenericTypeInfo<?>) typeInfo;
- Serializers.recursivelyRegisterType(genericTypeInfo.getTypeClass(), config, alreadySeen);
- }
- else if (typeInfo instanceof CompositeType) {
- List<GenericTypeInfo<?>> genericTypesInComposite = new ArrayList<>();
- Utils.getContainedGenericTypes((CompositeType<?>)typeInfo, genericTypesInComposite);
- for (GenericTypeInfo<?> gt : genericTypesInComposite) {
- Serializers.recursivelyRegisterType(gt.getTypeClass(), config, alreadySeen);
- }
- }
- else if (typeInfo instanceof ObjectArrayTypeInfo) {
- ObjectArrayTypeInfo<?, ?> objectArrayTypeInfo = (ObjectArrayTypeInfo<?, ?>) typeInfo;
- recursivelyRegisterType(objectArrayTypeInfo.getComponentInfo(), config, alreadySeen);
- }
- }
-
- public static void recursivelyRegisterType(Class<?> type, ExecutionConfig config, Set<Class<?>> alreadySeen) {
- // don't register or remember primitives
- if (type == null || type.isPrimitive() || type == Object.class) {
- return;
- }
-
- // prevent infinite recursion for recursive types
- if (!alreadySeen.add(type)) {
- return;
- }
-
- if (type.isArray()) {
- recursivelyRegisterType(type.getComponentType(), config, alreadySeen);
- }
- else {
- config.registerKryoType(type);
- checkAndAddSerializerForTypeAvro(config, type);
-
- Field[] fields = type.getDeclaredFields();
- for (Field field : fields) {
- if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers())) {
- continue;
- }
- Type fieldType = field.getGenericType();
- recursivelyRegisterGenericType(fieldType, config, alreadySeen);
- }
- }
- }
-
- private static void recursivelyRegisterGenericType(Type fieldType, ExecutionConfig config, Set<Class<?>> alreadySeen) {
- if (fieldType instanceof ParameterizedType) {
- // field has generics
- ParameterizedType parameterizedFieldType = (ParameterizedType) fieldType;
-
- for (Type t: parameterizedFieldType.getActualTypeArguments()) {
- if (TypeExtractor.isClassType(t) ) {
- recursivelyRegisterType(TypeExtractor.typeToClass(t), config, alreadySeen);
- }
- }
-
- recursivelyRegisterGenericType(parameterizedFieldType.getRawType(), config, alreadySeen);
- }
- else if (fieldType instanceof GenericArrayType) {
- GenericArrayType genericArrayType = (GenericArrayType) fieldType;
- recursivelyRegisterGenericType(genericArrayType.getGenericComponentType(), config, alreadySeen);
- }
- else if (fieldType instanceof Class) {
- Class<?> clazz = (Class<?>) fieldType;
- recursivelyRegisterType(clazz, config, alreadySeen);
- }
- }
-
- private static void checkAndAddSerializerForTypeAvro(ExecutionConfig reg, Class<?> type) {
- if (GenericData.Record.class.isAssignableFrom(type)) {
- registerGenericAvro(reg);
- }
- if (SpecificRecordBase.class.isAssignableFrom(type)) {
- @SuppressWarnings("unchecked")
- Class<? extends SpecificRecordBase> specRecordClass = (Class<? extends SpecificRecordBase>) type;
- registerSpecificAvro(reg, specRecordClass);
- }
- }
-
- /**
- * Register these serializers for using Avro's {@link GenericData.Record} and classes
- * implementing {@link org.apache.avro.specific.SpecificRecordBase}
- */
- private static void registerGenericAvro(ExecutionConfig reg) {
- // Avro POJOs contain java.util.List which have GenericData.Array as their runtime type
- // because Kryo is not able to serialize them properly, we use this serializer for them
- reg.registerTypeWithKryoSerializer(GenericData.Array.class, SpecificInstanceCollectionSerializerForArrayList.class);
-
- // We register this serializer for users who want to use untyped Avro records (GenericData.Record).
- // Kryo is able to serialize everything in there, except for the Schema.
- // This serializer is very slow, but using the GenericData.Records of Kryo is in general a bad idea.
- // we add the serializer as a default serializer because Avro is using a private sub-type at runtime.
- reg.addDefaultKryoSerializer(Schema.class, AvroSchemaSerializer.class);
- }
-
- private static void registerSpecificAvro(ExecutionConfig reg, Class<? extends SpecificRecordBase> avroType) {
- registerGenericAvro(reg);
- // This rule only applies if users explicitly use the GenericTypeInformation for the avro types
- // usually, we are able to handle Avro POJOs with the POJO serializer.
- // (However only if the GenericData.Array type is registered!)
-
- // ClassTag<SpecificRecordBase> tag = scala.reflect.ClassTag$.MODULE$.apply(avroType);
- // reg.registerTypeWithKryoSerializer(avroType, com.twitter.chill.avro.AvroSerializer.SpecificRecordSerializer(tag));
- }
-
- // --------------------------------------------------------------------------------------------
- // Custom Serializers
- // --------------------------------------------------------------------------------------------
-
- @SuppressWarnings("rawtypes")
- public static class SpecificInstanceCollectionSerializerForArrayList extends SpecificInstanceCollectionSerializer<ArrayList> {
- private static final long serialVersionUID = 1L;
-
- public SpecificInstanceCollectionSerializerForArrayList() {
- super(ArrayList.class);
- }
- }
- /**
- * Special serializer for Java collections enforcing certain instance types.
- * Avro is serializing collections with an "GenericData.Array" type. Kryo is not able to handle
- * this type, so we use ArrayLists.
- */
- @SuppressWarnings("rawtypes")
- public static class SpecificInstanceCollectionSerializer<T extends Collection>
- extends CollectionSerializer implements Serializable
- {
- private static final long serialVersionUID = 1L;
-
- private Class<T> type;
-
- public SpecificInstanceCollectionSerializer(Class<T> type) {
- this.type = type;
- }
-
- @Override
- protected Collection create(Kryo kryo, Input input, Class<Collection> type) {
- return kryo.newInstance(this.type);
- }
-
- @Override
- protected Collection createCopy(Kryo kryo, Collection original) {
- return kryo.newInstance(this.type);
- }
- }
-
- /**
- * Slow serialization approach for Avro schemas.
- * This is only used with {{@link org.apache.avro.generic.GenericData.Record}} types.
- * Having this serializer, we are able to handle avro Records.
- */
- public static class AvroSchemaSerializer extends Serializer<Schema> implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void write(Kryo kryo, Output output, Schema object) {
- String schemaAsString = object.toString(false);
- output.writeString(schemaAsString);
- }
-
- @Override
- public Schema read(Kryo kryo, Input input, Class<Schema> type) {
- String schemaAsString = input.readString();
- // the parser seems to be stateful, to we need a new one for every type.
- Schema.Parser sParser = new Schema.Parser();
- return sParser.parse(schemaAsString);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/TypeExtractionTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/TypeExtractionTest.java b/flink-java/src/test/java/org/apache/flink/api/java/TypeExtractionTest.java
new file mode 100644
index 0000000..fb20d78
--- /dev/null
+++ b/flink-java/src/test/java/org/apache/flink/api/java/TypeExtractionTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.java;
+
+import org.apache.flink.api.common.functions.RichMapFunction;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.typeutils.TypeInfoParser;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests concerning type extraction by ExecutionEnvironment methods.
+ */
+@SuppressWarnings("serial")
+public class TypeExtractionTest {
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ @Test
+ public void testFunctionWithMissingGenericsAndReturns() {
+
+ RichMapFunction function = new RichMapFunction() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object map(Object value) throws Exception {
+ return null;
+ }
+ };
+
+ TypeInformation<?> info = ExecutionEnvironment.getExecutionEnvironment()
+ .fromElements("arbitrary", "data")
+ .map(function).returns("String").getResultType();
+
+ assertEquals(TypeInfoParser.parse("String"), info);
+ }
+
+ @Test
+ public void testGetterSetterWithVertex() {
+ ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
+ env.fromElements(new VertexTyped(0L, 3.0), new VertexTyped(1L, 1.0));
+ }
+
+ // ------------------------------------------------------------------------
+ // Test types
+ // ------------------------------------------------------------------------
+
+ public static class Vertex<K, V> {
+
+ private K key1;
+ private K key2;
+ private V value;
+
+ public Vertex() {}
+
+ public Vertex(K key, V value) {
+ this.key1 = key;
+ this.key2 = key;
+ this.value = value;
+ }
+
+ public Vertex(K key1, K key2, V value) {
+ this.key1 = key1;
+ this.key2 = key2;
+ this.value = value;
+ }
+
+ public void setKey1(K key1) {
+ this.key1 = key1;
+ }
+
+ public void setKey2(K key2) {
+ this.key2 = key2;
+ }
+
+ public K getKey1() {
+ return key1;
+ }
+
+ public K getKey2() {
+ return key2;
+ }
+
+ public void setValue(V value) {
+ this.value = value;
+ }
+
+ public V getValue() {
+ return value;
+ }
+ }
+
+ public static class VertexTyped extends Vertex<Long, Double>{
+ public VertexTyped(Long l, Double d) {
+ super(l, d);
+ }
+ public VertexTyped() {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/operators/ExpressionKeysTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/operators/ExpressionKeysTest.java b/flink-java/src/test/java/org/apache/flink/api/java/operators/ExpressionKeysTest.java
deleted file mode 100644
index dd82234..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/operators/ExpressionKeysTest.java
+++ /dev/null
@@ -1,479 +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.java.operators;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.flink.api.common.InvalidProgramException;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.operators.Keys.ExpressionKeys;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.tuple.Tuple7;
-import org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest.ComplexNestedClass;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.operators.SelectorFunctionKeysTest.KeySelector1;
-import org.apache.flink.api.java.operators.SelectorFunctionKeysTest.KeySelector3;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.Whitebox;
-
-@SuppressWarnings("unused")
-@RunWith(PowerMockRunner.class)
-public class ExpressionKeysTest {
-
- @Test
- public void testBasicType() {
-
- TypeInformation<Long> longType = BasicTypeInfo.LONG_TYPE_INFO;
- ExpressionKeys<Long> ek = new ExpressionKeys<>("*", longType);
-
- Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
- }
-
- @Test(expected = InvalidProgramException.class)
- public void testGenericNonKeyType() {
- // Fail: GenericType cannot be used as key
- TypeInformation<GenericNonKeyType> genericType = new GenericTypeInfo<>(GenericNonKeyType.class);
- new ExpressionKeys<>("*", genericType);
- }
-
- @Test
- public void testKeyGenericType() {
-
- TypeInformation<GenericKeyType> genericType = new GenericTypeInfo<>(GenericKeyType.class);
- ExpressionKeys<GenericKeyType> ek = new ExpressionKeys<>("*", genericType);
-
- Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
- }
-
- @Test
- public void testTupleRangeCheck() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-
- // test private static final int[] rangeCheckFields(int[] fields, int maxAllowedField)
- Method rangeCheckFieldsMethod = Whitebox.getMethod(Keys.class, "rangeCheckFields", int[].class, int.class);
-
- // valid indexes
- rangeCheckFieldsMethod.invoke(null, new int[]{1, 2, 3, 4}, 4);
-
- // corner case tests
- rangeCheckFieldsMethod.invoke(null, new int[] {0}, 0);
-
- Throwable ex = null;
- try {
- // throws illegal argument.
- rangeCheckFieldsMethod.invoke(null, new int[] {5}, 0);
- } catch(Throwable iae) {
- ex = iae;
- }
- Assert.assertNotNull(ex);
- }
-
- @Test
- public void testStandardTupleKeys() {
- TupleTypeInfo<Tuple7<String, String, String, String, String, String, String>> typeInfo = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO);
-
- ExpressionKeys<Tuple7<String, String, String, String, String, String, String>> ek;
-
- for( int i = 1; i < 8; i++) {
- int[] ints = new int[i];
- for( int j = 0; j < i; j++) {
- ints[j] = j;
- }
- int[] inInts = Arrays.copyOf(ints, ints.length); // copy, just to make sure that the code is not cheating by changing the ints.
- ek = new ExpressionKeys<>(inInts, typeInfo);
- Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions());
- Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length);
-
- ArrayUtils.reverse(ints);
- inInts = Arrays.copyOf(ints, ints.length);
- ek = new ExpressionKeys<>(inInts, typeInfo);
- Assert.assertArrayEquals(ints, ek.computeLogicalKeyPositions());
- Assert.assertEquals(ints.length, ek.computeLogicalKeyPositions().length);
- }
- }
-
- @Test
- public void testInvalidTuple() throws Throwable {
- TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
- BasicTypeInfo.STRING_TYPE_INFO);
-
- String[][] tests = new String[][] {
- new String[] {"f0.f1"}, // nesting into unnested
- new String[] {"f11"},
- new String[] {"f-35"},
- new String[] {"f0.f33"},
- new String[] {"f1.f33"}
- };
- for (String[] test : tests) {
- Throwable e = null;
- try {
- new ExpressionKeys<>(test, typeInfo);
- } catch (Throwable t) {
- e = t;
- }
- Assert.assertNotNull(e);
- }
- }
-
- @Test(expected = InvalidProgramException.class)
- public void testTupleNonKeyField() {
- // selected field is not a key type
- TypeInformation<Tuple3<String, Long, GenericNonKeyType>> ti = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO,
- TypeExtractor.getForClass(GenericNonKeyType.class)
- );
-
- new ExpressionKeys<>(2, ti);
- }
-
- @Test
- public void testTupleKeyExpansion() {
- TupleTypeInfo<Tuple3<String, Tuple3<String, String, String>, String>> typeInfo = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
- BasicTypeInfo.STRING_TYPE_INFO);
- ExpressionKeys<Tuple3<String, Tuple3<String, String, String>, String>> fpk =
- new ExpressionKeys<>(0, typeInfo);
- Assert.assertArrayEquals(new int[] {0}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(1, typeInfo);
- Assert.assertArrayEquals(new int[] {1,2,3}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(2, typeInfo);
- Assert.assertArrayEquals(new int[] {4}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(new int[] {0,1,2}, typeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(null, typeInfo, true); // empty case
- Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>("*", typeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
-
- // scala style "select all"
- fpk = new ExpressionKeys<>("_", typeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
-
- // this was a bug:
- fpk = new ExpressionKeys<>("f2", typeInfo);
- Assert.assertArrayEquals(new int[] {4}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(new String[] {"f0","f1.f0","f1.f1", "f1.f2", "f2"}, typeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(new String[] {"f0","f1.f0","f1.f1", "f2"}, typeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,4}, fpk.computeLogicalKeyPositions());
-
- fpk = new ExpressionKeys<>(new String[] {"f2", "f0"}, typeInfo);
- Assert.assertArrayEquals(new int[] {4,0}, fpk.computeLogicalKeyPositions());
-
-
- TupleTypeInfo<Tuple3<String, Tuple3<Tuple3<String, String, String>, String, String>, String>> complexTypeInfo = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- new TupleTypeInfo<Tuple3<Tuple3<String, String, String>, String, String>>(new TupleTypeInfo<Tuple3<String, String, String>>(BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),BasicTypeInfo.STRING_TYPE_INFO,BasicTypeInfo.STRING_TYPE_INFO),
- BasicTypeInfo.STRING_TYPE_INFO);
-
- ExpressionKeys<Tuple3<String, Tuple3<Tuple3<String, String, String>, String, String>, String>> complexFpk =
- new ExpressionKeys<>(0, complexTypeInfo);
- Assert.assertArrayEquals(new int[] {0}, complexFpk.computeLogicalKeyPositions());
-
- complexFpk = new ExpressionKeys<>(new int[] {0,1,2}, complexTypeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());
-
- complexFpk = new ExpressionKeys<>("*", complexTypeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());
-
- // scala style select all
- complexFpk = new ExpressionKeys<>("_", complexTypeInfo);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6}, complexFpk.computeLogicalKeyPositions());
-
- complexFpk = new ExpressionKeys<>("f1.f0.*", complexTypeInfo);
- Assert.assertArrayEquals(new int[] {1,2,3}, complexFpk.computeLogicalKeyPositions());
-
- complexFpk = new ExpressionKeys<>("f1.f0", complexTypeInfo);
- Assert.assertArrayEquals(new int[] {1,2,3}, complexFpk.computeLogicalKeyPositions());
-
- complexFpk = new ExpressionKeys<>("f2", complexTypeInfo);
- Assert.assertArrayEquals(new int[] {6}, complexFpk.computeLogicalKeyPositions());
- }
-
- @Test
- public void testPojoKeys() {
- TypeInformation<PojoWithMultiplePojos> ti = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
- ExpressionKeys<PojoWithMultiplePojos> ek;
- ek = new ExpressionKeys<>("*", ti);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>("p1.*", ti);
- Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>("p2.*", ti);
- Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>("p1", ti);
- Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>("p2", ti);
- Assert.assertArrayEquals(new int[] {3,4}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>("i0", ti);
- Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
- }
-
- @Test
- public void testTupleWithNestedPojo() {
-
- TypeInformation<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ti =
- new TupleTypeInfo<>(
- BasicTypeInfo.INT_TYPE_INFO,
- TypeExtractor.getForClass(Pojo1.class),
- TypeExtractor.getForClass(PojoWithMultiplePojos.class)
- );
-
- ExpressionKeys<Tuple3<Integer, Pojo1, PojoWithMultiplePojos>> ek;
-
- ek = new ExpressionKeys<>(0, ti);
- Assert.assertArrayEquals(new int[] {0}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>(1, ti);
- Assert.assertArrayEquals(new int[] {1,2}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>(2, ti);
- Assert.assertArrayEquals(new int[] {3,4,5,6,7}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>(new int[]{}, ti, true);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions());
-
- ek = new ExpressionKeys<>("*", ti);
- Assert.assertArrayEquals(new int[] {0,1,2,3,4,5,6,7}, ek.computeLogicalKeyPositions());
-
- }
-
- @Test(expected = InvalidProgramException.class)
- public void testNonKeyPojoField() {
- // selected field is not a key type
- TypeInformation<PojoWithNonKeyField> ti = TypeExtractor.getForClass(PojoWithNonKeyField.class);
- new ExpressionKeys<>("b", ti);
- }
-
- @Test
- public void testInvalidPojo() throws Throwable {
- TypeInformation<ComplexNestedClass> ti = TypeExtractor.getForClass(ComplexNestedClass.class);
-
- String[][] tests = new String[][] {
- new String[] {"nonexistent"},
- new String[] {"date.abc"} // nesting into unnested
- };
- for (String[] test : tests) {
- Throwable e = null;
- try {
- new ExpressionKeys<>(test, ti);
- } catch (Throwable t) {
- e = t;
- }
- Assert.assertNotNull(e);
- }
- }
-
- @Test
- public void testAreCompatible1() throws Keys.IncompatibleKeysException {
- TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
-
- ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
- ExpressionKeys<Pojo1> ek2 = new ExpressionKeys<>("b", t1);
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- Assert.assertTrue(ek2.areCompatible(ek1));
- }
-
- @Test
- public void testAreCompatible2() throws Keys.IncompatibleKeysException {
- TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
- TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO
- );
-
- ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
- ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- Assert.assertTrue(ek2.areCompatible(ek1));
- }
-
- @Test
- public void testAreCompatible3() throws Keys.IncompatibleKeysException {
- TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
- TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO
- );
-
- ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1);
- ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- Assert.assertTrue(ek2.areCompatible(ek1));
- }
-
- @Test
- public void testAreCompatible4() throws Keys.IncompatibleKeysException {
- TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
- TypeInformation<Tuple3<String, Long, Integer>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO,
- BasicTypeInfo.INT_TYPE_INFO
- );
-
- ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1", "i0"}, t1);
- ExpressionKeys<Tuple3<String, Long, Integer>> ek2 = new ExpressionKeys<>(new int[]{0, 0, 2}, t2);
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- Assert.assertTrue(ek2.areCompatible(ek1));
- }
-
- @Test
- public void testAreCompatible5() throws Keys.IncompatibleKeysException {
- TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
- TypeInformation<Tuple2<String, String>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO
- );
-
- ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1.b", "p2.a2"}, t1);
- ExpressionKeys<Tuple2<String, String>> ek2 = new ExpressionKeys<>("*", t2);
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- Assert.assertTrue(ek2.areCompatible(ek1));
- }
-
- @Test(expected = Keys.IncompatibleKeysException.class)
- public void testAreCompatible6() throws Keys.IncompatibleKeysException {
- TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
- TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO
- );
-
- ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1);
- ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(1, t2);
-
- ek1.areCompatible(ek2);
- }
-
- @Test(expected = Keys.IncompatibleKeysException.class)
- public void testAreCompatible7() throws Keys.IncompatibleKeysException {
- TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class);
- TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO
- );
-
- ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>(new String[]{"a", "b"}, t1);
- ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2);
-
- ek1.areCompatible(ek2);
- }
-
- @Test
- public void testAreCompatible8() throws Keys.IncompatibleKeysException {
- TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
- TypeInformation<Pojo2> t2 = TypeExtractor.getForClass(Pojo2.class);
-
- ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1);
- Keys<Pojo2> ek2 = new Keys.SelectorFunctionKeys<>(
- new KeySelector1(),
- t2,
- BasicTypeInfo.STRING_TYPE_INFO
- );
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- }
-
- @Test
- public void testAreCompatible9() throws Keys.IncompatibleKeysException {
- TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO,
- BasicTypeInfo.INT_TYPE_INFO
- );
- TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
-
- ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new ExpressionKeys<>(new int[]{2,0}, t1);
- Keys<PojoWithMultiplePojos> ek2 = new Keys.SelectorFunctionKeys<>(
- new KeySelector3(),
- t2,
- new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO)
- );
-
- Assert.assertTrue(ek1.areCompatible(ek2));
- }
-
- public static class Pojo1 {
- public String a;
- public String b;
- }
-
- public static class Pojo2 {
- public String a2;
- public String b2;
- }
-
- public static class PojoWithMultiplePojos {
- public Pojo1 p1;
- public Pojo2 p2;
- public Integer i0;
- }
-
- public static class PojoWithNonKeyField {
- public String a;
- public GenericNonKeyType b;
- }
-
- public static class GenericNonKeyType {
- private String a;
- private String b;
- }
-
- public static class GenericKeyType implements Comparable<GenericNonKeyType> {
- private String a;
- private String b;
-
- @Override
- public int compareTo(GenericNonKeyType o) {
- return 0;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/operators/NamesTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/operators/NamesTest.java b/flink-java/src/test/java/org/apache/flink/api/java/operators/NamesTest.java
index 5c2c7e9..09a705c 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/operators/NamesTest.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/operators/NamesTest.java
@@ -48,7 +48,7 @@ public class NamesTest implements Serializable {
public void testDefaultName() {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
- DataSet<String> strs = env.fromCollection(Arrays.asList( new String[] {"a", "b"}));
+ DataSet<String> strs = env.fromCollection(Arrays.asList("a", "b"));
// WARNING: The test will fail if this line is being moved down in the file (the line-number is hard-coded)
@@ -68,7 +68,7 @@ public class NamesTest implements Serializable {
public void testGivenName() {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
- DataSet<String> strs = env.fromCollection(Arrays.asList( new String[] {"a", "b"}));
+ DataSet<String> strs = env.fromCollection(Arrays.asList("a", "b"));
strs.filter(new FilterFunction<String>() {
private static final long serialVersionUID = 1L;
@Override
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/operators/SelectorFunctionKeysTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/operators/SelectorFunctionKeysTest.java b/flink-java/src/test/java/org/apache/flink/api/java/operators/SelectorFunctionKeysTest.java
deleted file mode 100644
index f59af6e..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/operators/SelectorFunctionKeysTest.java
+++ /dev/null
@@ -1,153 +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.java.operators;
-
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.operators.ExpressionKeysTest.PojoWithMultiplePojos;
-import org.apache.flink.api.java.operators.ExpressionKeysTest.Pojo1;
-import org.apache.flink.api.java.operators.ExpressionKeysTest.Pojo2;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SelectorFunctionKeysTest {
-
- @Test
- public void testAreCompatible1() throws Keys.IncompatibleKeysException {
- TypeInformation<Pojo2> t1 = TypeExtractor.getForClass(Pojo2.class);
- TypeInformation<Tuple2<Integer, String>> t2 =
- new TupleTypeInfo<>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);
-
- Keys<Pojo2> k1 = new Keys.SelectorFunctionKeys<>(
- new KeySelector1(),
- t1,
- BasicTypeInfo.STRING_TYPE_INFO
- );
- Keys<Tuple2<Integer, String>> k2 = new Keys.SelectorFunctionKeys<>(
- new KeySelector2(),
- t2,
- BasicTypeInfo.STRING_TYPE_INFO
- );
-
- Assert.assertTrue(k1.areCompatible(k2));
- Assert.assertTrue(k2.areCompatible(k1));
- }
-
- @Test
- public void testAreCompatible2() throws Keys.IncompatibleKeysException {
- TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
- TypeInformation<Tuple3<Long, Pojo1, Integer>> t2 = new TupleTypeInfo<>(
- BasicTypeInfo.LONG_TYPE_INFO,
- TypeExtractor.getForClass(Pojo1.class),
- BasicTypeInfo.INT_TYPE_INFO);
- TypeInformation<Tuple2<Integer, String>> kt = new TupleTypeInfo<>(
- BasicTypeInfo.INT_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO
- );
-
- Keys<PojoWithMultiplePojos> k1 = new Keys.SelectorFunctionKeys<>(
- new KeySelector3(),
- t1,
- kt
- );
- Keys<Tuple3<Long, Pojo1, Integer>> k2 = new Keys.SelectorFunctionKeys<>(
- new KeySelector4(),
- t2,
- kt
- );
-
- Assert.assertTrue(k1.areCompatible(k2));
- Assert.assertTrue(k2.areCompatible(k1));
- }
-
- @Test
- public void testAreCompatible3() throws Keys.IncompatibleKeysException {
- TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO;
- TypeInformation<Pojo2> t2 = TypeExtractor.getForClass(Pojo2.class);
-
- Keys.ExpressionKeys<String> ek1 = new Keys.ExpressionKeys<>("*", t1);
- Keys<Pojo2> sk2 = new Keys.SelectorFunctionKeys<>(
- new KeySelector1(),
- t2,
- BasicTypeInfo.STRING_TYPE_INFO
- );
-
- Assert.assertTrue(sk2.areCompatible(ek1));
- }
-
- @Test
- public void testAreCompatible4() throws Keys.IncompatibleKeysException {
- TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>(
- BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.LONG_TYPE_INFO,
- BasicTypeInfo.INT_TYPE_INFO
- );
- TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class);
-
- Keys.ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new Keys.ExpressionKeys<>(new int[]{2,0}, t1);
- Keys<PojoWithMultiplePojos> sk2 = new Keys.SelectorFunctionKeys<>(
- new KeySelector3(),
- t2,
- new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO)
- );
-
- Assert.assertTrue(sk2.areCompatible(ek1));
- }
-
- @SuppressWarnings("serial")
- public static class KeySelector1 implements KeySelector<Pojo2, String> {
-
- @Override
- public String getKey(Pojo2 v) throws Exception {
- return v.b2;
- }
- }
-
- @SuppressWarnings("serial")
- public static class KeySelector2 implements KeySelector<Tuple2<Integer, String>, String> {
-
- @Override
- public String getKey(Tuple2<Integer, String> v) throws Exception {
- return v.f1;
- }
- }
-
- @SuppressWarnings("serial")
- public static class KeySelector3 implements KeySelector<PojoWithMultiplePojos, Tuple2<Integer, String>> {
-
- @Override
- public Tuple2<Integer, String> getKey(PojoWithMultiplePojos v) throws Exception {
- return new Tuple2<>(v.i0, v.p1.b);
- }
- }
-
- @SuppressWarnings("serial")
- public static class KeySelector4 implements KeySelector<Tuple3<Long, Pojo1, Integer>, Tuple2<Integer, String>> {
-
- @Override
- public Tuple2<Integer, String> getKey(Tuple3<Long, Pojo1, Integer> v) throws Exception {
- return new Tuple2<>(v.f2, v.f1.a);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
index 8d8f801..a1ccfe4 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/sca/UdfAnalyzerTest.java
@@ -35,7 +35,7 @@ import org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields;
import org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsFirst;
import org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFieldsSecond;
import org.apache.flink.api.java.functions.SemanticPropUtil;
-import org.apache.flink.api.java.operators.Keys;
+import org.apache.flink.api.common.operators.Keys;
import org.apache.flink.api.java.tuple.Tuple1;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java b/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
deleted file mode 100644
index 0cc5dcf..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/tuple/Tuple2Test.java
+++ /dev/null
@@ -1,45 +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.java.tuple;
-
-import org.apache.flink.types.NullFieldException;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class Tuple2Test {
-
- @Test
- public void testSwapValues() {
- Tuple2<String, Integer> toSwap = new Tuple2<>("Test case", 25);
- Tuple2<Integer, String> swapped = toSwap.swap();
-
- Assert.assertEquals(swapped.f0, toSwap.f1);
-
- Assert.assertEquals(swapped.f1, toSwap.f0);
- }
-
- @Test(expected = NullFieldException.class)
- public void testGetFieldNotNull() {
- Tuple2<String, Integer> tuple = new Tuple2<>("Test case", null);
-
- Assert.assertEquals("Test case", tuple.getFieldNotNull(0));
- tuple.getFieldNotNull(1);
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeExtractionTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeExtractionTest.java b/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeExtractionTest.java
deleted file mode 100644
index 96ba264..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeExtractionTest.java
+++ /dev/null
@@ -1,876 +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.java.type.extractor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
-import org.apache.flink.api.java.ExecutionEnvironment;
-import org.apache.flink.api.java.tuple.Tuple1;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.api.java.typeutils.PojoField;
-import org.apache.flink.api.java.typeutils.PojoTypeInfo;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.typeutils.TypeInfoParser;
-import org.apache.flink.api.java.typeutils.TypeInfoParserTest.MyWritable;
-import org.apache.flink.api.java.typeutils.WritableTypeInfo;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.google.common.collect.HashMultiset;
-
-/**
- * Pojo Type tests
- *
- * A Pojo is a bean-style class with getters, setters and empty ctor
- * OR a class with all fields public (or for every private field, there has to be a public getter/setter)
- * everything else is a generic type (that can't be used for field selection)
- */
-public class PojoTypeExtractionTest {
-
- public static class HasDuplicateField extends WC {
- @SuppressWarnings("unused")
- private int count; // duplicate
- }
-
- @Test(expected=RuntimeException.class)
- public void testDuplicateFieldException() {
- TypeExtractor.createTypeInfo(HasDuplicateField.class);
- }
-
- // test with correct pojo types
- public static class WC { // is a pojo
- public ComplexNestedClass complex; // is a pojo
- private int count; // is a BasicType
-
- public WC() {
- }
- public int getCount() {
- return count;
- }
- public void setCount(int c) {
- this.count = c;
- }
- }
- public static class ComplexNestedClass { // pojo
- public static int ignoreStaticField;
- public transient int ignoreTransientField;
- public Date date; // generic type
- public Integer someNumberWithÜnicödeNäme; // BasicType
- public float someFloat; // BasicType
- public Tuple3<Long, Long, String> word; //Tuple Type with three basic types
- public Object nothing; // generic type
- public MyWritable hadoopCitizen; // writableType
- public List<String> collection;
- }
-
- // all public test
- public static class AllPublic extends ComplexNestedClass {
- public ArrayList<String> somethingFancy; // generic type
- public HashMultiset<Integer> fancyIds; // generic type
- public String[] fancyArray; // generic type
- }
-
- public static class ParentSettingGenerics extends PojoWithGenerics<Integer, Long> {
- public String field3;
- }
- public static class PojoWithGenerics<T1, T2> {
- public int key;
- public T1 field1;
- public T2 field2;
- }
-
- public static class ComplexHierarchyTop extends ComplexHierarchy<Tuple1<String>> {}
- public static class ComplexHierarchy<T> extends PojoWithGenerics<FromTuple,T> {}
-
- // extends from Tuple and adds a field
- public static class FromTuple extends Tuple3<String, String, Long> {
- private static final long serialVersionUID = 1L;
- public int special;
- }
-
- public static class IncorrectPojo {
- private int isPrivate;
- public int getIsPrivate() {
- return isPrivate;
- }
- // setter is missing (intentional)
- }
-
- // correct pojo
- public static class BeanStylePojo {
- public String abc;
- private int field;
- public int getField() {
- return this.field;
- }
- public void setField(int f) {
- this.field = f;
- }
- }
- public static class WrongCtorPojo {
- public int a;
- public WrongCtorPojo(int a) {
- this.a = a;
- }
- }
-
- public static class PojoWithGenericFields {
- private Collection<String> users;
- private boolean favorited;
-
- public boolean isFavorited() {
- return favorited;
- }
-
- public void setFavorited(boolean favorited) {
- this.favorited = favorited;
- }
-
- public Collection<String> getUsers() {
- return users;
- }
-
- public void setUsers(Collection<String> users) {
- this.users = users;
- }
- }
- @Test
- public void testPojoWithGenericFields() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(PojoWithGenericFields.class);
-
- Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
- }
-
-
- // in this test, the location of the getters and setters is mixed across the type hierarchy.
- public static class TypedPojoGetterSetterCheck extends GenericPojoGetterSetterCheck<String> {
- public void setPackageProtected(String in) {
- this.packageProtected = in;
- }
- }
- public static class GenericPojoGetterSetterCheck<T> {
- T packageProtected;
- public T getPackageProtected() {
- return packageProtected;
- }
- }
-
- @Test
- public void testIncorrectPojos() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(IncorrectPojo.class);
- Assert.assertTrue(typeForClass instanceof GenericTypeInfo<?>);
-
- typeForClass = TypeExtractor.createTypeInfo(WrongCtorPojo.class);
- Assert.assertTrue(typeForClass instanceof GenericTypeInfo<?>);
- }
-
- @Test
- public void testCorrectPojos() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(BeanStylePojo.class);
- Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
-
- typeForClass = TypeExtractor.createTypeInfo(TypedPojoGetterSetterCheck.class);
- Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
- }
-
- @Test
- public void testPojoWC() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(WC.class);
- checkWCPojoAsserts(typeForClass);
-
- WC t = new WC();
- t.complex = new ComplexNestedClass();
- TypeInformation<?> typeForObject = TypeExtractor.getForObject(t);
- checkWCPojoAsserts(typeForObject);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private void checkWCPojoAsserts(TypeInformation<?> typeInfo) {
- Assert.assertFalse(typeInfo.isBasicType());
- Assert.assertFalse(typeInfo.isTupleType());
- Assert.assertEquals(10, typeInfo.getTotalFields());
- Assert.assertTrue(typeInfo instanceof PojoTypeInfo);
- PojoTypeInfo<?> pojoType = (PojoTypeInfo<?>) typeInfo;
-
- List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
- String[] fields = {"count",
- "complex.date",
- "complex.hadoopCitizen",
- "complex.collection",
- "complex.nothing",
- "complex.someFloat",
- "complex.someNumberWithÜnicödeNäme",
- "complex.word.f0",
- "complex.word.f1",
- "complex.word.f2"};
- int[] positions = {9,
- 1,
- 2,
- 0,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8};
- Assert.assertEquals(fields.length, positions.length);
- for(int i = 0; i < fields.length; i++) {
- pojoType.getFlatFields(fields[i], 0, ffd);
- Assert.assertEquals("Too many keys returned", 1, ffd.size());
- Assert.assertEquals("position of field "+fields[i]+" wrong", positions[i], ffd.get(0).getPosition());
- ffd.clear();
- }
-
- pojoType.getFlatFields("complex.word.*", 0, ffd);
- Assert.assertEquals(3, ffd.size());
- // check if it returns 5,6,7
- for(FlatFieldDescriptor ffdE : ffd) {
- final int pos = ffdE.getPosition();
- Assert.assertTrue(pos <= 8 );
- Assert.assertTrue(6 <= pos );
- if(pos == 6) {
- Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
- }
- if(pos == 7) {
- Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
- }
- if(pos == 8) {
- Assert.assertEquals(String.class, ffdE.getType().getTypeClass());
- }
- }
- ffd.clear();
-
- // scala style full tuple selection for pojos
- pojoType.getFlatFields("complex.word._", 0, ffd);
- Assert.assertEquals(3, ffd.size());
- ffd.clear();
-
- pojoType.getFlatFields("complex.*", 0, ffd);
- Assert.assertEquals(9, ffd.size());
- // check if it returns 0-7
- for(FlatFieldDescriptor ffdE : ffd) {
- final int pos = ffdE.getPosition();
- Assert.assertTrue(ffdE.getPosition() <= 8 );
- Assert.assertTrue(0 <= ffdE.getPosition() );
-
- if(pos == 0) {
- Assert.assertEquals(List.class, ffdE.getType().getTypeClass());
- }
- if(pos == 1) {
- Assert.assertEquals(Date.class, ffdE.getType().getTypeClass());
- }
- if(pos == 2) {
- Assert.assertEquals(MyWritable.class, ffdE.getType().getTypeClass());
- }
- if(pos == 3) {
- Assert.assertEquals(Object.class, ffdE.getType().getTypeClass());
- }
- if(pos == 4) {
- Assert.assertEquals(Float.class, ffdE.getType().getTypeClass());
- }
- if(pos == 5) {
- Assert.assertEquals(Integer.class, ffdE.getType().getTypeClass());
- }
- if(pos == 6) {
- Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
- }
- if(pos == 7) {
- Assert.assertEquals(Long.class, ffdE.getType().getTypeClass());
- }
- if(pos == 8) {
- Assert.assertEquals(String.class, ffdE.getType().getTypeClass());
- }
- if(pos == 9) {
- Assert.assertEquals(Integer.class, ffdE.getType().getTypeClass());
- }
- }
- ffd.clear();
-
- pojoType.getFlatFields("*", 0, ffd);
- Assert.assertEquals(10, ffd.size());
- // check if it returns 0-8
- for(FlatFieldDescriptor ffdE : ffd) {
- Assert.assertTrue(ffdE.getPosition() <= 9 );
- Assert.assertTrue(0 <= ffdE.getPosition() );
- if(ffdE.getPosition() == 9) {
- Assert.assertEquals(Integer.class, ffdE.getType().getTypeClass());
- }
- }
- ffd.clear();
-
- TypeInformation<?> typeComplexNested = pojoType.getTypeAt(0); // ComplexNestedClass complex
- Assert.assertTrue(typeComplexNested instanceof PojoTypeInfo);
-
- Assert.assertEquals(7, typeComplexNested.getArity());
- Assert.assertEquals(9, typeComplexNested.getTotalFields());
- PojoTypeInfo<?> pojoTypeComplexNested = (PojoTypeInfo<?>) typeComplexNested;
-
- boolean dateSeen = false, intSeen = false, floatSeen = false,
- tupleSeen = false, objectSeen = false, writableSeen = false, collectionSeen = false;
- for(int i = 0; i < pojoTypeComplexNested.getArity(); i++) {
- PojoField field = pojoTypeComplexNested.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("date")) {
- if(dateSeen) {
- Assert.fail("already seen");
- }
- dateSeen = true;
- Assert.assertEquals(BasicTypeInfo.DATE_TYPE_INFO, field.getTypeInformation());
- Assert.assertEquals(Date.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("someNumberWithÜnicödeNäme")) {
- if(intSeen) {
- Assert.fail("already seen");
- }
- intSeen = true;
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- Assert.assertEquals(Integer.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("someFloat")) {
- if(floatSeen) {
- Assert.fail("already seen");
- }
- floatSeen = true;
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, field.getTypeInformation());
- Assert.assertEquals(Float.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("word")) {
- if(tupleSeen) {
- Assert.fail("already seen");
- }
- tupleSeen = true;
- Assert.assertTrue(field.getTypeInformation() instanceof TupleTypeInfo<?>);
- Assert.assertEquals(Tuple3.class, field.getTypeInformation().getTypeClass());
- // do some more advanced checks on the tuple
- TupleTypeInfo<?> tupleTypeFromComplexNested = (TupleTypeInfo<?>) field.getTypeInformation();
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tupleTypeFromComplexNested.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tupleTypeFromComplexNested.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tupleTypeFromComplexNested.getTypeAt(2));
- } else if(name.equals("nothing")) {
- if(objectSeen) {
- Assert.fail("already seen");
- }
- objectSeen = true;
- Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.getTypeInformation());
- Assert.assertEquals(Object.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("hadoopCitizen")) {
- if(writableSeen) {
- Assert.fail("already seen");
- }
- writableSeen = true;
- Assert.assertEquals(new WritableTypeInfo<MyWritable>(MyWritable.class), field.getTypeInformation());
- Assert.assertEquals(MyWritable.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("collection")) {
- if(collectionSeen) {
- Assert.fail("already seen");
- }
- collectionSeen = true;
- Assert.assertEquals(new GenericTypeInfo(List.class), field.getTypeInformation());
-
- } else {
- Assert.fail("field "+field+" is not expected");
- }
- }
- Assert.assertTrue("Field was not present", dateSeen);
- Assert.assertTrue("Field was not present", intSeen);
- Assert.assertTrue("Field was not present", floatSeen);
- Assert.assertTrue("Field was not present", tupleSeen);
- Assert.assertTrue("Field was not present", objectSeen);
- Assert.assertTrue("Field was not present", writableSeen);
- Assert.assertTrue("Field was not present", collectionSeen);
-
- TypeInformation<?> typeAtOne = pojoType.getTypeAt(1); // int count
- Assert.assertTrue(typeAtOne instanceof BasicTypeInfo);
-
- Assert.assertEquals(typeInfo.getTypeClass(), WC.class);
- Assert.assertEquals(typeInfo.getArity(), 2);
- }
-
- @Test
- public void testPojoAllPublic() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(AllPublic.class);
- checkAllPublicAsserts(typeForClass);
-
- TypeInformation<?> typeForObject = TypeExtractor.getForObject(new AllPublic() );
- checkAllPublicAsserts(typeForObject);
- }
-
- private void checkAllPublicAsserts(TypeInformation<?> typeInformation) {
- Assert.assertTrue(typeInformation instanceof PojoTypeInfo);
- Assert.assertEquals(10, typeInformation.getArity());
- Assert.assertEquals(12, typeInformation.getTotalFields());
- // check if the three additional fields are identified correctly
- boolean arrayListSeen = false, multisetSeen = false, strArraySeen = false;
- PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeInformation;
- for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
- PojoField field = pojoTypeForClass.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("somethingFancy")) {
- if(arrayListSeen) {
- Assert.fail("already seen");
- }
- arrayListSeen = true;
- Assert.assertTrue(field.getTypeInformation() instanceof GenericTypeInfo);
- Assert.assertEquals(ArrayList.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("fancyIds")) {
- if(multisetSeen) {
- Assert.fail("already seen");
- }
- multisetSeen = true;
- Assert.assertTrue(field.getTypeInformation() instanceof GenericTypeInfo);
- Assert.assertEquals(HashMultiset.class, field.getTypeInformation().getTypeClass());
- } else if(name.equals("fancyArray")) {
- if(strArraySeen) {
- Assert.fail("already seen");
- }
- strArraySeen = true;
- Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, field.getTypeInformation());
- Assert.assertEquals(String[].class, field.getTypeInformation().getTypeClass());
- } else if(Arrays.asList("date", "someNumberWithÜnicödeNäme", "someFloat", "word", "nothing", "hadoopCitizen", "collection").contains(name)) {
- // ignore these, they are inherited from the ComplexNestedClass
- }
- else {
- Assert.fail("field "+field+" is not expected");
- }
- }
- Assert.assertTrue("Field was not present", arrayListSeen);
- Assert.assertTrue("Field was not present", multisetSeen);
- Assert.assertTrue("Field was not present", strArraySeen);
- }
-
- @Test
- public void testPojoExtendingTuple() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(FromTuple.class);
- checkFromTuplePojo(typeForClass);
-
- FromTuple ft = new FromTuple();
- ft.f0 = ""; ft.f1 = ""; ft.f2 = 0L;
- TypeInformation<?> typeForObject = TypeExtractor.getForObject(ft);
- checkFromTuplePojo(typeForObject);
- }
-
- private void checkFromTuplePojo(TypeInformation<?> typeInformation) {
- Assert.assertTrue(typeInformation instanceof PojoTypeInfo<?>);
- Assert.assertEquals(4, typeInformation.getTotalFields());
- PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeInformation;
- for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
- PojoField field = pojoTypeForClass.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("special")) {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- } else if(name.equals("f0") || name.equals("f1")) {
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
- } else if(name.equals("f2")) {
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.getTypeInformation());
- } else {
- Assert.fail("unexpected field");
- }
- }
- }
-
- @Test
- public void testPojoWithGenerics() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(ParentSettingGenerics.class);
- Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
- PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
- for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
- PojoField field = pojoTypeForClass.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("field1")) {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("field2")) {
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("field3")) {
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("key")) {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- } else {
- Assert.fail("Unexpected field "+field);
- }
- }
- }
-
- /**
- * Test if the TypeExtractor is accepting untyped generics,
- * making them GenericTypes
- */
- @Test
- public void testPojoWithGenericsSomeFieldsGeneric() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(PojoWithGenerics.class);
- Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
- PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
- for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
- PojoField field = pojoTypeForClass.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("field1")) {
- Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.getTypeInformation());
- } else if (name.equals("field2")) {
- Assert.assertEquals(new GenericTypeInfo<Object>(Object.class), field.getTypeInformation());
- } else if (name.equals("key")) {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- } else {
- Assert.fail("Unexpected field "+field);
- }
- }
- }
-
-
- @Test
- public void testPojoWithComplexHierarchy() {
- TypeInformation<?> typeForClass = TypeExtractor.createTypeInfo(ComplexHierarchyTop.class);
- Assert.assertTrue(typeForClass instanceof PojoTypeInfo<?>);
- PojoTypeInfo<?> pojoTypeForClass = (PojoTypeInfo<?>) typeForClass;
- for(int i = 0; i < pojoTypeForClass.getArity(); i++) {
- PojoField field = pojoTypeForClass.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("field1")) {
- Assert.assertTrue(field.getTypeInformation() instanceof PojoTypeInfo<?>); // From tuple is pojo (not tuple type!)
- } else if (name.equals("field2")) {
- Assert.assertTrue(field.getTypeInformation() instanceof TupleTypeInfo<?>);
- Assert.assertTrue( ((TupleTypeInfo<?>)field.getTypeInformation()).getTypeAt(0).equals(BasicTypeInfo.STRING_TYPE_INFO) );
- } else if (name.equals("key")) {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- } else {
- Assert.fail("Unexpected field "+field);
- }
- }
- }
-
-
- public static class Vertex<K, V> {
-
- private K key1;
- private K key2;
- private V value;
-
- public Vertex() {}
-
- public Vertex(K key, V value) {
- this.key1 = key;
- this.key2 = key;
- this.value = value;
- }
-
- public Vertex(K key1, K key2, V value) {
- this.key1 = key1;
- this.key2 = key2;
- this.value = value;
- }
-
- public void setKey1(K key1) {
- this.key1 = key1;
- }
-
- public void setKey2(K key2) {
- this.key2 = key2;
- }
-
- public K getKey1() {
- return key1;
- }
-
- public K getKey2() {
- return key2;
- }
-
- public void setValue(V value) {
- this.value = value;
- }
-
- public V getValue() {
- return value;
- }
- }
-
- public static class VertexTyped extends Vertex<Long, Double>{
- public VertexTyped(Long l, Double d) {
- super(l, d);
- }
- public VertexTyped() {
- }
- }
-
- @Test
- public void testGetterSetterWithVertex() {
- ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
- env.fromElements(new VertexTyped(0L, 3.0), new VertexTyped(1L, 1.0));
- }
-
- public static class MyMapper<T> implements MapFunction<PojoWithGenerics<Long, T>, PojoWithGenerics<T,T>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public PojoWithGenerics<T, T> map(PojoWithGenerics<Long, T> value)
- throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference1() {
- MapFunction<?, ?> function = new MyMapper<String>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoWithGenerics<key=int,field1=Long,field2=String>"));
- Assert.assertTrue(ti instanceof PojoTypeInfo<?>);
- PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
- for(int i = 0; i < pti.getArity(); i++) {
- PojoField field = pti.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("field1")) {
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("field2")) {
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("key")) {
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, field.getTypeInformation());
- } else {
- Assert.fail("Unexpected field "+field);
- }
- }
- }
-
- public static class PojoTuple<A, B, C> extends Tuple3<B, C, Long> {
- private static final long serialVersionUID = 1L;
-
- public A extraField;
- }
-
- public static class MyMapper2<D, E> implements MapFunction<Tuple2<E, D>, PojoTuple<E, D, D>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public PojoTuple<E, D, D> map(Tuple2<E, D> value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference2() {
- MapFunction<?, ?> function = new MyMapper2<Boolean, Character>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("Tuple2<Character,Boolean>"));
- Assert.assertTrue(ti instanceof PojoTypeInfo<?>);
- PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
- for(int i = 0; i < pti.getArity(); i++) {
- PojoField field = pti.getPojoFieldAt(i);
- String name = field.getField().getName();
- if(name.equals("extraField")) {
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("f0")) {
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("f1")) {
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, field.getTypeInformation());
- } else if (name.equals("f2")) {
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, field.getTypeInformation());
- } else {
- Assert.fail("Unexpected field "+field);
- }
- }
- }
-
- public static class MyMapper3<D, E> implements MapFunction<PojoTuple<E, D, D>, Tuple2<E, D>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<E, D> map(PojoTuple<E, D, D> value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference3() {
- MapFunction<?, ?> function = new MyMapper3<Boolean, Character>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoTuple<extraField=char,f0=boolean,f1=boolean,f2=long>"));
- Assert.assertTrue(ti instanceof TupleTypeInfo<?>);
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public static class PojoWithParameterizedFields1<Z> {
- public Tuple2<Z, Z> field;
- }
-
- public static class MyMapper4<A> implements MapFunction<PojoWithParameterizedFields1<A>, A> {
- private static final long serialVersionUID = 1L;
- @Override
- public A map(PojoWithParameterizedFields1<A> value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference4() {
- MapFunction<?, ?> function = new MyMapper4<Byte>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoWithParameterizedFields1<field=Tuple2<byte,byte>>"));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, ti);
- }
-
- public static class PojoWithParameterizedFields2<Z> {
- public PojoWithGenerics<Z, Z> field;
- }
-
- public static class MyMapper5<A> implements MapFunction<PojoWithParameterizedFields2<A>, A> {
- private static final long serialVersionUID = 1L;
- @Override
- public A map(PojoWithParameterizedFields2<A> value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference5() {
- MapFunction<?, ?> function = new MyMapper5<Byte>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoWithParameterizedFields2<"
- + "field=org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoWithGenerics<key=int,field1=byte,field2=byte>"
- + ">"));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, ti);
- }
-
- public static class PojoWithParameterizedFields3<Z> {
- public Z[] field;
- }
-
- public static class MyMapper6<A> implements MapFunction<PojoWithParameterizedFields3<A>, A> {
- private static final long serialVersionUID = 1L;
- @Override
- public A map(PojoWithParameterizedFields3<A> value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference6() {
- MapFunction<?, ?> function = new MyMapper6<Integer>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoWithParameterizedFields3<"
- + "field=int[]"
- + ">"));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
- }
-
- public static class MyMapper7<A> implements MapFunction<PojoWithParameterizedFields4<A>, A> {
- private static final long serialVersionUID = 1L;
- @Override
- public A map(PojoWithParameterizedFields4<A> value) throws Exception {
- return null;
- }
- }
-
- public static class PojoWithParameterizedFields4<Z> {
- public Tuple1<Z>[] field;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericPojoTypeInference7() {
- MapFunction<?, ?> function = new MyMapper7<Integer>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation)
- TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.PojoTypeExtractionTest$PojoWithParameterizedFields4<"
- + "field=Tuple1<int>[]"
- + ">"));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
- }
-
- public static class RecursivePojo1 {
- public RecursivePojo1 field;
- }
-
- public static class RecursivePojo2 {
- public Tuple1<RecursivePojo2> field;
- }
-
- public static class RecursivePojo3 {
- public NestedPojo field;
- }
-
- public static class NestedPojo {
- public RecursivePojo3 field;
- }
-
- @Test
- public void testRecursivePojo1() {
- TypeInformation<?> ti = TypeExtractor.createTypeInfo(RecursivePojo1.class);
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- Assert.assertEquals(GenericTypeInfo.class, ((PojoTypeInfo) ti).getPojoFieldAt(0).getTypeInformation().getClass());
- }
-
- @Test
- public void testRecursivePojo2() {
- TypeInformation<?> ti = TypeExtractor.createTypeInfo(RecursivePojo2.class);
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- PojoField pf = ((PojoTypeInfo) ti).getPojoFieldAt(0);
- Assert.assertTrue(pf.getTypeInformation() instanceof TupleTypeInfo);
- Assert.assertEquals(GenericTypeInfo.class, ((TupleTypeInfo) pf.getTypeInformation()).getTypeAt(0).getClass());
- }
-
- @Test
- public void testRecursivePojo3() {
- TypeInformation<?> ti = TypeExtractor.createTypeInfo(RecursivePojo3.class);
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- PojoField pf = ((PojoTypeInfo) ti).getPojoFieldAt(0);
- Assert.assertTrue(pf.getTypeInformation() instanceof PojoTypeInfo);
- Assert.assertEquals(GenericTypeInfo.class, ((PojoTypeInfo) pf.getTypeInformation()).getPojoFieldAt(0).getTypeInformation().getClass());
- }
-
- public static class FooBarPojo {
- public int foo, bar;
- public FooBarPojo() {}
- }
-
- public static class DuplicateMapper implements MapFunction<FooBarPojo, Tuple2<FooBarPojo, FooBarPojo>> {
- @Override
- public Tuple2<FooBarPojo, FooBarPojo> map(FooBarPojo value) throws Exception {
- return null;
- }
- }
-
- @Test
- public void testDualUseOfPojo() {
- MapFunction<?, ?> function = new DuplicateMapper();
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeExtractor.createTypeInfo(FooBarPojo.class));
- Assert.assertTrue(ti instanceof TupleTypeInfo);
- TupleTypeInfo<?> tti = ((TupleTypeInfo) ti);
- Assert.assertTrue(tti.getTypeAt(0) instanceof PojoTypeInfo);
- Assert.assertTrue(tti.getTypeAt(1) instanceof PojoTypeInfo);
- }
-}
[19/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java
new file mode 100644
index 0000000..c0c7797
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoComparator.java
@@ -0,0 +1,354 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.flink.api.common.typeutils.CompositeTypeComparator;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.types.NullKeyFieldException;
+import org.apache.flink.util.InstantiationUtil;
+
+
+public final class PojoComparator<T> extends CompositeTypeComparator<T> implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ // Reflection fields for the comp fields
+ private transient Field[] keyFields;
+
+ private final TypeComparator<Object>[] comparators;
+
+ private final int[] normalizedKeyLengths;
+
+ private final int numLeadingNormalizableKeys;
+
+ private final int normalizableKeyPrefixLen;
+
+ private final boolean invertNormKey;
+
+ private TypeSerializer<T> serializer;
+
+ private final Class<T> type;
+
+ @SuppressWarnings("unchecked")
+ public PojoComparator(Field[] keyFields, TypeComparator<?>[] comparators, TypeSerializer<T> serializer, Class<T> type) {
+ this.keyFields = keyFields;
+ this.comparators = (TypeComparator<Object>[]) comparators;
+
+ this.type = type;
+ this.serializer = serializer;
+
+ // set up auxiliary fields for normalized key support
+ this.normalizedKeyLengths = new int[keyFields.length];
+ int nKeys = 0;
+ int nKeyLen = 0;
+ boolean inverted = false;
+
+ for (int i = 0; i < this.comparators.length; i++) {
+ TypeComparator<?> k = this.comparators[i];
+ if(k == null) {
+ throw new IllegalArgumentException("One of the passed comparators is null");
+ }
+ if(keyFields[i] == null) {
+ throw new IllegalArgumentException("One of the passed reflection fields is null");
+ }
+
+ // as long as the leading keys support normalized keys, we can build up the composite key
+ if (k.supportsNormalizedKey()) {
+ if (i == 0) {
+ // the first comparator decides whether we need to invert the key direction
+ inverted = k.invertNormalizedKey();
+ }
+ else if (k.invertNormalizedKey() != inverted) {
+ // if a successor does not agree on the invertion direction, it cannot be part of the normalized key
+ break;
+ }
+
+ nKeys++;
+ final int len = k.getNormalizeKeyLen();
+ if (len < 0) {
+ throw new RuntimeException("Comparator " + k.getClass().getName() + " specifies an invalid length for the normalized key: " + len);
+ }
+ this.normalizedKeyLengths[i] = len;
+ nKeyLen += this.normalizedKeyLengths[i];
+
+ if (nKeyLen < 0) {
+ // overflow, which means we are out of budget for normalized key space anyways
+ nKeyLen = Integer.MAX_VALUE;
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ this.numLeadingNormalizableKeys = nKeys;
+ this.normalizableKeyPrefixLen = nKeyLen;
+ this.invertNormKey = inverted;
+ }
+
+ @SuppressWarnings("unchecked")
+ private PojoComparator(PojoComparator<T> toClone) {
+ this.keyFields = toClone.keyFields;
+ this.comparators = new TypeComparator[toClone.comparators.length];
+
+ for (int i = 0; i < toClone.comparators.length; i++) {
+ this.comparators[i] = toClone.comparators[i].duplicate();
+ }
+
+ this.normalizedKeyLengths = toClone.normalizedKeyLengths;
+ this.numLeadingNormalizableKeys = toClone.numLeadingNormalizableKeys;
+ this.normalizableKeyPrefixLen = toClone.normalizableKeyPrefixLen;
+ this.invertNormKey = toClone.invertNormKey;
+
+ this.type = toClone.type;
+
+ try {
+ this.serializer = (TypeSerializer<T>) InstantiationUtil.deserializeObject(
+ InstantiationUtil.serializeObject(toClone.serializer), Thread.currentThread().getContextClassLoader());
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot copy serializer", e);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Cannot copy serializer", e);
+ }
+ }
+
+ private void writeObject(ObjectOutputStream out)
+ throws IOException, ClassNotFoundException {
+ out.defaultWriteObject();
+ out.writeInt(keyFields.length);
+ for (Field field: keyFields) {
+ out.writeObject(field.getDeclaringClass());
+ out.writeUTF(field.getName());
+ }
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ int numKeyFields = in.readInt();
+ keyFields = new Field[numKeyFields];
+ for (int i = 0; i < numKeyFields; i++) {
+ Class<?> clazz = (Class<?>) in.readObject();
+ String fieldName = in.readUTF();
+ // try superclasses as well
+ while (clazz != null) {
+ try {
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ keyFields[i] = field;
+ break;
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ if (keyFields[i] == null ) {
+ throw new RuntimeException("Class resolved at TaskManager is not compatible with class read during Plan setup."
+ + " (" + fieldName + ")");
+ }
+ }
+ }
+
+ public Field[] getKeyFields() {
+ return this.keyFields;
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void getFlatComparator(List<TypeComparator> flatComparators) {
+ for(int i = 0; i < comparators.length; i++) {
+ if(comparators[i] instanceof CompositeTypeComparator) {
+ ((CompositeTypeComparator)comparators[i]).getFlatComparator(flatComparators);
+ } else {
+ flatComparators.add(comparators[i]);
+ }
+ }
+ }
+
+ /**
+ * This method is handling the IllegalAccess exceptions of Field.get()
+ */
+ public final Object accessField(Field field, Object object) {
+ try {
+ object = field.get(object);
+ } catch (NullPointerException npex) {
+ throw new NullKeyFieldException("Unable to access field "+field+" on object "+object);
+ } catch (IllegalAccessException iaex) {
+ throw new RuntimeException("This should not happen since we call setAccesssible(true) in PojoTypeInfo."
+ + " fields: " + field + " obj: " + object);
+ }
+ return object;
+ }
+
+ @Override
+ public int hash(T value) {
+ int i = 0;
+ int code = 0;
+ for (; i < this.keyFields.length; i++) {
+ code *= TupleComparatorBase.HASH_SALT[i & 0x1F];
+ try {
+ code += this.comparators[i].hash(accessField(keyFields[i], value));
+ }catch(NullPointerException npe) {
+ throw new RuntimeException("A NullPointerException occured while accessing a key field in a POJO. " +
+ "Most likely, the value grouped/joined on is null. Field name: "+keyFields[i].getName(), npe);
+ }
+ }
+ return code;
+
+ }
+
+ @Override
+ public void setReference(T toCompare) {
+ int i = 0;
+ for (; i < this.keyFields.length; i++) {
+ this.comparators[i].setReference(accessField(keyFields[i], toCompare));
+ }
+ }
+
+ @Override
+ public boolean equalToReference(T candidate) {
+ int i = 0;
+ for (; i < this.keyFields.length; i++) {
+ if (!this.comparators[i].equalToReference(accessField(keyFields[i], candidate))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int compareToReference(TypeComparator<T> referencedComparator) {
+ PojoComparator<T> other = (PojoComparator<T>) referencedComparator;
+
+ int i = 0;
+ try {
+ for (; i < this.keyFields.length; i++) {
+ int cmp = this.comparators[i].compareToReference(other.comparators[i]);
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+ return 0;
+ }
+ catch (NullPointerException npex) {
+ throw new NullKeyFieldException(this.keyFields[i].toString());
+ }
+ }
+
+ @Override
+ public int compare(T first, T second) {
+ int i = 0;
+ for (; i < keyFields.length; i++) {
+ int cmp = comparators[i].compare(accessField(keyFields[i], first), accessField(keyFields[i], second));
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+
+ return 0;
+ }
+
+
+ @Override
+ public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
+ T first = this.serializer.createInstance();
+ T second = this.serializer.createInstance();
+
+ first = this.serializer.deserialize(first, firstSource);
+ second = this.serializer.deserialize(second, secondSource);
+
+ return this.compare(first, second);
+ }
+
+ @Override
+ public boolean supportsNormalizedKey() {
+ return this.numLeadingNormalizableKeys > 0;
+ }
+
+ @Override
+ public int getNormalizeKeyLen() {
+ return this.normalizableKeyPrefixLen;
+ }
+
+ @Override
+ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
+ return this.numLeadingNormalizableKeys < this.keyFields.length ||
+ this.normalizableKeyPrefixLen == Integer.MAX_VALUE ||
+ this.normalizableKeyPrefixLen > keyBytes;
+ }
+
+ @Override
+ public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
+ int i = 0;
+ for (; i < this.numLeadingNormalizableKeys & numBytes > 0; i++)
+ {
+ int len = this.normalizedKeyLengths[i];
+ len = numBytes >= len ? len : numBytes;
+ this.comparators[i].putNormalizedKey(accessField(keyFields[i], value), target, offset, len);
+ numBytes -= len;
+ offset += len;
+ }
+ }
+
+ @Override
+ public boolean invertNormalizedKey() {
+ return this.invertNormKey;
+ }
+
+
+ @Override
+ public boolean supportsSerializationWithKeyNormalization() {
+ return false;
+ }
+
+ @Override
+ public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PojoComparator<T> duplicate() {
+ return new PojoComparator<T>(this);
+ }
+
+ @Override
+ public int extractKeys(Object record, Object[] target, int index) {
+ int localIndex = index;
+ for (int i = 0; i < comparators.length; i++) {
+ localIndex += comparators[i].extractKeys(accessField(keyFields[i], record), target, localIndex);
+ }
+ return localIndex - index;
+ }
+
+ // --------------------------------------------------------------------------------------------
+}
+
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java
new file mode 100644
index 0000000..de24956
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java
@@ -0,0 +1,592 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+
+
+public final class PojoSerializer<T> extends TypeSerializer<T> {
+
+ // Flags for the header
+ private static byte IS_NULL = 1;
+ private static byte NO_SUBCLASS = 2;
+ private static byte IS_SUBCLASS = 4;
+ private static byte IS_TAGGED_SUBCLASS = 8;
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> clazz;
+
+ private final TypeSerializer<Object>[] fieldSerializers;
+
+ private final int numFields;
+
+ private final Map<Class<?>, Integer> registeredClasses;
+
+ private final TypeSerializer<?>[] registeredSerializers;
+
+ private final ExecutionConfig executionConfig;
+
+ private transient Map<Class<?>, TypeSerializer<?>> subclassSerializerCache;
+ private transient ClassLoader cl;
+ // We need to handle these ourselves in writeObject()/readObject()
+ private transient Field[] fields;
+
+ @SuppressWarnings("unchecked")
+ public PojoSerializer(
+ Class<T> clazz,
+ TypeSerializer<?>[] fieldSerializers,
+ Field[] fields,
+ ExecutionConfig executionConfig) {
+
+ this.clazz = Preconditions.checkNotNull(clazz);
+ this.fieldSerializers = (TypeSerializer<Object>[]) Preconditions.checkNotNull(fieldSerializers);
+ this.fields = Preconditions.checkNotNull(fields);
+ this.numFields = fieldSerializers.length;
+ this.executionConfig = Preconditions.checkNotNull(executionConfig);
+
+ LinkedHashSet<Class<?>> registeredPojoTypes = executionConfig.getRegisteredPojoTypes();
+
+ for (int i = 0; i < numFields; i++) {
+ this.fields[i].setAccessible(true);
+ }
+
+ cl = Thread.currentThread().getContextClassLoader();
+
+ subclassSerializerCache = new HashMap<Class<?>, TypeSerializer<?>>();
+
+ // We only want those classes that are not our own class and are actually sub-classes.
+ List<Class<?>> cleanedTaggedClasses = new ArrayList<Class<?>>(registeredPojoTypes.size());
+ for (Class<?> registeredClass: registeredPojoTypes) {
+ if (registeredClass.equals(clazz)) {
+ continue;
+ }
+ if (!clazz.isAssignableFrom(registeredClass)) {
+ continue;
+ }
+ cleanedTaggedClasses.add(registeredClass);
+
+ }
+ this.registeredClasses = new LinkedHashMap<Class<?>, Integer>(cleanedTaggedClasses.size());
+ registeredSerializers = new TypeSerializer[cleanedTaggedClasses.size()];
+
+ int id = 0;
+ for (Class<?> registeredClass: cleanedTaggedClasses) {
+ this.registeredClasses.put(registeredClass, id);
+ TypeInformation<?> typeInfo = TypeExtractor.createTypeInfo(registeredClass);
+ registeredSerializers[id] = typeInfo.createSerializer(executionConfig);
+
+ id++;
+ }
+ }
+
+ private void writeObject(ObjectOutputStream out)
+ throws IOException, ClassNotFoundException {
+ out.defaultWriteObject();
+ out.writeInt(fields.length);
+ for (Field field: fields) {
+ out.writeObject(field.getDeclaringClass());
+ out.writeUTF(field.getName());
+ }
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ int numFields = in.readInt();
+ fields = new Field[numFields];
+ for (int i = 0; i < numFields; i++) {
+ Class<?> clazz = (Class<?>)in.readObject();
+ String fieldName = in.readUTF();
+ fields[i] = null;
+ // try superclasses as well
+ while (clazz != null) {
+ try {
+ fields[i] = clazz.getDeclaredField(fieldName);
+ fields[i].setAccessible(true);
+ break;
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ if (fields[i] == null) {
+ throw new RuntimeException("Class resolved at TaskManager is not compatible with class read during Plan setup."
+ + " (" + fieldName + ")");
+ }
+ }
+
+ cl = Thread.currentThread().getContextClassLoader();
+ subclassSerializerCache = new HashMap<Class<?>, TypeSerializer<?>>();
+ }
+
+ private TypeSerializer<?> getSubclassSerializer(Class<?> subclass) {
+ TypeSerializer<?> result = subclassSerializerCache.get(subclass);
+ if (result == null) {
+
+ TypeInformation<?> typeInfo = TypeExtractor.createTypeInfo(subclass);
+ result = typeInfo.createSerializer(executionConfig);
+ if (result instanceof PojoSerializer) {
+ PojoSerializer<?> subclassSerializer = (PojoSerializer<?>) result;
+ subclassSerializer.copyBaseFieldOrder(this);
+ }
+ subclassSerializerCache.put(subclass, result);
+
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unused")
+ private boolean hasField(Field f) {
+ for (Field field: fields) {
+ if (f.equals(field)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void copyBaseFieldOrder(PojoSerializer<?> baseSerializer) {
+ // do nothing for now, but in the future, adapt subclass serializer to have same
+ // ordering as base class serializer so that binary comparison on base class fields
+ // can work
+ }
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public PojoSerializer<T> duplicate() {
+ boolean stateful = false;
+ TypeSerializer<?>[] duplicateFieldSerializers = new TypeSerializer[fieldSerializers.length];
+
+ for (int i = 0; i < fieldSerializers.length; i++) {
+ duplicateFieldSerializers[i] = fieldSerializers[i].duplicate();
+ if (duplicateFieldSerializers[i] != fieldSerializers[i]) {
+ // at least one of them is stateful
+ stateful = true;
+ }
+ }
+
+ if (stateful) {
+ return new PojoSerializer<T>(clazz, duplicateFieldSerializers, fields, executionConfig);
+ } else {
+ return this;
+ }
+ }
+
+
+ @Override
+ public T createInstance() {
+ if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
+ return null;
+ }
+ try {
+ T t = clazz.newInstance();
+ initializeFields(t);
+ return t;
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Cannot instantiate class.", e);
+ }
+ }
+
+ protected void initializeFields(T t) {
+ for (int i = 0; i < numFields; i++) {
+ try {
+ fields[i].set(t, fieldSerializers[i].createInstance());
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Cannot initialize fields.", e);
+ }
+ }
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public T copy(T from) {
+ if (from == null) {
+ return null;
+ }
+
+ Class<?> actualType = from.getClass();
+ if (actualType == clazz) {
+ T target;
+ try {
+ target = (T) from.getClass().newInstance();
+ }
+ catch (Throwable t) {
+ throw new RuntimeException("Cannot instantiate class.", t);
+ }
+ // no subclass
+ try {
+ for (int i = 0; i < numFields; i++) {
+ Object value = fields[i].get(from);
+ if (value != null) {
+ Object copy = fieldSerializers[i].copy(value);
+ fields[i].set(target, copy);
+ }
+ else {
+ fields[i].set(target, null);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields before.");
+
+ }
+ return target;
+ } else {
+ // subclass
+ TypeSerializer subclassSerializer = getSubclassSerializer(actualType);
+ return (T) subclassSerializer.copy(from);
+ }
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public T copy(T from, T reuse) {
+ if (from == null) {
+ return null;
+ }
+
+ Class<?> actualType = from.getClass();
+ if (reuse == null || actualType != reuse.getClass()) {
+ // cannot reuse, do a non-reuse copy
+ return copy(from);
+ }
+
+ if (actualType == clazz) {
+ try {
+ for (int i = 0; i < numFields; i++) {
+ Object value = fields[i].get(from);
+ if (value != null) {
+ Object reuseValue = fields[i].get(reuse);
+ Object copy;
+ if(reuseValue != null) {
+ copy = fieldSerializers[i].copy(value, reuseValue);
+ }
+ else {
+ copy = fieldSerializers[i].copy(value);
+ }
+ fields[i].set(reuse, copy);
+ }
+ else {
+ fields[i].set(reuse, null);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields" + "before.");
+ }
+ } else {
+ TypeSerializer subclassSerializer = getSubclassSerializer(actualType);
+ reuse = (T) subclassSerializer.copy(from, reuse);
+ }
+
+ return reuse;
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public void serialize(T value, DataOutputView target) throws IOException {
+ int flags = 0;
+ // handle null values
+ if (value == null) {
+ flags |= IS_NULL;
+ target.writeByte(flags);
+ return;
+ }
+
+ Integer subclassTag = -1;
+ Class<?> actualClass = value.getClass();
+ TypeSerializer subclassSerializer = null;
+ if (clazz != actualClass) {
+ subclassTag = registeredClasses.get(actualClass);
+ if (subclassTag != null) {
+ flags |= IS_TAGGED_SUBCLASS;
+ subclassSerializer = registeredSerializers[subclassTag];
+ } else {
+ flags |= IS_SUBCLASS;
+ subclassSerializer = getSubclassSerializer(actualClass);
+ }
+ } else {
+ flags |= NO_SUBCLASS;
+ }
+
+ target.writeByte(flags);
+
+ if ((flags & IS_SUBCLASS) != 0) {
+ target.writeUTF(actualClass.getName());
+ } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
+ target.writeByte(subclassTag);
+ }
+
+
+ if ((flags & NO_SUBCLASS) != 0) {
+ try {
+ for (int i = 0; i < numFields; i++) {
+ Object o = fields[i].get(value);
+ if (o == null) {
+ target.writeBoolean(true); // null field handling
+ } else {
+ target.writeBoolean(false);
+ fieldSerializers[i].serialize(o, target);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields" + "before.");
+
+ }
+ } else {
+ // subclass
+ if (subclassSerializer != null) {
+ subclassSerializer.serialize(value, target);
+ }
+ }
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public T deserialize(DataInputView source) throws IOException {
+ int flags = source.readByte();
+ if((flags & IS_NULL) != 0) {
+ return null;
+ }
+
+ T target;
+
+ Class<?> actualSubclass = null;
+ TypeSerializer subclassSerializer = null;
+
+ if ((flags & IS_SUBCLASS) != 0) {
+ String subclassName = source.readUTF();
+ try {
+ actualSubclass = Class.forName(subclassName, true, cl);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Cannot instantiate class.", e);
+ }
+ subclassSerializer = getSubclassSerializer(actualSubclass);
+ target = (T) subclassSerializer.createInstance();
+ // also initialize fields for which the subclass serializer is not responsible
+ initializeFields(target);
+ } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
+
+ int subclassTag = source.readByte();
+ subclassSerializer = registeredSerializers[subclassTag];
+ target = (T) subclassSerializer.createInstance();
+ // also initialize fields for which the subclass serializer is not responsible
+ initializeFields(target);
+ } else {
+ target = createInstance();
+ }
+
+ if ((flags & NO_SUBCLASS) != 0) {
+ try {
+ for (int i = 0; i < numFields; i++) {
+ boolean isNull = source.readBoolean();
+ if (isNull) {
+ fields[i].set(target, null);
+ } else {
+ Object field = fieldSerializers[i].deserialize(source);
+ fields[i].set(target, field);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Error during POJO copy, this should not happen since we check the fields" + "before.");
+
+ }
+ } else {
+ if (subclassSerializer != null) {
+ target = (T) subclassSerializer.deserialize(target, source);
+ }
+ }
+ return target;
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+
+ // handle null values
+ int flags = source.readByte();
+ if((flags & IS_NULL) != 0) {
+ return null;
+ }
+
+ Class<?> subclass = null;
+ TypeSerializer subclassSerializer = null;
+ if ((flags & IS_SUBCLASS) != 0) {
+ String subclassName = source.readUTF();
+ try {
+ subclass = Class.forName(subclassName, true, cl);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Cannot instantiate class.", e);
+ }
+ subclassSerializer = getSubclassSerializer(subclass);
+
+ if (reuse == null || subclass != reuse.getClass()) {
+ // cannot reuse
+ reuse = (T) subclassSerializer.createInstance();
+ // also initialize fields for which the subclass serializer is not responsible
+ initializeFields(reuse);
+ }
+ } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
+ int subclassTag = source.readByte();
+ subclassSerializer = registeredSerializers[subclassTag];
+
+ if (reuse == null || ((PojoSerializer)subclassSerializer).clazz != reuse.getClass()) {
+ // cannot reuse
+ reuse = (T) subclassSerializer.createInstance();
+ // also initialize fields for which the subclass serializer is not responsible
+ initializeFields(reuse);
+ }
+ } else {
+ if (reuse == null || clazz != reuse.getClass()) {
+ reuse = createInstance();
+ }
+ }
+
+ if ((flags & NO_SUBCLASS) != 0) {
+ try {
+ for (int i = 0; i < numFields; i++) {
+ boolean isNull = source.readBoolean();
+ if (isNull) {
+ fields[i].set(reuse, null);
+ } else {
+ Object field;
+
+ Object reuseField = fields[i].get(reuse);
+ if(reuseField != null) {
+ field = fieldSerializers[i].deserialize(reuseField, source);
+ }
+ else {
+ field = fieldSerializers[i].deserialize(source);
+ }
+
+ fields[i].set(reuse, field);
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(
+ "Error during POJO copy, this should not happen since we check the fields before.");
+ }
+ } else {
+ if (subclassSerializer != null) {
+ reuse = (T) subclassSerializer.deserialize(reuse, source);
+ }
+ }
+
+ return reuse;
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ // copy the flags
+ int flags = source.readByte();
+ target.writeByte(flags);
+
+ if ((flags & IS_NULL) != 0) {
+ // is a null value, nothing further to copy
+ return;
+ }
+
+ TypeSerializer<?> subclassSerializer = null;
+ if ((flags & IS_SUBCLASS) != 0) {
+ String className = source.readUTF();
+ target.writeUTF(className);
+ try {
+ Class<?> subclass = Class.forName(className, true, Thread.currentThread()
+ .getContextClassLoader());
+ subclassSerializer = getSubclassSerializer(subclass);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Cannot instantiate class.", e);
+ }
+ } else if ((flags & IS_TAGGED_SUBCLASS) != 0) {
+ int subclassTag = source.readByte();
+ target.writeByte(subclassTag);
+ subclassSerializer = registeredSerializers[subclassTag];
+ }
+
+ if ((flags & NO_SUBCLASS) != 0) {
+ for (int i = 0; i < numFields; i++) {
+ boolean isNull = source.readBoolean();
+ target.writeBoolean(isNull);
+ if (!isNull) {
+ fieldSerializers[i].copy(source, target);
+ }
+ }
+ } else {
+ if (subclassSerializer != null) {
+ subclassSerializer.copy(source, target);
+ }
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * (31 * Arrays.hashCode(fieldSerializers) + Arrays.hashCode(registeredSerializers)) +
+ Objects.hash(clazz, numFields, registeredClasses);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof PojoSerializer) {
+ PojoSerializer<?> other = (PojoSerializer<?>) obj;
+
+ return other.canEqual(this) &&
+ clazz == other.clazz &&
+ Arrays.equals(fieldSerializers, other.fieldSerializers) &&
+ Arrays.equals(registeredSerializers, other.registeredSerializers) &&
+ numFields == other.numFields &&
+ registeredClasses.equals(other.registeredClasses);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof PojoSerializer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java
new file mode 100644
index 0000000..4b734a7
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeComparatorFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeComparatorFactory;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.util.InstantiationUtil;
+
+public final class RuntimeComparatorFactory<T> implements TypeComparatorFactory<T>, java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+ private static final String CONFIG_KEY = "SER_DATA";
+
+ private TypeComparator<T> comparator;
+
+
+ public RuntimeComparatorFactory() {}
+
+ public RuntimeComparatorFactory(TypeComparator<T> comparator) {
+ this.comparator = comparator;
+ }
+
+ @Override
+ public void writeParametersToConfig(Configuration config) {
+ try {
+ InstantiationUtil.writeObjectToConfig(comparator, config, CONFIG_KEY);
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Could not serialize comparator into the configuration.", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void readParametersFromConfig(Configuration config, ClassLoader cl) throws ClassNotFoundException {
+ try {
+ comparator = (TypeComparator<T>) InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY, cl);
+ }
+ catch (ClassNotFoundException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Could not serialize serializer into the configuration.", e);
+ }
+ }
+
+ @Override
+ public TypeComparator<T> createComparator() {
+ if (comparator != null) {
+ return comparator;
+ } else {
+ throw new RuntimeException("ComparatorFactory has not been initialized from configuration.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java
new file mode 100644
index 0000000..31e28f7
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimePairComparatorFactory.java
@@ -0,0 +1,44 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.GenericPairComparator;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypePairComparator;
+import org.apache.flink.api.common.typeutils.TypePairComparatorFactory;
+
+public final class RuntimePairComparatorFactory<T1, T2>
+ implements TypePairComparatorFactory<T1, T2>, java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public TypePairComparator<T1, T2> createComparator12(
+ TypeComparator<T1> comparator1,
+ TypeComparator<T2> comparator2) {
+ return new GenericPairComparator<T1, T2>(comparator1, comparator2);
+ }
+
+ @Override
+ public TypePairComparator<T2, T1> createComparator21(
+ TypeComparator<T1> comparator1,
+ TypeComparator<T2> comparator2) {
+ return new GenericPairComparator<T2, T1>(comparator2, comparator1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java
new file mode 100644
index 0000000..96aff73
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RuntimeSerializerFactory.java
@@ -0,0 +1,124 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.TypeSerializerFactory;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.util.InstantiationUtil;
+
+public final class RuntimeSerializerFactory<T> implements TypeSerializerFactory<T>, java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+ private static final String CONFIG_KEY_SER = "SER_DATA";
+
+ private static final String CONFIG_KEY_CLASS = "CLASS_DATA";
+
+
+ private TypeSerializer<T> serializer;
+
+ private boolean firstSerializer = true;
+
+ private Class<T> clazz;
+
+ // Because we read the class from the TaskConfig and instantiate ourselves
+ public RuntimeSerializerFactory() {}
+
+ public RuntimeSerializerFactory(TypeSerializer<T> serializer, Class<T> clazz) {
+ if (serializer == null || clazz == null) {
+ throw new NullPointerException();
+ }
+
+ this.clazz = clazz;
+ this.serializer = serializer;
+ }
+
+
+ @Override
+ public void writeParametersToConfig(Configuration config) {
+ try {
+ InstantiationUtil.writeObjectToConfig(clazz, config, CONFIG_KEY_CLASS);
+ InstantiationUtil.writeObjectToConfig(serializer, config, CONFIG_KEY_SER);
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Could not serialize serializer into the configuration.", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void readParametersFromConfig(Configuration config, ClassLoader cl) throws ClassNotFoundException {
+ if (config == null || cl == null) {
+ throw new NullPointerException();
+ }
+
+ try {
+ this.clazz = (Class<T>) InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY_CLASS, cl);
+ this.serializer = (TypeSerializer<T>) InstantiationUtil.readObjectFromConfig(config, CONFIG_KEY_SER, cl);
+ firstSerializer = true;
+ }
+ catch (ClassNotFoundException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Could not load deserializer from the configuration.", e);
+ }
+ }
+
+ @Override
+ public TypeSerializer<T> getSerializer() {
+ if (this.serializer != null) {
+ if (firstSerializer) {
+ firstSerializer = false;
+ return this.serializer;
+ } else {
+ return this.serializer.duplicate();
+ }
+ } else {
+ throw new RuntimeException("SerializerFactory has not been initialized from configuration.");
+ }
+ }
+
+ @Override
+ public Class<T> getDataType() {
+ return clazz;
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return clazz.hashCode() ^ serializer.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj != null && obj instanceof RuntimeSerializerFactory) {
+ RuntimeSerializerFactory<?> other = (RuntimeSerializerFactory<?>) obj;
+
+ return this.clazz == other.clazz &&
+ this.serializer.equals(other.serializer);
+ } else {
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java
new file mode 100644
index 0000000..a06ff1a
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/Tuple0Serializer.java
@@ -0,0 +1,121 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple0;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+
+public class Tuple0Serializer extends TupleSerializer<Tuple0> {
+
+ private static final long serialVersionUID = 1278813169022975971L;
+
+ public static final Tuple0Serializer INSTANCE = new Tuple0Serializer();
+
+ // ------------------------------------------------------------------------
+
+ private Tuple0Serializer() {
+ super(Tuple0.class, new TypeSerializer<?>[0]);
+ }
+
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Tuple0Serializer duplicate() {
+ return this;
+ }
+
+ @Override
+ public Tuple0 createInstance() {
+ return Tuple0.INSTANCE;
+ }
+
+ @Override
+ public Tuple0 createInstance(Object[] fields) {
+ if (fields == null || fields.length == 0) {
+ return Tuple0.INSTANCE;
+ }
+
+ throw new UnsupportedOperationException(
+ "Tuple0 cannot take any data, as it has zero fields.");
+ }
+
+ @Override
+ public Tuple0 copy(Tuple0 from) {
+ return from;
+ }
+
+ @Override
+ public Tuple0 copy(Tuple0 from, Tuple0 reuse) {
+ return reuse;
+ }
+
+ @Override
+ public int getLength() {
+ return 1;
+ }
+
+ @Override
+ public void serialize(Tuple0 record, DataOutputView target) throws IOException {
+ target.writeByte(42);
+ }
+
+ @Override
+ public Tuple0 deserialize(DataInputView source) throws IOException {
+ source.readByte();
+ return Tuple0.INSTANCE;
+ }
+
+ @Override
+ public Tuple0 deserialize(Tuple0 reuse, DataInputView source) throws IOException {
+ source.readByte();
+ return reuse;
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ target.writeByte(source.readByte());
+ }
+
+ // ------------------------------------------------------------------------
+
+
+ @Override
+ public int hashCode() {
+ return Tuple0Serializer.class.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Tuple0Serializer) {
+ Tuple0Serializer other = (Tuple0Serializer) obj;
+
+ return other.canEqual(this);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof Tuple0Serializer;
+ }
+
+ @Override
+ public String toString() {
+ return "Tuple0Serializer";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java
new file mode 100644
index 0000000..875ecc2
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparator.java
@@ -0,0 +1,157 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.types.KeyFieldOutOfBoundsException;
+import org.apache.flink.types.NullFieldException;
+import org.apache.flink.types.NullKeyFieldException;
+
+
+public final class TupleComparator<T extends Tuple> extends TupleComparatorBase<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ public TupleComparator(int[] keyPositions, TypeComparator<?>[] comparators, TypeSerializer<?>[] serializers) {
+ super(keyPositions, comparators, serializers);
+ }
+
+ private TupleComparator(TupleComparator<T> toClone) {
+ super(toClone);
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Comparator Methods
+ // --------------------------------------------------------------------------------------------
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int hash(T value) {
+ int i = 0;
+ try {
+ int code = this.comparators[0].hash(value.getFieldNotNull(keyPositions[0]));
+ for (i = 1; i < this.keyPositions.length; i++) {
+ code *= HASH_SALT[i & 0x1F]; // salt code with (i % HASH_SALT.length)-th salt component
+ code += this.comparators[i].hash(value.getFieldNotNull(keyPositions[i]));
+ }
+ return code;
+ }
+ catch (NullFieldException nfex) {
+ throw new NullKeyFieldException(nfex);
+ }
+ catch (IndexOutOfBoundsException iobex) {
+ throw new KeyFieldOutOfBoundsException(keyPositions[i]);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setReference(T toCompare) {
+ int i = 0;
+ try {
+ for (; i < this.keyPositions.length; i++) {
+ this.comparators[i].setReference(toCompare.getFieldNotNull(this.keyPositions[i]));
+ }
+ }
+ catch (NullFieldException nfex) {
+ throw new NullKeyFieldException(nfex);
+ }
+ catch (IndexOutOfBoundsException iobex) {
+ throw new KeyFieldOutOfBoundsException(keyPositions[i]);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equalToReference(T candidate) {
+ int i = 0;
+ try {
+ for (; i < this.keyPositions.length; i++) {
+ if (!this.comparators[i].equalToReference(candidate.getFieldNotNull(this.keyPositions[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ catch (NullFieldException nfex) {
+ throw new NullKeyFieldException(nfex);
+ }
+ catch (IndexOutOfBoundsException iobex) {
+ throw new KeyFieldOutOfBoundsException(keyPositions[i]);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compare(T first, T second) {
+ int i = 0;
+ try {
+ for (; i < keyPositions.length; i++) {
+ int keyPos = keyPositions[i];
+ int cmp = comparators[i].compare(first.getFieldNotNull(keyPos), second.getFieldNotNull(keyPos));
+
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+ return 0;
+ }
+ catch (NullFieldException nfex) {
+ throw new NullKeyFieldException(nfex);
+ }
+ catch (IndexOutOfBoundsException iobex) {
+ throw new KeyFieldOutOfBoundsException(keyPositions[i]);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void putNormalizedKey(T value, MemorySegment target, int offset, int numBytes) {
+ int i = 0;
+ try {
+ for (; i < this.numLeadingNormalizableKeys && numBytes > 0; i++) {
+ int len = this.normalizedKeyLengths[i];
+ len = numBytes >= len ? len : numBytes;
+ this.comparators[i].putNormalizedKey(value.getFieldNotNull(this.keyPositions[i]), target, offset, len);
+ numBytes -= len;
+ offset += len;
+ }
+ } catch (NullFieldException nfex) {
+ throw new NullKeyFieldException(nfex);
+ } catch (NullPointerException npex) {
+ throw new NullKeyFieldException(this.keyPositions[i]);
+ }
+ }
+
+ @Override
+ public int extractKeys(Object record, Object[] target, int index) {
+ int localIndex = index;
+ for(int i = 0; i < comparators.length; i++) {
+ localIndex += comparators[i].extractKeys(((Tuple) record).getField(keyPositions[i]), target, localIndex);
+ }
+ return localIndex - index;
+ }
+
+ public TypeComparator<T> duplicate() {
+ return new TupleComparator<T>(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java
new file mode 100644
index 0000000..28169e5
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleComparatorBase.java
@@ -0,0 +1,279 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.flink.api.common.typeutils.CompositeTypeComparator;
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.types.KeyFieldOutOfBoundsException;
+import org.apache.flink.types.NullKeyFieldException;
+
+
+public abstract class TupleComparatorBase<T> extends CompositeTypeComparator<T> implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** key positions describe which fields are keys in what order */
+ protected int[] keyPositions;
+
+ /** comparators for the key fields, in the same order as the key fields */
+ @SuppressWarnings("rawtypes")
+ protected TypeComparator[] comparators;
+
+ protected int[] normalizedKeyLengths;
+
+ protected int numLeadingNormalizableKeys;
+
+ protected int normalizableKeyPrefixLen;
+
+ protected boolean invertNormKey;
+
+
+ /** serializers to deserialize the first n fields for comparison */
+ @SuppressWarnings("rawtypes")
+ protected TypeSerializer[] serializers;
+
+ // cache for the deserialized field objects
+ protected transient Object[] deserializedFields1;
+ protected transient Object[] deserializedFields2;
+
+
+ @SuppressWarnings("unchecked")
+ public TupleComparatorBase(int[] keyPositions, TypeComparator<?>[] comparators, TypeSerializer<?>[] serializers) {
+ // set the default utils
+ this.keyPositions = keyPositions;
+ this.comparators = (TypeComparator<Object>[]) comparators;
+ this.serializers = (TypeSerializer<Object>[]) serializers;
+
+ // set up auxiliary fields for normalized key support
+ this.normalizedKeyLengths = new int[keyPositions.length];
+ int nKeys = 0;
+ int nKeyLen = 0;
+ boolean inverted = false;
+
+ for (int i = 0; i < this.keyPositions.length; i++) {
+ TypeComparator<?> k = this.comparators[i];
+
+ // as long as the leading keys support normalized keys, we can build up the composite key
+ if (k.supportsNormalizedKey()) {
+ if (i == 0) {
+ // the first comparator decides whether we need to invert the key direction
+ inverted = k.invertNormalizedKey();
+ }
+ else if (k.invertNormalizedKey() != inverted) {
+ // if a successor does not agree on the inversion direction, it cannot be part of the normalized key
+ break;
+ }
+
+ nKeys++;
+ final int len = k.getNormalizeKeyLen();
+ if (len < 0) {
+ throw new RuntimeException("Comparator " + k.getClass().getName() + " specifies an invalid length for the normalized key: " + len);
+ }
+ this.normalizedKeyLengths[i] = len;
+ nKeyLen += len;
+
+ if (nKeyLen < 0) {
+ // overflow, which means we are out of budget for normalized key space anyways
+ nKeyLen = Integer.MAX_VALUE;
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ this.numLeadingNormalizableKeys = nKeys;
+ this.normalizableKeyPrefixLen = nKeyLen;
+ this.invertNormKey = inverted;
+ }
+
+ protected TupleComparatorBase(TupleComparatorBase<T> toClone) {
+ privateDuplicate(toClone);
+ }
+
+ // We need this because we cannot call the cloning constructor from the
+ // ScalaTupleComparator
+ protected void privateDuplicate(TupleComparatorBase<T> toClone) {
+ // copy fields and serializer factories
+ this.keyPositions = toClone.keyPositions;
+
+ this.serializers = new TypeSerializer[toClone.serializers.length];
+ for (int i = 0; i < toClone.serializers.length; i++) {
+ this.serializers[i] = toClone.serializers[i].duplicate();
+ }
+
+ this.comparators = new TypeComparator[toClone.comparators.length];
+ for (int i = 0; i < toClone.comparators.length; i++) {
+ this.comparators[i] = toClone.comparators[i].duplicate();
+ }
+
+ this.normalizedKeyLengths = toClone.normalizedKeyLengths;
+ this.numLeadingNormalizableKeys = toClone.numLeadingNormalizableKeys;
+ this.normalizableKeyPrefixLen = toClone.normalizableKeyPrefixLen;
+ this.invertNormKey = toClone.invertNormKey;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // Comparator Methods
+ // --------------------------------------------------------------------------------------------
+
+ protected int[] getKeyPositions() {
+ return this.keyPositions;
+ }
+
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void getFlatComparator(List<TypeComparator> flatComparators) {
+ for(int i = 0; i < comparators.length; i++) {
+ if(comparators[i] instanceof CompositeTypeComparator) {
+ ((CompositeTypeComparator)comparators[i]).getFlatComparator(flatComparators);
+ } else {
+ flatComparators.add(comparators[i]);
+ }
+ }
+ }
+ // --------------------------------------------------------------------------------------------
+ // Comparator Methods
+ // --------------------------------------------------------------------------------------------
+
+
+ @Override
+ public int compareToReference(TypeComparator<T> referencedComparator) {
+ TupleComparatorBase<T> other = (TupleComparatorBase<T>) referencedComparator;
+
+ int i = 0;
+ try {
+ for (; i < this.keyPositions.length; i++) {
+ @SuppressWarnings("unchecked")
+ int cmp = this.comparators[i].compareToReference(other.comparators[i]);
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+ return 0;
+ }
+ catch (NullPointerException npex) {
+ throw new NullKeyFieldException(keyPositions[i]);
+ }
+ catch (IndexOutOfBoundsException iobex) {
+ throw new KeyFieldOutOfBoundsException(keyPositions[i]);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
+ if (deserializedFields1 == null) {
+ instantiateDeserializationUtils();
+ }
+
+ int i = 0;
+ try {
+ for (; i < serializers.length; i++) {
+ deserializedFields1[i] = serializers[i].deserialize(deserializedFields1[i], firstSource);
+ deserializedFields2[i] = serializers[i].deserialize(deserializedFields2[i], secondSource);
+ }
+
+ for (i = 0; i < keyPositions.length; i++) {
+ int keyPos = keyPositions[i];
+ int cmp = comparators[i].compare(deserializedFields1[keyPos], deserializedFields2[keyPos]);
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+
+ return 0;
+ } catch (NullPointerException npex) {
+ throw new NullKeyFieldException(keyPositions[i]);
+ } catch (IndexOutOfBoundsException iobex) {
+ throw new KeyFieldOutOfBoundsException(keyPositions[i], iobex);
+ }
+ }
+
+ @Override
+ public boolean supportsNormalizedKey() {
+ return this.numLeadingNormalizableKeys > 0;
+ }
+
+ @Override
+ public int getNormalizeKeyLen() {
+ return this.normalizableKeyPrefixLen;
+ }
+
+ @Override
+ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
+ return this.numLeadingNormalizableKeys < this.keyPositions.length ||
+ this.normalizableKeyPrefixLen == Integer.MAX_VALUE ||
+ this.normalizableKeyPrefixLen > keyBytes;
+ }
+
+ @Override
+ public boolean invertNormalizedKey() {
+ return this.invertNormKey;
+ }
+
+
+ @Override
+ public boolean supportsSerializationWithKeyNormalization() {
+ return false;
+ }
+
+ @Override
+ public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ protected final void instantiateDeserializationUtils() {
+ this.deserializedFields1 = new Object[this.serializers.length];
+ this.deserializedFields2 = new Object[this.serializers.length];
+
+ for (int i = 0; i < this.serializers.length; i++) {
+ this.deserializedFields1[i] = this.serializers[i].createInstance();
+ this.deserializedFields2[i] = this.serializers[i].createInstance();
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ /**
+ * A sequence of prime numbers to be used for salting the computed hash values.
+ * Based on some empirical evidence, we are using a 32-element subsequence of the
+ * OEIS sequence #A068652 (numbers such that every cyclic permutation is a prime).
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/List_of_prime_numbers">http://en.wikipedia.org/wiki/List_of_prime_numbers</a>
+ * @see <a href="http://oeis.org/A068652">http://oeis.org/A068652</a>
+ */
+ public static final int[] HASH_SALT = new int[] {
+ 73 , 79 , 97 , 113 , 131 , 197 , 199 , 311 ,
+ 337 , 373 , 719 , 733 , 919 , 971 , 991 , 1193 ,
+ 1931 , 3119 , 3779 , 7793 , 7937 , 9311 , 9377 , 11939 ,
+ 19391, 19937, 37199, 39119, 71993, 91193, 93719, 93911 };
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java
new file mode 100644
index 0000000..0897063
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializer.java
@@ -0,0 +1,158 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.types.NullFieldException;
+
+
+public class TupleSerializer<T extends Tuple> extends TupleSerializerBase<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ public TupleSerializer(Class<T> tupleClass, TypeSerializer<?>[] fieldSerializers) {
+ super(tupleClass, fieldSerializers);
+ }
+
+ @Override
+ public TupleSerializer<T> duplicate() {
+ boolean stateful = false;
+ TypeSerializer<?>[] duplicateFieldSerializers = new TypeSerializer<?>[fieldSerializers.length];
+
+ for (int i = 0; i < fieldSerializers.length; i++) {
+ duplicateFieldSerializers[i] = fieldSerializers[i].duplicate();
+ if (duplicateFieldSerializers[i] != fieldSerializers[i]) {
+ // at least one of them is stateful
+ stateful = true;
+ }
+ }
+
+ if (stateful) {
+ return new TupleSerializer<T>(tupleClass, duplicateFieldSerializers);
+ } else {
+ return this;
+ }
+ }
+
+ @Override
+ public T createInstance() {
+ try {
+ T t = tupleClass.newInstance();
+
+ for (int i = 0; i < arity; i++) {
+ t.setField(fieldSerializers[i].createInstance(), i);
+ }
+
+ return t;
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Cannot instantiate tuple.", e);
+ }
+ }
+
+ @Override
+ public T createInstance(Object[] fields) {
+
+ try {
+ T t = tupleClass.newInstance();
+
+ for (int i = 0; i < arity; i++) {
+ t.setField(fields[i], i);
+ }
+
+ return t;
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Cannot instantiate tuple.", e);
+ }
+ }
+
+ @Override
+ public T createOrReuseInstance(Object[] fields, T reuse) {
+ for (int i = 0; i < arity; i++) {
+ reuse.setField(fields[i], i);
+ }
+ return reuse;
+ }
+
+ @Override
+ public T copy(T from) {
+ T target = instantiateRaw();
+ for (int i = 0; i < arity; i++) {
+ Object copy = fieldSerializers[i].copy(from.getField(i));
+ target.setField(copy, i);
+ }
+ return target;
+ }
+
+ @Override
+ public T copy(T from, T reuse) {
+ for (int i = 0; i < arity; i++) {
+ Object copy = fieldSerializers[i].copy(from.getField(i), reuse.getField(i));
+ reuse.setField(copy, i);
+ }
+
+ return reuse;
+ }
+
+ @Override
+ public void serialize(T value, DataOutputView target) throws IOException {
+ for (int i = 0; i < arity; i++) {
+ Object o = value.getField(i);
+ try {
+ fieldSerializers[i].serialize(o, target);
+ } catch (NullPointerException npex) {
+ throw new NullFieldException(i, npex);
+ }
+ }
+ }
+
+ @Override
+ public T deserialize(DataInputView source) throws IOException {
+ T tuple = instantiateRaw();
+ for (int i = 0; i < arity; i++) {
+ Object field = fieldSerializers[i].deserialize(source);
+ tuple.setField(field, i);
+ }
+ return tuple;
+ }
+
+ @Override
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+ for (int i = 0; i < arity; i++) {
+ Object field = fieldSerializers[i].deserialize(reuse.getField(i), source);
+ reuse.setField(field, i);
+ }
+ return reuse;
+ }
+
+ private T instantiateRaw() {
+ try {
+ return tupleClass.newInstance();
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Cannot instantiate tuple.", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java
new file mode 100644
index 0000000..fc657a1
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/TupleSerializerBase.java
@@ -0,0 +1,102 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Objects;
+
+
+public abstract class TupleSerializerBase<T> extends TypeSerializer<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final Class<T> tupleClass;
+
+ protected final TypeSerializer<Object>[] fieldSerializers;
+
+ protected final int arity;
+
+ @SuppressWarnings("unchecked")
+ public TupleSerializerBase(Class<T> tupleClass, TypeSerializer<?>[] fieldSerializers) {
+ this.tupleClass = Preconditions.checkNotNull(tupleClass);
+ this.fieldSerializers = (TypeSerializer<Object>[]) Preconditions.checkNotNull(fieldSerializers);
+ this.arity = fieldSerializers.length;
+ }
+
+ public Class<T> getTupleClass() {
+ return this.tupleClass;
+ }
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+ public int getArity() {
+ return arity;
+ }
+
+ // We use this in the Aggregate and Distinct Operators to create instances
+ // of immutable Typles (i.e. Scala Tuples)
+ public abstract T createInstance(Object[] fields);
+
+ public abstract T createOrReuseInstance(Object[] fields, T reuse);
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ for (int i = 0; i < arity; i++) {
+ fieldSerializers[i].copy(source, target);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * Arrays.hashCode(fieldSerializers) + Objects.hash(tupleClass, arity);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof TupleSerializerBase) {
+ TupleSerializerBase<?> other = (TupleSerializerBase<?>) obj;
+
+ return other.canEqual(this) &&
+ tupleClass == other.tupleClass &&
+ Arrays.equals(fieldSerializers, other.fieldSerializers) &&
+ arity == other.arity;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof TupleSerializerBase;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java
new file mode 100644
index 0000000..4b9629a
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueComparator.java
@@ -0,0 +1,183 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.types.NormalizableKey;
+import org.apache.flink.types.Value;
+import org.apache.flink.util.InstantiationUtil;
+
+import com.esotericsoftware.kryo.Kryo;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+/**
+ * Comparator for all Value types that extend Key
+ */
+public class ValueComparator<T extends Value & Comparable<T>> extends TypeComparator<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> type;
+
+ private final boolean ascendingComparison;
+
+ private transient T reference;
+
+ private transient T tempReference;
+
+ private transient Kryo kryo;
+
+ @SuppressWarnings("rawtypes")
+ private final TypeComparator[] comparators = new TypeComparator[] {this};
+
+ public ValueComparator(boolean ascending, Class<T> type) {
+ this.type = type;
+ this.ascendingComparison = ascending;
+ }
+
+ @Override
+ public int hash(T record) {
+ return record.hashCode();
+ }
+
+ @Override
+ public void setReference(T toCompare) {
+ checkKryoInitialized();
+
+ reference = KryoUtils.copy(toCompare, kryo, new ValueSerializer<T>(type));
+ }
+
+ @Override
+ public boolean equalToReference(T candidate) {
+ return candidate.equals(this.reference);
+ }
+
+ @Override
+ public int compareToReference(TypeComparator<T> referencedComparator) {
+ T otherRef = ((ValueComparator<T>) referencedComparator).reference;
+ int comp = otherRef.compareTo(reference);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public int compare(T first, T second) {
+ int comp = first.compareTo(second);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
+ if (reference == null) {
+ reference = InstantiationUtil.instantiate(type, Value.class);
+ }
+ if (tempReference == null) {
+ tempReference = InstantiationUtil.instantiate(type, Value.class);
+ }
+
+ reference.read(firstSource);
+ tempReference.read(secondSource);
+ int comp = reference.compareTo(tempReference);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public boolean supportsNormalizedKey() {
+ return NormalizableKey.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public int getNormalizeKeyLen() {
+ if (reference == null) {
+ reference = InstantiationUtil.instantiate(type, Value.class);
+ }
+
+ NormalizableKey<?> key = (NormalizableKey<?>) reference;
+ return key.getMaxNormalizedKeyLen();
+ }
+
+ @Override
+ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
+ return keyBytes < getNormalizeKeyLen();
+ }
+
+ @Override
+ public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
+ NormalizableKey<?> key = (NormalizableKey<?>) record;
+ key.copyNormalizedKey(target, offset, numBytes);
+ }
+
+ @Override
+ public boolean invertNormalizedKey() {
+ return !ascendingComparison;
+ }
+
+ @Override
+ public TypeComparator<T> duplicate() {
+ return new ValueComparator<T>(ascendingComparison, type);
+ }
+
+ private void checkKryoInitialized() {
+ if (this.kryo == null) {
+ this.kryo = new Kryo();
+
+ Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
+ instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+ kryo.setInstantiatorStrategy(instantiatorStrategy);
+
+ this.kryo.setAsmEnabled(true);
+ this.kryo.register(type);
+ }
+ }
+
+ @Override
+ public int extractKeys(Object record, Object[] target, int index) {
+ target[index] = record;
+ return 1;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public TypeComparator[] getFlatComparators() {
+ return comparators;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // unsupported normalization
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean supportsSerializationWithKeyNormalization() {
+ return false;
+ }
+
+ @Override
+ public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java
new file mode 100644
index 0000000..9329866
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializer.java
@@ -0,0 +1,152 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import com.google.common.base.Preconditions;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.types.Value;
+import org.apache.flink.util.InstantiationUtil;
+
+import com.esotericsoftware.kryo.Kryo;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+/**
+ * Serializer for {@link Value} types. Uses the value's serialization methods, and uses
+ * Kryo for deep object copies.
+ *
+ * @param <T> The type serialized.
+ */
+public class ValueSerializer<T extends Value> extends TypeSerializer<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Class<T> type;
+
+ private transient Kryo kryo;
+
+ private transient T copyInstance;
+
+ // --------------------------------------------------------------------------------------------
+
+ public ValueSerializer(Class<T> type) {
+ this.type = Preconditions.checkNotNull(type);
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean isImmutableType() {
+ return false;
+ }
+
+ @Override
+ public ValueSerializer<T> duplicate() {
+ return new ValueSerializer<T>(type);
+ }
+
+ @Override
+ public T createInstance() {
+ return InstantiationUtil.instantiate(this.type);
+ }
+
+ @Override
+ public T copy(T from) {
+ checkKryoInitialized();
+
+ return KryoUtils.copy(from, kryo, this);
+ }
+
+ @Override
+ public T copy(T from, T reuse) {
+ checkKryoInitialized();
+
+ return KryoUtils.copy(from, reuse, kryo, this);
+ }
+
+ @Override
+ public int getLength() {
+ return -1;
+ }
+
+ @Override
+ public void serialize(T value, DataOutputView target) throws IOException {
+ value.write(target);
+ }
+
+ @Override
+ public T deserialize(DataInputView source) throws IOException {
+ return deserialize(createInstance(), source);
+ }
+
+ @Override
+ public T deserialize(T reuse, DataInputView source) throws IOException {
+ reuse.read(source);
+ return reuse;
+ }
+
+ @Override
+ public void copy(DataInputView source, DataOutputView target) throws IOException {
+ if (this.copyInstance == null) {
+ this.copyInstance = InstantiationUtil.instantiate(type);
+ }
+
+ this.copyInstance.read(source);
+ this.copyInstance.write(target);
+ }
+
+ private void checkKryoInitialized() {
+ if (this.kryo == null) {
+ this.kryo = new Kryo();
+
+ Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
+ instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+ kryo.setInstantiatorStrategy(instantiatorStrategy);
+
+ this.kryo.setAsmEnabled(true);
+ this.kryo.register(type);
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ return this.type.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ValueSerializer) {
+ ValueSerializer<?> other = (ValueSerializer<?>) obj;
+
+ return other.canEqual(this) && type == other.type;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean canEqual(Object obj) {
+ return obj instanceof ValueSerializer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java
new file mode 100644
index 0000000..a03369a
--- /dev/null
+++ b/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/WritableComparator.java
@@ -0,0 +1,189 @@
+/*
+ * 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.java.typeutils.runtime;
+
+import java.io.IOException;
+
+import org.apache.flink.api.common.typeutils.TypeComparator;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.types.NormalizableKey;
+import org.apache.flink.util.InstantiationUtil;
+import org.apache.hadoop.io.Writable;
+
+import com.esotericsoftware.kryo.Kryo;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+
+public class WritableComparator<T extends Writable & Comparable<T>> extends TypeComparator<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ private Class<T> type;
+
+ private final boolean ascendingComparison;
+
+ private transient T reference;
+
+ private transient T tempReference;
+
+ private transient Kryo kryo;
+
+ @SuppressWarnings("rawtypes")
+ private final TypeComparator[] comparators = new TypeComparator[] {this};
+
+ public WritableComparator(boolean ascending, Class<T> type) {
+ this.type = type;
+ this.ascendingComparison = ascending;
+ }
+
+ @Override
+ public int hash(T record) {
+ return record.hashCode();
+ }
+
+ @Override
+ public void setReference(T toCompare) {
+ checkKryoInitialized();
+
+ reference = KryoUtils.copy(toCompare, kryo, new WritableSerializer<T>(type));
+ }
+
+ @Override
+ public boolean equalToReference(T candidate) {
+ return candidate.equals(reference);
+ }
+
+ @Override
+ public int compareToReference(TypeComparator<T> referencedComparator) {
+ T otherRef = ((WritableComparator<T>) referencedComparator).reference;
+ int comp = otherRef.compareTo(reference);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public int compare(T first, T second) {
+ int comp = first.compareTo(second);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException {
+ ensureReferenceInstantiated();
+ ensureTempReferenceInstantiated();
+
+ reference.readFields(firstSource);
+ tempReference.readFields(secondSource);
+
+ int comp = reference.compareTo(tempReference);
+ return ascendingComparison ? comp : -comp;
+ }
+
+ @Override
+ public boolean supportsNormalizedKey() {
+ return NormalizableKey.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public int getNormalizeKeyLen() {
+ ensureReferenceInstantiated();
+
+ NormalizableKey<?> key = (NormalizableKey<?>) reference;
+ return key.getMaxNormalizedKeyLen();
+ }
+
+ @Override
+ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
+ return keyBytes < getNormalizeKeyLen();
+ }
+
+ @Override
+ public void putNormalizedKey(T record, MemorySegment target, int offset, int numBytes) {
+ NormalizableKey<?> key = (NormalizableKey<?>) record;
+ key.copyNormalizedKey(target, offset, numBytes);
+ }
+
+ @Override
+ public boolean invertNormalizedKey() {
+ return !ascendingComparison;
+ }
+
+ @Override
+ public TypeComparator<T> duplicate() {
+ return new WritableComparator<T>(ascendingComparison, type);
+ }
+
+ @Override
+ public int extractKeys(Object record, Object[] target, int index) {
+ target[index] = record;
+ return 1;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public TypeComparator[] getFlatComparators() {
+ return comparators;
+ }
+
+ // --------------------------------------------------------------------------------------------
+ // unsupported normalization
+ // --------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean supportsSerializationWithKeyNormalization() {
+ return false;
+ }
+
+ @Override
+ public void writeWithKeyNormalization(T record, DataOutputView target) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public T readWithKeyDenormalization(T reuse, DataInputView source) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ // --------------------------------------------------------------------------------------------
+
+ private void checkKryoInitialized() {
+ if (this.kryo == null) {
+ this.kryo = new Kryo();
+
+ Kryo.DefaultInstantiatorStrategy instantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
+ instantiatorStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+ kryo.setInstantiatorStrategy(instantiatorStrategy);
+
+ this.kryo.setAsmEnabled(true);
+ this.kryo.register(type);
+ }
+ }
+
+ private void ensureReferenceInstantiated() {
+ if (reference == null) {
+ reference = InstantiationUtil.instantiate(type, Writable.class);
+ }
+ }
+
+ private void ensureTempReferenceInstantiated() {
+ if (tempReference == null) {
+ tempReference = InstantiationUtil.instantiate(type, Writable.class);
+ }
+ }
+}
[06/38] flink git commit: [FLINK-3303] [core] Move all type utilities
to flink-core
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeInformationTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeInformationTest.java b/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeInformationTest.java
deleted file mode 100644
index 7f5ef25..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/PojoTypeInformationTest.java
+++ /dev/null
@@ -1,98 +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.java.type.extractor;
-
-import static org.junit.Assert.assertTrue;
-
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.junit.Test;
-
-public class PojoTypeInformationTest {
-
- public static class SimplePojo {
- public String str;
- public Boolean Bl;
- public boolean bl;
- public Byte Bt;
- public byte bt;
- public Short Shrt;
- public short shrt;
- public Integer Intgr;
- public int intgr;
- public Long Lng;
- public long lng;
- public Float Flt;
- public float flt;
- public Double Dbl;
- public double dbl;
- public Character Ch;
- public char ch;
- public int[] primIntArray;
- public Integer[] intWrapperArray;
- }
-
- @Test
- public void testSimplePojoTypeExtraction() {
- TypeInformation<SimplePojo> type = TypeExtractor.getForClass(SimplePojo.class);
- assertTrue("Extracted type is not a composite/pojo type but should be.", type instanceof CompositeType);
- }
-
- public static class NestedPojoInner {
- public String field;
- }
-
- public static class NestedPojoOuter {
- public Integer intField;
- public NestedPojoInner inner;
- }
-
- @Test
- public void testNestedPojoTypeExtraction() {
- TypeInformation<NestedPojoOuter> type = TypeExtractor.getForClass(NestedPojoOuter.class);
- assertTrue("Extracted type is not a Pojo type but should be.", type instanceof CompositeType);
- }
-
- public static class Recursive1Pojo {
- public Integer intField;
- public Recursive2Pojo rec;
- }
-
- public static class Recursive2Pojo {
- public String strField;
- public Recursive1Pojo rec;
- }
-
- @Test
- public void testRecursivePojoTypeExtraction() {
- // This one tests whether a recursive pojo is detected using the set of visited
- // types in the type extractor. The recursive field will be handled using the generic serializer.
- TypeInformation<Recursive1Pojo> type = TypeExtractor.getForClass(Recursive1Pojo.class);
- assertTrue("Extracted type is not a Pojo type but should be.", type instanceof CompositeType);
- }
-
- @Test
- public void testRecursivePojoObjectTypeExtraction() {
- TypeInformation<Recursive1Pojo> type = TypeExtractor.getForObject(new Recursive1Pojo());
- assertTrue("Extracted type is not a Pojo type but should be.", type instanceof CompositeType);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorInputFormatsTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorInputFormatsTest.java b/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorInputFormatsTest.java
deleted file mode 100644
index bbf5148..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorInputFormatsTest.java
+++ /dev/null
@@ -1,234 +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.java.type.extractor;
-
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-
-import org.apache.flink.api.common.io.DefaultInputSplitAssigner;
-import org.apache.flink.api.common.io.GenericInputFormat;
-import org.apache.flink.api.common.io.InputFormat;
-import org.apache.flink.api.common.io.statistics.BaseStatistics;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.core.io.InputSplit;
-import org.junit.Test;
-
-@SuppressWarnings("serial")
-public class TypeExtractorInputFormatsTest {
-
- @Test
- public void testExtractInputFormatType() {
- try {
- InputFormat<?, ?> format = new DummyFloatInputFormat();
- TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
- assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, typeInfo);
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testExtractDerivedInputFormatType() {
- try {
- // simple type
- {
- InputFormat<?, ?> format = new DerivedInputFormat();
- TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
- assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, typeInfo);
- }
-
- // composite type
- {
- InputFormat<?, ?> format = new DerivedTupleInputFormat();
- TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
-
- assertTrue(typeInfo.isTupleType());
- assertTrue(typeInfo instanceof TupleTypeInfo);
-
- @SuppressWarnings("unchecked")
- TupleTypeInfo<Tuple3<String, Short, Double>> tupleInfo = (TupleTypeInfo<Tuple3<String, Short, Double>>) typeInfo;
-
- assertEquals(3, tupleInfo.getArity());
- assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tupleInfo.getTypeAt(0));
- assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tupleInfo.getTypeAt(1));
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tupleInfo.getTypeAt(2));
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testMultiLevelDerivedInputFormatType() {
- try {
-
- // composite type
- {
- InputFormat<?, ?> format = new FinalRelativeInputFormat();
- TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
-
- assertTrue(typeInfo.isTupleType());
- assertTrue(typeInfo instanceof TupleTypeInfo);
-
- @SuppressWarnings("unchecked")
- TupleTypeInfo<Tuple3<String, Integer, Double>> tupleInfo = (TupleTypeInfo<Tuple3<String, Integer, Double>>) typeInfo;
-
- assertEquals(3, tupleInfo.getArity());
- assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tupleInfo.getTypeAt(0));
- assertEquals(BasicTypeInfo.INT_TYPE_INFO, tupleInfo.getTypeAt(1));
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tupleInfo.getTypeAt(2));
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testQueryableFormatType() {
- try {
- InputFormat<?, ?> format = new QueryableInputFormat();
- TypeInformation<?> typeInfo = TypeExtractor.getInputFormatTypes(format);
- assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, typeInfo);
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- // --------------------------------------------------------------------------------------------
- // Test formats
- // --------------------------------------------------------------------------------------------
-
- public static final class DummyFloatInputFormat implements InputFormat<Float, InputSplit> {
-
- @Override
- public void configure(Configuration parameters) {}
-
- @Override
- public BaseStatistics getStatistics(BaseStatistics cachedStatistics) { return null; }
-
- @Override
- public InputSplit[] createInputSplits(int minNumSplits) { return null; }
-
- @Override
- public DefaultInputSplitAssigner getInputSplitAssigner(InputSplit[] splits) { return null; }
-
- @Override
- public void open(InputSplit split) {}
-
- @Override
- public boolean reachedEnd() { return false; }
-
- @Override
- public Float nextRecord(Float reuse) throws IOException { return null; }
-
- @Override
- public void close() {}
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static final class DerivedInputFormat extends GenericInputFormat<Short> {
-
- @Override
- public boolean reachedEnd() { return false; }
-
- @Override
- public Short nextRecord(Short reuse) { return null; }
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static final class DerivedTupleInputFormat extends GenericInputFormat<Tuple3<String, Short, Double>> {
-
- @Override
- public boolean reachedEnd() { return false; }
-
- @Override
- public Tuple3<String, Short, Double> nextRecord(Tuple3<String, Short, Double> reuse) { return null; }
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static class RelativeInputFormat<T> extends GenericInputFormat<Tuple3<String, T, Double>> {
-
- @Override
- public boolean reachedEnd() { return false; }
-
- @Override
- public Tuple3<String, T, Double> nextRecord(Tuple3<String, T, Double> reuse) { return null; }
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static final class FinalRelativeInputFormat extends RelativeInputFormat<Integer> {
-
- @Override
- public Tuple3<String, Integer, Double> nextRecord(Tuple3<String, Integer, Double> reuse) { return null; }
- }
-
- // --------------------------------------------------------------------------------------------
-
- public static final class QueryableInputFormat implements InputFormat<Float, InputSplit>, ResultTypeQueryable<Double> {
-
- @Override
- public void configure(Configuration parameters) {}
-
- @Override
- public BaseStatistics getStatistics(BaseStatistics cachedStatistics) { return null; }
-
- @Override
- public InputSplit[] createInputSplits(int minNumSplits) { return null; }
-
- @Override
- public DefaultInputSplitAssigner getInputSplitAssigner(InputSplit[] splits) { return null; }
-
- @Override
- public void open(InputSplit split) {}
-
- @Override
- public boolean reachedEnd() { return false; }
-
- @Override
- public Float nextRecord(Float reuse) throws IOException { return null; }
-
- @Override
- public void close() {}
-
- @Override
- public TypeInformation<Double> getProducedType() {
- return BasicTypeInfo.DOUBLE_TYPE_INFO;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flink/blob/21a71586/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorTest.java b/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorTest.java
deleted file mode 100644
index 57b32b1..0000000
--- a/flink-java/src/test/java/org/apache/flink/api/java/type/extractor/TypeExtractorTest.java
+++ /dev/null
@@ -1,1931 +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.java.type.extractor;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.flink.api.common.functions.InvalidTypesException;
-import org.apache.flink.api.common.functions.MapFunction;
-import org.apache.flink.api.common.functions.RichCoGroupFunction;
-import org.apache.flink.api.common.functions.RichCrossFunction;
-import org.apache.flink.api.common.functions.RichFlatJoinFunction;
-import org.apache.flink.api.common.functions.RichFlatMapFunction;
-import org.apache.flink.api.common.functions.RichGroupReduceFunction;
-import org.apache.flink.api.common.functions.RichMapFunction;
-import org.apache.flink.api.common.functions.RuntimeContext;
-import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
-import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.common.typeutils.CompositeType.FlatFieldDescriptor;
-import org.apache.flink.api.java.ExecutionEnvironment;
-import org.apache.flink.api.java.functions.KeySelector;
-import org.apache.flink.api.java.tuple.Tuple;
-import org.apache.flink.api.java.tuple.Tuple0;
-import org.apache.flink.api.java.tuple.Tuple1;
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.tuple.Tuple9;
-import org.apache.flink.api.java.typeutils.Either;
-import org.apache.flink.api.java.typeutils.EitherTypeInfo;
-import org.apache.flink.api.java.typeutils.EnumTypeInfo;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.api.java.typeutils.MissingTypeInfo;
-import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
-import org.apache.flink.api.java.typeutils.PojoTypeInfo;
-import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
-import org.apache.flink.api.java.typeutils.TupleTypeInfo;
-import org.apache.flink.api.java.typeutils.TypeExtractor;
-import org.apache.flink.api.java.typeutils.TypeInfoParser;
-import org.apache.flink.api.java.typeutils.ValueTypeInfo;
-import org.apache.flink.api.java.typeutils.WritableTypeInfo;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.types.DoubleValue;
-import org.apache.flink.types.IntValue;
-import org.apache.flink.types.StringValue;
-import org.apache.flink.types.Value;
-import org.apache.flink.util.Collector;
-import org.apache.hadoop.io.Writable;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-public class TypeExtractorTest {
-
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testBasicType() {
- // use getGroupReduceReturnTypes()
- RichGroupReduceFunction<?, ?> function = new RichGroupReduceFunction<Boolean, Boolean>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void reduce(Iterable<Boolean> values, Collector<Boolean> out) throws Exception {
- // nothing to do
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getGroupReduceReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Boolean"));
-
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
- Assert.assertEquals(Boolean.class, ti.getTypeClass());
-
- // use getForClass()
- Assert.assertTrue(TypeExtractor.getForClass(Boolean.class).isBasicType());
- Assert.assertEquals(ti, TypeExtractor.getForClass(Boolean.class));
-
- // use getForObject()
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, TypeExtractor.getForObject(Boolean.valueOf(true)));
- }
-
- public static class MyWritable implements Writable {
-
- @Override
- public void write(DataOutput out) throws IOException {
-
- }
-
- @Override
- public void readFields(DataInput in) throws IOException {
- }
-
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testWritableType() {
- RichMapFunction<?, ?> function = new RichMapFunction<MyWritable, MyWritable>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public MyWritable map(MyWritable value) throws Exception {
- return null;
- }
-
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) new WritableTypeInfo<MyWritable>(MyWritable.class));
-
- Assert.assertTrue(ti instanceof WritableTypeInfo<?>);
- Assert.assertEquals(MyWritable.class, ((WritableTypeInfo<?>) ti).getTypeClass());
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTupleWithBasicTypes() throws Exception {
- // use getMapReturnTypes()
- RichMapFunction<?, ?> function = new RichMapFunction<Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>, Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> map(
- Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> value) throws Exception {
- return null;
- }
-
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(9, ti.getArity());
- Assert.assertTrue(ti instanceof TupleTypeInfo);
- List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
- ((TupleTypeInfo) ti).getFlatFields("f3", 0, ffd);
- Assert.assertTrue(ffd.size() == 1);
- Assert.assertEquals(3, ffd.get(0).getPosition() );
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(Tuple9.class, tti.getTypeClass());
-
- for (int i = 0; i < 9; i++) {
- Assert.assertTrue(tti.getTypeAt(i) instanceof BasicTypeInfo);
- }
-
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(3));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(4));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(5));
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti.getTypeAt(6));
- Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti.getTypeAt(7));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti.getTypeAt(8));
-
- // use getForObject()
- Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte> t = new Tuple9<Integer, Long, Double, Float, Boolean, String, Character, Short, Byte>(
- 1, 1L, 1.0, 1.0F, false, "Hello World", 'w', (short) 1, (byte) 1);
-
- Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);
-
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti2.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti2.getTypeAt(2));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(3));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti2.getTypeAt(4));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti2.getTypeAt(5));
- Assert.assertEquals(BasicTypeInfo.CHAR_TYPE_INFO, tti2.getTypeAt(6));
- Assert.assertEquals(BasicTypeInfo.SHORT_TYPE_INFO, tti2.getTypeAt(7));
- Assert.assertEquals(BasicTypeInfo.BYTE_TYPE_INFO, tti2.getTypeAt(8));
-
- // test that getForClass does not work
- try {
- TypeExtractor.getForClass(Tuple9.class);
- Assert.fail("Exception expected here");
- } catch (InvalidTypesException e) {
- // that is correct
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTupleWithTuples() {
- // use getFlatMapReturnTypes()
- RichFlatMapFunction<?, ?> function = new RichFlatMapFunction<Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>, Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void flatMap(Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>> value,
- Collector<Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>> out) throws Exception {
- // nothing to do
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getFlatMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>"));
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(3, ti.getArity());
- Assert.assertTrue(ti instanceof TupleTypeInfo);
- List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
-
- ((TupleTypeInfo) ti).getFlatFields("f0.f0", 0, ffd);
- Assert.assertEquals(0, ffd.get(0).getPosition() );
- ffd.clear();
-
- ((TupleTypeInfo) ti).getFlatFields("f0.f0", 0, ffd);
- Assert.assertTrue( ffd.get(0).getType() instanceof BasicTypeInfo );
- Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(String.class) );
- ffd.clear();
-
- ((TupleTypeInfo) ti).getFlatFields("f1.f0", 0, ffd);
- Assert.assertEquals(1, ffd.get(0).getPosition() );
- ffd.clear();
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(Tuple3.class, tti.getTypeClass());
-
- Assert.assertTrue(tti.getTypeAt(0).isTupleType());
- Assert.assertTrue(tti.getTypeAt(1).isTupleType());
- Assert.assertTrue(tti.getTypeAt(2).isTupleType());
-
- Assert.assertEquals(Tuple1.class, tti.getTypeAt(0).getTypeClass());
- Assert.assertEquals(Tuple1.class, tti.getTypeAt(1).getTypeClass());
- Assert.assertEquals(Tuple2.class, tti.getTypeAt(2).getTypeClass());
-
- Assert.assertEquals(1, tti.getTypeAt(0).getArity());
- Assert.assertEquals(1, tti.getTypeAt(1).getArity());
- Assert.assertEquals(2, tti.getTypeAt(2).getArity());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(0)).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(1)).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(2)).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti.getTypeAt(2)).getTypeAt(1));
-
- // use getForObject()
- Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>> t = new Tuple3<Tuple1<String>, Tuple1<Integer>, Tuple2<Long, Long>>(
- new Tuple1<String>("hello"), new Tuple1<Integer>(1), new Tuple2<Long, Long>(2L, 3L));
- Assert.assertTrue(TypeExtractor.getForObject(t) instanceof TupleTypeInfo);
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) TypeExtractor.getForObject(t);
-
- Assert.assertEquals(1, tti2.getTypeAt(0).getArity());
- Assert.assertEquals(1, tti2.getTypeAt(1).getArity());
- Assert.assertEquals(2, tti2.getTypeAt(2).getArity());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(0)).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(1)).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(2)).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ((TupleTypeInfo<?>) tti2.getTypeAt(2)).getTypeAt(1));
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTuple0() {
- // use getFlatMapReturnTypes()
- RichFlatMapFunction<?, ?> function = new RichFlatMapFunction<Tuple0, Tuple0>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void flatMap(Tuple0 value, Collector<Tuple0> out) throws Exception {
- // nothing to do
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getFlatMapReturnTypes(function,
- (TypeInformation) TypeInfoParser.parse("Tuple0"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(0, ti.getArity());
- Assert.assertTrue(ti instanceof TupleTypeInfo);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testSubclassOfTuple() {
- // use getJoinReturnTypes()
- RichFlatJoinFunction<?, ?, ?> function = new RichFlatJoinFunction<CustomTuple, String, CustomTuple>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void join(CustomTuple first, String second, Collector<CustomTuple> out) throws Exception {
- out.collect(null);
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getFlatJoinReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, Integer>"), (TypeInformation) TypeInfoParser.parse("String"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) ti).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) ti).getTypeAt(1));
- Assert.assertEquals(CustomTuple.class, ((TupleTypeInfo<?>) ti).getTypeClass());
-
- // use getForObject()
- CustomTuple t = new CustomTuple("hello", 1);
- TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
-
- Assert.assertTrue(ti2.isTupleType());
- Assert.assertEquals(2, ti2.getArity());
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((TupleTypeInfo<?>) ti2).getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ((TupleTypeInfo<?>) ti2).getTypeAt(1));
- Assert.assertEquals(CustomTuple.class, ((TupleTypeInfo<?>) ti2).getTypeClass());
- }
-
- public static class CustomTuple extends Tuple2<String, Integer> {
- private static final long serialVersionUID = 1L;
-
- public CustomTuple(String myField1, Integer myField2) {
- this.setFields(myField1, myField2);
- }
-
- public String getMyField1() {
- return this.f0;
- }
-
- public int getMyField2() {
- return this.f1;
- }
- }
-
- public static class PojoWithNonPublicDefaultCtor {
- public int foo, bar;
- PojoWithNonPublicDefaultCtor() {}
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testPojo() {
- // use getCrossReturnTypes()
- RichCrossFunction<?, ?, ?> function = new RichCrossFunction<CustomType, Integer, CustomType>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public CustomType cross(CustomType first, Integer second) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getCrossReturnTypes(function, (TypeInformation) TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.TypeExtractorTest$CustomType"), (TypeInformation) TypeInfoParser.parse("Integer"));
-
- Assert.assertFalse(ti.isBasicType());
- Assert.assertFalse(ti.isTupleType());
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- Assert.assertEquals(ti.getTypeClass(), CustomType.class);
-
- // use getForClass()
- Assert.assertTrue(TypeExtractor.getForClass(CustomType.class) instanceof PojoTypeInfo);
- Assert.assertEquals(TypeExtractor.getForClass(CustomType.class).getTypeClass(), ti.getTypeClass());
-
- // use getForObject()
- CustomType t = new CustomType("World", 1);
- TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
-
- Assert.assertFalse(ti2.isBasicType());
- Assert.assertFalse(ti2.isTupleType());
- Assert.assertTrue(ti2 instanceof PojoTypeInfo);
- Assert.assertEquals(ti2.getTypeClass(), CustomType.class);
-
- Assert.assertFalse(TypeExtractor.getForClass(PojoWithNonPublicDefaultCtor.class) instanceof PojoTypeInfo);
- }
-
-
-
- public static class CustomType {
- public String myField1;
- public int myField2;
-
- public CustomType() {
- }
-
- public CustomType(String myField1, int myField2) {
- this.myField1 = myField1;
- this.myField2 = myField2;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTupleWithPojo() {
- // use getMapReturnTypes()
- RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<Long, CustomType>, Tuple2<Long, CustomType>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<Long, CustomType> map(Tuple2<Long, CustomType> value) throws Exception {
- return null;
- }
-
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Long,org.apache.flink.api.java.type.extractor.TypeExtractorTest$CustomType>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(Tuple2.class, tti.getTypeClass());
- List<FlatFieldDescriptor> ffd = new ArrayList<FlatFieldDescriptor>();
-
- tti.getFlatFields("f0", 0, ffd);
- Assert.assertEquals(1, ffd.size());
- Assert.assertEquals(0, ffd.get(0).getPosition() ); // Long
- Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(Long.class) );
- ffd.clear();
-
- tti.getFlatFields("f1.myField1", 0, ffd);
- Assert.assertEquals(1, ffd.get(0).getPosition() );
- Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(String.class) );
- ffd.clear();
-
-
- tti.getFlatFields("f1.myField2", 0, ffd);
- Assert.assertEquals(2, ffd.get(0).getPosition() );
- Assert.assertTrue( ffd.get(0).getType().getTypeClass().equals(Integer.class) );
-
-
- Assert.assertEquals(Long.class, tti.getTypeAt(0).getTypeClass());
- Assert.assertTrue(tti.getTypeAt(1) instanceof PojoTypeInfo);
- Assert.assertEquals(CustomType.class, tti.getTypeAt(1).getTypeClass());
-
- // use getForObject()
- Tuple2<?, ?> t = new Tuple2<Long, CustomType>(1L, new CustomType("Hello", 1));
- TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
-
- Assert.assertTrue(ti2.isTupleType());
- Assert.assertEquals(2, ti2.getArity());
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) ti2;
-
- Assert.assertEquals(Tuple2.class, tti2.getTypeClass());
- Assert.assertEquals(Long.class, tti2.getTypeAt(0).getTypeClass());
- Assert.assertTrue(tti2.getTypeAt(1) instanceof PojoTypeInfo);
- Assert.assertEquals(CustomType.class, tti2.getTypeAt(1).getTypeClass());
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testValue() {
- // use getKeyExtractorType()
- KeySelector<?, ?> function = new KeySelector<StringValue, StringValue>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public StringValue getKey(StringValue value) {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getKeySelectorTypes(function, (TypeInformation) TypeInfoParser.parse("StringValue"));
-
- Assert.assertFalse(ti.isBasicType());
- Assert.assertFalse(ti.isTupleType());
- Assert.assertTrue(ti instanceof ValueTypeInfo);
- Assert.assertEquals(ti.getTypeClass(), StringValue.class);
-
- // use getForClass()
- Assert.assertTrue(TypeExtractor.getForClass(StringValue.class) instanceof ValueTypeInfo);
- Assert.assertEquals(TypeExtractor.getForClass(StringValue.class).getTypeClass(), ti.getTypeClass());
-
- // use getForObject()
- StringValue v = new StringValue("Hello");
- Assert.assertTrue(TypeExtractor.getForObject(v) instanceof ValueTypeInfo);
- Assert.assertEquals(TypeExtractor.getForObject(v).getTypeClass(), ti.getTypeClass());
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTupleOfValues() {
- // use getMapReturnTypes()
- RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<StringValue, IntValue>, Tuple2<StringValue, IntValue>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<StringValue, IntValue> map(Tuple2<StringValue, IntValue> value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<StringValue, IntValue>"));
-
- Assert.assertFalse(ti.isBasicType());
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(StringValue.class, ((TupleTypeInfo<?>) ti).getTypeAt(0).getTypeClass());
- Assert.assertEquals(IntValue.class, ((TupleTypeInfo<?>) ti).getTypeAt(1).getTypeClass());
-
- // use getForObject()
- Tuple2<StringValue, IntValue> t = new Tuple2<StringValue, IntValue>(new StringValue("x"), new IntValue(1));
- TypeInformation<?> ti2 = TypeExtractor.getForObject(t);
-
- Assert.assertFalse(ti2.isBasicType());
- Assert.assertTrue(ti2.isTupleType());
- Assert.assertEquals(((TupleTypeInfo<?>) ti2).getTypeAt(0).getTypeClass(), StringValue.class);
- Assert.assertEquals(((TupleTypeInfo<?>) ti2).getTypeAt(1).getTypeClass(), IntValue.class);
- }
-
- public static class LongKeyValue<V> extends Tuple2<Long, V> {
- private static final long serialVersionUID = 1L;
-
- public LongKeyValue(Long field1, V field2) {
- this.f0 = field1;
- this.f1 = field2;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericsNotInSuperclass() {
- // use getMapReturnTypes()
- RichMapFunction<?, ?> function = new RichMapFunction<LongKeyValue<String>, LongKeyValue<String>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public LongKeyValue<String> map(LongKeyValue<String> value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Long, String>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(LongKeyValue.class, tti.getTypeClass());
-
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public static class ChainedOne<X, Y> extends Tuple3<X, Long, Y> {
- private static final long serialVersionUID = 1L;
-
- public ChainedOne(X field0, Long field1, Y field2) {
- this.f0 = field0;
- this.f1 = field1;
- this.f2 = field2;
- }
- }
-
- public static class ChainedTwo<V> extends ChainedOne<String, V> {
- private static final long serialVersionUID = 1L;
-
- public ChainedTwo(String field0, Long field1, V field2) {
- super(field0, field1, field2);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testChainedGenericsNotInSuperclass() {
- // use TypeExtractor
- RichMapFunction<?, ?> function = new RichMapFunction<ChainedTwo<Integer>, ChainedTwo<Integer>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public ChainedTwo<Integer> map(ChainedTwo<Integer> value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, Long, Integer>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(3, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(ChainedTwo.class, tti.getTypeClass());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti.getTypeAt(2));
- }
-
- public static class ChainedThree extends ChainedTwo<String> {
- private static final long serialVersionUID = 1L;
-
- public ChainedThree(String field0, Long field1, String field2) {
- super(field0, field1, field2);
- }
- }
-
- public static class ChainedFour extends ChainedThree {
- private static final long serialVersionUID = 1L;
-
- public ChainedFour(String field0, Long field1, String field2) {
- super(field0, field1, field2);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericsInDirectSuperclass() {
- // use TypeExtractor
- RichMapFunction<?, ?> function = new RichMapFunction<ChainedThree, ChainedThree>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public ChainedThree map(ChainedThree value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, Long, String>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(3, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(ChainedThree.class, tti.getTypeClass());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(2));
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testGenericsNotInSuperclassWithNonGenericClassAtEnd() {
- // use TypeExtractor
- RichMapFunction<?, ?> function = new RichMapFunction<ChainedFour, ChainedFour>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public ChainedFour map(ChainedFour value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, Long, String>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(3, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(ChainedFour.class, tti.getTypeClass());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(2));
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testMissingTupleGenerics() {
- RichMapFunction<?, ?> function = new RichMapFunction<String, Tuple2>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2 map(String value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"), "name", true);
- Assert.assertTrue(ti instanceof MissingTypeInfo);
-
- try {
- TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"));
- Assert.fail("Expected an exception");
- }
- catch (InvalidTypesException e) {
- // expected
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTupleSupertype() {
- RichMapFunction<?, ?> function = new RichMapFunction<String, Tuple>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple map(String value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"), "name", true);
- Assert.assertTrue(ti instanceof MissingTypeInfo);
-
- try {
- TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"));
- Assert.fail("Expected an exception");
- }
- catch (InvalidTypesException e) {
- // expected
- }
- }
-
- public static class SameTypeVariable<X> extends Tuple2<X, X> {
- private static final long serialVersionUID = 1L;
-
- public SameTypeVariable(X field0, X field1) {
- super(field0, field1);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testSameGenericVariable() {
- RichMapFunction<?, ?> function = new RichMapFunction<SameTypeVariable<String>, SameTypeVariable<String>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public SameTypeVariable<String> map(SameTypeVariable<String> value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, String>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(SameTypeVariable.class, tti.getTypeClass());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public static class Nested<V, T> extends Tuple2<V, Tuple2<T, T>> {
- private static final long serialVersionUID = 1L;
-
- public Nested(V field0, Tuple2<T, T> field1) {
- super(field0, field1);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testNestedTupleGenerics() {
- RichMapFunction<?, ?> function = new RichMapFunction<Nested<String, Integer>, Nested<String, Integer>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Nested<String, Integer> map(Nested<String, Integer> value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, Tuple2<Integer, Integer>>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
-
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(Nested.class, tti.getTypeClass());
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertTrue(tti.getTypeAt(1).isTupleType());
- Assert.assertEquals(2, tti.getTypeAt(1).getArity());
-
- // Nested
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(1);
- Assert.assertEquals(Tuple2.class, tti2.getTypeClass());
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti2.getTypeAt(1));
- }
-
- public static class Nested2<T> extends Nested<T, Nested<Integer, T>> {
- private static final long serialVersionUID = 1L;
-
- public Nested2(T field0, Tuple2<Nested<Integer, T>, Nested<Integer, T>> field1) {
- super(field0, field1);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testNestedTupleGenerics2() {
- RichMapFunction<?, ?> function = new RichMapFunction<Nested2<Boolean>, Nested2<Boolean>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Nested2<Boolean> map(Nested2<Boolean> value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Boolean, Tuple2<Tuple2<Integer, Tuple2<Boolean, Boolean>>, Tuple2<Integer, Tuple2<Boolean, Boolean>>>>"));
-
- // Should be
- // Tuple2<Boolean, Tuple2<Tuple2<Integer, Tuple2<Boolean, Boolean>>, Tuple2<Integer, Tuple2<Boolean, Boolean>>>>
-
- // 1st nested level
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertTrue(tti.getTypeAt(1).isTupleType());
-
- // 2nd nested level
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(1);
- Assert.assertTrue(tti2.getTypeAt(0).isTupleType());
- Assert.assertTrue(tti2.getTypeAt(1).isTupleType());
-
- // 3rd nested level
- TupleTypeInfo<?> tti3 = (TupleTypeInfo<?>) tti2.getTypeAt(0);
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, tti3.getTypeAt(0));
- Assert.assertTrue(tti3.getTypeAt(1).isTupleType());
-
- // 4th nested level
- TupleTypeInfo<?> tti4 = (TupleTypeInfo<?>) tti3.getTypeAt(1);
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti4.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti4.getTypeAt(1));
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testFunctionWithMissingGenerics() {
- RichMapFunction function = new RichMapFunction() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(Object value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, TypeInfoParser.parse("String"), "name", true);
- Assert.assertTrue(ti instanceof MissingTypeInfo);
-
- try {
- TypeExtractor.getMapReturnTypes(function, TypeInfoParser.parse("String"));
- Assert.fail("Expected an exception");
- }
- catch (InvalidTypesException e) {
- // expected
- }
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- @Test
- public void testFunctionWithMissingGenericsAndReturns() {
- RichMapFunction function = new RichMapFunction() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Object map(Object value) throws Exception {
- return null;
- }
- };
-
- TypeInformation info = ExecutionEnvironment.getExecutionEnvironment()
- .fromElements("arbitrary", "data")
- .map(function).returns("String").getResultType();
-
- Assert.assertEquals(TypeInfoParser.parse("String"), info);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testFunctionDependingOnInputAsSuperclass() {
- IdentityMapper<Boolean> function = new IdentityMapper<Boolean>() {
- private static final long serialVersionUID = 1L;
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Boolean"));
-
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
- }
-
- public class IdentityMapper<T> extends RichMapFunction<T, T> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public T map(T value) throws Exception {
- return null;
- }
- }
-
- @Test
- public void testFunctionDependingOnInputFromInput() {
- IdentityMapper<Boolean> function = new IdentityMapper<Boolean>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.BOOLEAN_TYPE_INFO);
-
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
- }
-
- @Test
- public void testFunctionDependingOnInputWithMissingInput() {
- IdentityMapper<Boolean> function = new IdentityMapper<Boolean>();
-
- try {
- TypeExtractor.getMapReturnTypes(function, null);
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
- }
-
- public class IdentityMapper2<T> extends RichMapFunction<Tuple2<T, String>, T> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public T map(Tuple2<T, String> value) throws Exception {
- return null;
- }
- }
-
- @Test
- public void testFunctionDependingOnInputWithTupleInput() {
- IdentityMapper2<Boolean> function = new IdentityMapper2<Boolean>();
-
- TypeInformation<Tuple2<Boolean, String>> inputType = new TupleTypeInfo<Tuple2<Boolean, String>>(BasicTypeInfo.BOOLEAN_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO);
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, inputType);
-
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testFunctionDependingOnInputWithCustomTupleInput() {
- IdentityMapper<SameTypeVariable<String>> function = new IdentityMapper<SameTypeVariable<String>>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, String>"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public class IdentityMapper3<T, V> extends RichMapFunction<T, V> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public V map(T value) throws Exception {
- return null;
- }
- }
-
- @Test
- public void testFunctionDependingOnUnknownInput() {
- IdentityMapper3<Boolean, String> function = new IdentityMapper3<Boolean, String>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.BOOLEAN_TYPE_INFO, "name", true);
- Assert.assertTrue(ti instanceof MissingTypeInfo);
-
- try {
- TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.BOOLEAN_TYPE_INFO);
- Assert.fail("Expected an exception");
- }
- catch (InvalidTypesException e) {
- // expected
- }
- }
-
- public class IdentityMapper4<D> extends IdentityMapper<D> {
- private static final long serialVersionUID = 1L;
- }
-
- @Test
- public void testFunctionDependingOnInputWithFunctionHierarchy() {
- IdentityMapper4<String> function = new IdentityMapper4<String>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.STRING_TYPE_INFO);
-
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
- }
-
- public class IdentityMapper5<D> extends IdentityMapper<Tuple2<D, D>> {
- private static final long serialVersionUID = 1L;
- }
-
- @Test
- public void testFunctionDependingOnInputWithFunctionHierarchy2() {
- IdentityMapper5<String> function = new IdentityMapper5<String>();
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, new TupleTypeInfo(BasicTypeInfo.STRING_TYPE_INFO,
- BasicTypeInfo.STRING_TYPE_INFO));
-
- Assert.assertTrue(ti.isTupleType());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public class Mapper extends IdentityMapper<String> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(String value) throws Exception {
- return null;
- }
- }
-
- public class Mapper2 extends Mapper {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(String value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testFunctionWithNoGenericSuperclass() {
- RichMapFunction<?, ?> function = new Mapper2();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String"));
-
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
- }
-
- public class OneAppender<T> extends RichMapFunction<T, Tuple2<T, Integer>> {
- private static final long serialVersionUID = 1L;
-
- public Tuple2<T, Integer> map(T value) {
- return new Tuple2<T, Integer>(value, 1);
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testFunctionDependingPartialOnInput() {
- RichMapFunction<?, ?> function = new OneAppender<DoubleValue>() {
- private static final long serialVersionUID = 1L;
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("DoubleValue"));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
-
- Assert.assertTrue(tti.getTypeAt(0) instanceof ValueTypeInfo<?>);
- ValueTypeInfo<?> vti = (ValueTypeInfo<?>) tti.getTypeAt(0);
- Assert.assertEquals(DoubleValue.class, vti.getTypeClass());
-
- Assert.assertTrue(tti.getTypeAt(1).isBasicType());
- Assert.assertEquals(Integer.class , tti.getTypeAt(1).getTypeClass());
- }
-
- @Test
- public void testFunctionDependingPartialOnInput2() {
- RichMapFunction<DoubleValue, ?> function = new OneAppender<DoubleValue>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, new ValueTypeInfo<DoubleValue>(DoubleValue.class));
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
-
- Assert.assertTrue(tti.getTypeAt(0) instanceof ValueTypeInfo<?>);
- ValueTypeInfo<?> vti = (ValueTypeInfo<?>) tti.getTypeAt(0);
- Assert.assertEquals(DoubleValue.class, vti.getTypeClass());
-
- Assert.assertTrue(tti.getTypeAt(1).isBasicType());
- Assert.assertEquals(Integer.class , tti.getTypeAt(1).getTypeClass());
- }
-
- public class FieldDuplicator<T> extends RichMapFunction<T, Tuple2<T, T>> {
- private static final long serialVersionUID = 1L;
-
- public Tuple2<T, T> map(T value) {
- return new Tuple2<T, T>(value, value);
- }
- }
-
- @Test
- public void testFunctionInputInOutputMultipleTimes() {
- RichMapFunction<Float, ?> function = new FieldDuplicator<Float>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.FLOAT_TYPE_INFO);
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti.getTypeAt(1));
- }
-
- @Test
- public void testFunctionInputInOutputMultipleTimes2() {
- RichMapFunction<Tuple2<Float, Float>, ?> function = new FieldDuplicator<Tuple2<Float, Float>>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, new TupleTypeInfo<Tuple2<Float, Float>>(
- BasicTypeInfo.FLOAT_TYPE_INFO, BasicTypeInfo.FLOAT_TYPE_INFO));
-
- // should be
- // Tuple2<Tuple2<Float, Float>, Tuple2<Float, Float>>
-
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
-
- // 2nd nested level
- Assert.assertTrue(tti.getTypeAt(0).isTupleType());
- TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(0);
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti2.getTypeAt(1));
- Assert.assertTrue(tti.getTypeAt(0).isTupleType());
- TupleTypeInfo<?> tti3 = (TupleTypeInfo<?>) tti.getTypeAt(1);
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti3.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.FLOAT_TYPE_INFO, tti3.getTypeAt(1));
- }
-
- public interface Testable {}
-
- public static abstract class AbstractClassWithoutMember {}
-
- public static abstract class AbstractClassWithMember {
- public int x;
- }
-
- @Test
- public void testAbstractAndInterfaceTypes() {
-
- // interface
- RichMapFunction<String, ?> function = new RichMapFunction<String, Testable>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Testable map(String value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertTrue(ti instanceof GenericTypeInfo);
-
- // abstract class with out class member
- RichMapFunction<String, ?> function2 = new RichMapFunction<String, AbstractClassWithoutMember>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public AbstractClassWithoutMember map(String value) throws Exception {
- return null;
- }
- };
-
- ti = TypeExtractor.getMapReturnTypes(function2, BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertTrue(ti instanceof GenericTypeInfo);
-
- // abstract class with class member
- RichMapFunction<String, ?> function3 = new RichMapFunction<String, AbstractClassWithMember>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public AbstractClassWithMember map(String value) throws Exception {
- return null;
- }
- };
-
- ti = TypeExtractor.getMapReturnTypes(function3, BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testValueSupertypeException() {
- RichMapFunction<?, ?> function = new RichMapFunction<StringValue, Value>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Value map(StringValue value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti =TypeExtractor.getMapReturnTypes(function, (TypeInformation)TypeInfoParser.parse("StringValue"), "name", true);
- Assert.assertTrue(ti instanceof MissingTypeInfo);
-
- try {
- TypeExtractor.getMapReturnTypes(function, (TypeInformation)TypeInfoParser.parse("StringValue"));
- Assert.fail("Expected an exception");
- }
- catch (InvalidTypesException e) {
- // expected
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testBasicArray() {
- // use getCoGroupReturnTypes()
- RichCoGroupFunction<?, ?, ?> function = new RichCoGroupFunction<String[], String[], String[]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void coGroup(Iterable<String[]> first, Iterable<String[]> second, Collector<String[]> out) throws Exception {
- // nothing to do
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getCoGroupReturnTypes(function, (TypeInformation) TypeInfoParser.parse("String[]"), (TypeInformation) TypeInfoParser.parse("String[]"));
-
- Assert.assertFalse(ti.isBasicType());
- Assert.assertFalse(ti.isTupleType());
-
- // Due to a Java 6 bug the classification can be slightly wrong
- Assert.assertTrue(ti instanceof BasicArrayTypeInfo<?,?> || ti instanceof ObjectArrayTypeInfo<?,?>);
-
- if(ti instanceof BasicArrayTypeInfo<?,?>) {
- Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, ti);
- }
- else {
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ((ObjectArrayTypeInfo<?,?>) ti).getComponentInfo());
- }
- }
-
- @Test
- public void testBasicArray2() {
- RichMapFunction<Boolean[], ?> function = new IdentityMapper<Boolean[]>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicArrayTypeInfo.BOOLEAN_ARRAY_TYPE_INFO);
-
- Assert.assertTrue(ti instanceof BasicArrayTypeInfo<?, ?>);
- BasicArrayTypeInfo<?, ?> bati = (BasicArrayTypeInfo<?, ?>) ti;
- Assert.assertTrue(bati.getComponentInfo().isBasicType());
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, bati.getComponentInfo());
- }
-
- public static class CustomArrayObject {}
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testCustomArray() {
- RichMapFunction<?, ?> function = new RichMapFunction<CustomArrayObject[], CustomArrayObject[]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public CustomArrayObject[] map(CustomArrayObject[] value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.TypeExtractorTest$CustomArrayObject[]"));
-
- Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
- Assert.assertEquals(CustomArrayObject.class, ((ObjectArrayTypeInfo<?, ?>) ti).getComponentInfo().getTypeClass());
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testTupleArray() {
- RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<String, String>[], Tuple2<String, String>[]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<String, String>[] map(Tuple2<String, String>[] value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<String, String>[]"));
-
- Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
- ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) ti;
- Assert.assertTrue(oati.getComponentInfo().isTupleType());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) oati.getComponentInfo();
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public class CustomArrayObject2<F> extends Tuple1<F> {
- private static final long serialVersionUID = 1L;
-
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testCustomArrayWithTypeVariable() {
- RichMapFunction<CustomArrayObject2<Boolean>[], ?> function = new IdentityMapper<CustomArrayObject2<Boolean>[]>();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple1<Boolean>[]"));
-
- Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?, ?>);
- ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) ti;
- Assert.assertTrue(oati.getComponentInfo().isTupleType());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) oati.getComponentInfo();
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(0));
- }
-
- public class GenericArrayClass<T> extends RichMapFunction<T[], T[]> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public T[] map(T[] value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testParameterizedArrays() {
- GenericArrayClass<Boolean> function = new GenericArrayClass<Boolean>(){
- private static final long serialVersionUID = 1L;
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Boolean[]"));
- Assert.assertTrue(ti instanceof ObjectArrayTypeInfo<?,?>);
- ObjectArrayTypeInfo<?, ?> oati = (ObjectArrayTypeInfo<?, ?>) ti;
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, oati.getComponentInfo());
- }
-
- public static class MyObject<T> {
- public T myField;
- }
-
- public static class InType extends MyObject<String> {}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testParameterizedPojo() {
- RichMapFunction<?, ?> function = new RichMapFunction<InType, MyObject<String>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public MyObject<String> map(InType value) throws Exception {
- return null;
- }
- };
- TypeInformation<?> inType = TypeExtractor.createTypeInfo(InType.class);
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, (TypeInformation) inType);
- Assert.assertTrue(ti instanceof PojoTypeInfo);
- }
-
- @Test
- public void testFunctionDependingOnInputWithTupleInputWithTypeMismatch() {
- IdentityMapper2<Boolean> function = new IdentityMapper2<Boolean>();
-
- TypeInformation<Tuple2<Boolean, String>> inputType = new TupleTypeInfo<Tuple2<Boolean, String>>(BasicTypeInfo.BOOLEAN_TYPE_INFO,
- BasicTypeInfo.INT_TYPE_INFO);
-
- // input is: Tuple2<Boolean, Integer>
- // allowed: Tuple2<?, String>
-
- try {
- TypeExtractor.getMapReturnTypes(function, inputType);
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testInputMismatchExceptions() {
-
- RichMapFunction<?, ?> function = new RichMapFunction<Tuple2<String, String>, String>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(Tuple2<String, String> value) throws Exception {
- return null;
- }
- };
-
- try {
- TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple2<Integer, String>"));
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
-
- try {
- TypeExtractor.getMapReturnTypes(function, (TypeInformation) TypeInfoParser.parse("Tuple3<String, String, String>"));
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
-
- RichMapFunction<?, ?> function2 = new RichMapFunction<StringValue, String>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(StringValue value) throws Exception {
- return null;
- }
- };
-
- try {
- TypeExtractor.getMapReturnTypes(function2, (TypeInformation) TypeInfoParser.parse("IntValue"));
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
-
- RichMapFunction<?, ?> function3 = new RichMapFunction<Tuple1<Integer>[], String>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(Tuple1<Integer>[] value) throws Exception {
- return null;
- }
- };
-
- try {
- TypeExtractor.getMapReturnTypes(function3, (TypeInformation) TypeInfoParser.parse("Integer[]"));
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
-
- RichMapFunction<?, ?> function4 = new RichMapFunction<Writable, String>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String map(Writable value) throws Exception {
- return null;
- }
- };
-
- try {
- TypeExtractor.getMapReturnTypes(function4, (TypeInformation) new WritableTypeInfo<MyWritable>(MyWritable.class));
- Assert.fail("exception expected");
- } catch (InvalidTypesException e) {
- // right
- }
- }
-
- public static class DummyFlatMapFunction<A,B,C,D> extends RichFlatMapFunction<Tuple2<A,B>, Tuple2<C,D>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void flatMap(Tuple2<A, B> value, Collector<Tuple2<C, D>> out) throws Exception {
-
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testTypeErasure() {
- TypeInformation<?> ti = TypeExtractor.getFlatMapReturnTypes(new DummyFlatMapFunction<String, Integer, String, Boolean>(),
- (TypeInformation) TypeInfoParser.parse("Tuple2<String, Integer>"), "name", true);
- Assert.assertTrue(ti instanceof MissingTypeInfo);
-
- try {
- TypeExtractor.getFlatMapReturnTypes(new DummyFlatMapFunction<String, Integer, String, Boolean>(),
- (TypeInformation) TypeInfoParser.parse("Tuple2<String, Integer>"));
-
- Assert.fail("Expected an exception");
- }
- catch (InvalidTypesException e) {
- // expected
- }
- }
-
- public static class MyQueryableMapper<A> extends RichMapFunction<String, A> implements ResultTypeQueryable<A> {
- private static final long serialVersionUID = 1L;
-
- @SuppressWarnings("unchecked")
- @Override
- public TypeInformation<A> getProducedType() {
- return (TypeInformation<A>) BasicTypeInfo.INT_TYPE_INFO;
- }
-
- @Override
- public A map(String value) throws Exception {
- return null;
- }
- }
-
- @Test
- public void testResultTypeQueryable() {
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(new MyQueryableMapper<Integer>(), BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
- }
-
- @Test
- public void testTupleWithPrimitiveArray() {
- RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>> function = new RichMapFunction<Integer, Tuple9<int[],double[],long[],byte[],char[],float[],short[], boolean[], String[]>>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple9<int[], double[], long[], byte[], char[], float[], short[], boolean[], String[]> map(Integer value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(function, BasicTypeInfo.INT_TYPE_INFO);
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(PrimitiveArrayTypeInfo.INT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(PrimitiveArrayTypeInfo.DOUBLE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(PrimitiveArrayTypeInfo.LONG_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(2));
- Assert.assertEquals(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(3));
- Assert.assertEquals(PrimitiveArrayTypeInfo.CHAR_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(4));
- Assert.assertEquals(PrimitiveArrayTypeInfo.FLOAT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(5));
- Assert.assertEquals(PrimitiveArrayTypeInfo.SHORT_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(6));
- Assert.assertEquals(PrimitiveArrayTypeInfo.BOOLEAN_PRIMITIVE_ARRAY_TYPE_INFO, tti.getTypeAt(7));
- Assert.assertEquals(BasicArrayTypeInfo.STRING_ARRAY_TYPE_INFO, tti.getTypeAt(8));
- }
-
- @Test
- public void testFunction() {
- RichMapFunction<String, Boolean> mapInterface = new RichMapFunction<String, Boolean>() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void setRuntimeContext(RuntimeContext t) {
-
- }
-
- @Override
- public void open(Configuration parameters) throws Exception {
- }
-
- @Override
- public RuntimeContext getRuntimeContext() {
- return null;
- }
-
- @Override
- public void close() throws Exception {
-
- }
-
- @Override
- public Boolean map(String record) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(mapInterface, BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
- }
-
- @Test
- public void testInterface() {
- MapFunction<String, Boolean> mapInterface = new MapFunction<String, Boolean>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Boolean map(String record) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes(mapInterface, BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, ti);
- }
-
- @Test
- public void testCreateTypeInfoFromInstance() {
- ResultTypeQueryable instance = new ResultTypeQueryable<Long>() {
- @Override
- public TypeInformation<Long> getProducedType() {
- return BasicTypeInfo.LONG_TYPE_INFO;
- }
- };
- TypeInformation<?> ti = TypeExtractor.createTypeInfo(instance, null, null, 0);
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, ti);
-
- // method also needs to work for instances that do not implement ResultTypeQueryable
- MapFunction<Integer, Long> func = new MapFunction<Integer, Long>() {
- @Override
- public Long map(Integer value) throws Exception {
- return value.longValue();
- }
- };
- ti = TypeExtractor.createTypeInfo(func, MapFunction.class, func.getClass(), 0);
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
- }
-
- @SuppressWarnings({ "serial", "unchecked", "rawtypes" })
- @Test
- public void testExtractKeySelector() {
- KeySelector<String, Integer> selector = new KeySelector<String, Integer>() {
- @Override
- public Integer getKey(String value) { return null; }
- };
-
- TypeInformation<?> ti = TypeExtractor.getKeySelectorTypes(selector, BasicTypeInfo.STRING_TYPE_INFO);
- Assert.assertEquals(BasicTypeInfo.INT_TYPE_INFO, ti);
-
- try {
- TypeExtractor.getKeySelectorTypes((KeySelector) selector, BasicTypeInfo.BOOLEAN_TYPE_INFO);
- Assert.fail();
- }
- catch (InvalidTypesException e) {
- // good
- }
- catch (Exception e) {
- Assert.fail("wrong exception type");
- }
- }
-
- public static class DuplicateValue<T> implements MapFunction<Tuple1<T>, Tuple2<T, T>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<T, T> map(Tuple1<T> vertex) {
- return new Tuple2<T, T>(vertex.f0, vertex.f0);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testDuplicateValue() {
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) new DuplicateValue<String>(), TypeInfoParser.parse("Tuple1<String>"));
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public static class DuplicateValueNested<T> implements MapFunction<Tuple1<Tuple1<T>>, Tuple2<T, T>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<T, T> map(Tuple1<Tuple1<T>> vertex) {
- return new Tuple2<T, T>(null, null);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testDuplicateValueNested() {
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) new DuplicateValueNested<String>(), TypeInfoParser.parse("Tuple1<Tuple1<String>>"));
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(2, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- }
-
- public static class Edge<K, V> extends Tuple3<K, K, V> {
- private static final long serialVersionUID = 1L;
-
- }
-
- public static class EdgeMapper<K, V> implements MapFunction<Edge<K, V>, Edge<K, V>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Edge<K, V> map(Edge<K, V> value) throws Exception {
- return null;
- }
-
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testInputInference1() {
- EdgeMapper<String, Double> em = new EdgeMapper<String, Double>();
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Tuple3<String, String, Double>"));
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(3, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.DOUBLE_TYPE_INFO, tti.getTypeAt(2));
- }
-
- public static class EdgeMapper2<V> implements MapFunction<V, Edge<Long, V>> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Edge<Long, V> map(V value) throws Exception {
- return null;
- }
-
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testInputInference2() {
- EdgeMapper2<Boolean> em = new EdgeMapper2<Boolean>();
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Boolean"));
- Assert.assertTrue(ti.isTupleType());
- Assert.assertEquals(3, ti.getArity());
- TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(0));
- Assert.assertEquals(BasicTypeInfo.LONG_TYPE_INFO, tti.getTypeAt(1));
- Assert.assertEquals(BasicTypeInfo.BOOLEAN_TYPE_INFO, tti.getTypeAt(2));
- }
-
- public static class EdgeMapper3<K, V> implements MapFunction<Edge<K, V>, V> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public V map(Edge<K, V> value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testInputInference3() {
- EdgeMapper3<Boolean, String> em = new EdgeMapper3<Boolean, String>();
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Tuple3<Boolean,Boolean,String>"));
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
- }
-
- public static class EdgeMapper4<K, V> implements MapFunction<Edge<K, V>[], V> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public V map(Edge<K, V>[] value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testInputInference4() {
- EdgeMapper4<Boolean, String> em = new EdgeMapper4<Boolean, String>();
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) em, TypeInfoParser.parse("Tuple3<Boolean,Boolean,String>[]"));
- Assert.assertTrue(ti.isBasicType());
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
- }
-
- public static enum MyEnum {
- ONE, TWO, THREE
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testEnumType() {
- MapFunction<?, ?> mf = new MapFunction<MyEnum, MyEnum>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public MyEnum map(MyEnum value) throws Exception {
- return null;
- }
- };
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) mf, new EnumTypeInfo(MyEnum.class));
- Assert.assertTrue(ti instanceof EnumTypeInfo);
- Assert.assertEquals(ti.getTypeClass(), MyEnum.class);
- }
-
- public static class MapperWithMultiDimGenericArray<T> implements MapFunction<T[][][], Tuple1<T>[][][]> {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple1<T>[][][] map(T[][][] value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testMultiDimensionalArray() {
- // tuple array
- MapFunction<?,?> function = new MapFunction<Tuple2<Integer, Double>[][], Tuple2<Integer, Double>[][]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Tuple2<Integer, Double>[][] map(
- Tuple2<Integer, Double>[][] value) throws Exception {
- return null;
- }
- };
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("Tuple2<Integer, Double>[][]"));
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<Java Tuple2<Integer, Double>>>", ti.toString());
-
- // primitive array
- function = new MapFunction<int[][][], int[][][]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public int[][][] map(
- int[][][] value) throws Exception {
- return null;
- }
- };
- ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("int[][][]"));
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<int[]>>", ti.toString());
-
- // basic array
- function = new MapFunction<Integer[][][], Integer[][][]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Integer[][][] map(
- Integer[][][] value) throws Exception {
- return null;
- }
- };
- ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("Integer[][][]"));
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<BasicArrayTypeInfo<Integer>>>", ti.toString());
-
- // pojo array
- function = new MapFunction<CustomType[][][], CustomType[][][]>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public CustomType[][][] map(
- CustomType[][][] value) throws Exception {
- return null;
- }
- };
- ti = TypeExtractor.getMapReturnTypes((MapFunction)function, TypeInfoParser.parse("org.apache.flink.api.java.type.extractor.TypeExtractorTest$CustomType<"
- + "myField1=String,myField2=int"
- + ">[][][]"));
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<"
- + "PojoType<org.apache.flink.api.java.type.extractor.TypeExtractorTest$CustomType, fields = [myField1: String, myField2: Integer]>"
- + ">>>", ti.toString());
-
- // generic array
- ti = TypeExtractor.getMapReturnTypes((MapFunction) new MapperWithMultiDimGenericArray<String>(), TypeInfoParser.parse("String[][][]"));
- Assert.assertEquals("ObjectArrayTypeInfo<ObjectArrayTypeInfo<ObjectArrayTypeInfo<Java Tuple1<String>>>>", ti.toString());
- }
-
- @SuppressWarnings("rawtypes")
- public static class MapWithResultTypeQueryable implements MapFunction, ResultTypeQueryable {
- private static final long serialVersionUID = 1L;
-
- @Override
- public TypeInformation getProducedType() {
- return BasicTypeInfo.STRING_TYPE_INFO;
- }
-
- @Override
- public Object map(Object value) throws Exception {
- return null;
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Test
- public void testInputMismatchWithRawFuntion() {
- MapFunction<?, ?> function = new MapWithResultTypeQueryable();
-
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction)function, BasicTypeInfo.INT_TYPE_INFO);
- Assert.assertEquals(BasicTypeInfo.STRING_TYPE_INFO, ti);
- }
-
- public static class Either1<T> extends Either<String, T> {
- @Override
- public String left() throws IllegalStateException {
- return null;
- }
-
- @Override
- public T right() throws IllegalStateException {
- return null;
- }
- }
-
- public static class Either2 extends Either1<Tuple1<Integer>> {
- // nothing to do here
- }
-
- public static class EitherMapper<T> implements MapFunction<T, Either1<T>> {
- @Override
- public Either1<T> map(T value) throws Exception {
- return null;
- }
- }
-
- public static class EitherMapper2 implements MapFunction<String, Either2> {
- @Override
- public Either2 map(String value) throws Exception {
- return null;
- }
- }
-
- public static class EitherMapper3 implements MapFunction<Either2, Either2> {
- @Override
- public Either2 map(Either2 value) throws Exception {
- return null;
- }
- }
-
- @Test
- public void testEither() {
- MapFunction<?, ?> function = new MapFunction<Either<String, Boolean>, Either<String, Boolean>>() {
- @Override
- public Either<String, Boolean> map(Either<String, Boolean> value) throws Exception {
- return null;
- }
- };
- TypeInformation<?> expected = new EitherTypeInfo(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.BOOLEAN_TYPE_INFO);
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) function, expected);
- Assert.assertEquals(expected, ti);
- }
-
- @Test
- public void testEitherHierarchy() {
- MapFunction<?, ?> function = new EitherMapper<Boolean>();
- TypeInformation<?> ti = TypeExtractor.getMapReturnTypes((MapFunction) function, BasicTypeInfo.BOOLEAN_TYPE_INFO);
- TypeInformation<?> expected = new EitherTypeInfo(BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.BOOLEAN_TYPE_INFO);
- Assert.assertEquals(expected, ti);
-
- function = new EitherMapper2();
- ti = TypeExtractor.getMapReturnTypes((MapFunction) function, BasicTypeInfo.STRING_TYPE_INFO);
- expected = new EitherTypeInfo(BasicTypeInfo.STRING_TYPE_INFO, new TupleTypeInfo(BasicTypeInfo.INT_TYPE_INFO));
- Assert.assertEquals(expected, ti);
-
- function = new EitherMapper3();
- ti = TypeExtractor.getMapReturnTypes((MapFunction) function, expected);
- Assert.assertEquals(expected, ti);
-
- Either<String, Tuple1<Integer>> either = new Either2();
- ti = TypeExtractor.getForObject(either);
- Assert.assertEquals(expected, ti);
- }
-
- @Test(expected=InvalidTypesException.class)
- public void testEitherFromObjectException() {
- Either<String, Tuple1<Integer>> either = Either.Left("test");
- TypeExtractor.getForObject(either);
- }
-}