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

org.apache.flink.streaming.api.datastream.StreamProjection Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT 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.api.datastream;

import org.apache.flink.annotation.PublicEvolving;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple1;
import org.apache.flink.api.java.tuple.Tuple10;
import org.apache.flink.api.java.tuple.Tuple11;
import org.apache.flink.api.java.tuple.Tuple12;
import org.apache.flink.api.java.tuple.Tuple13;
import org.apache.flink.api.java.tuple.Tuple14;
import org.apache.flink.api.java.tuple.Tuple15;
import org.apache.flink.api.java.tuple.Tuple16;
import org.apache.flink.api.java.tuple.Tuple17;
import org.apache.flink.api.java.tuple.Tuple18;
import org.apache.flink.api.java.tuple.Tuple19;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple20;
import org.apache.flink.api.java.tuple.Tuple21;
import org.apache.flink.api.java.tuple.Tuple22;
import org.apache.flink.api.java.tuple.Tuple23;
import org.apache.flink.api.java.tuple.Tuple24;
import org.apache.flink.api.java.tuple.Tuple25;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.api.java.tuple.Tuple4;
import org.apache.flink.api.java.tuple.Tuple5;
import org.apache.flink.api.java.tuple.Tuple6;
import org.apache.flink.api.java.tuple.Tuple7;
import org.apache.flink.api.java.tuple.Tuple8;
import org.apache.flink.api.java.tuple.Tuple9;
import org.apache.flink.api.java.typeutils.TupleTypeInfo;
import org.apache.flink.streaming.api.operators.StreamProject;
import org.apache.flink.util.Preconditions;

/**
 * The result of {@link DataStream#project(int...)}. This can be used to add more fields to the
 * projection.
 */
@PublicEvolving
public class StreamProjection {

    private DataStream dataStream;
    private int[] fieldIndexes;

    protected StreamProjection(DataStream dataStream, int[] fieldIndexes) {
        if (!dataStream.getType().isTupleType()) {
            throw new RuntimeException("Only Tuple DataStreams can be projected");
        }
        if (fieldIndexes.length == 0) {
            throw new IllegalArgumentException("project() needs to select at least one (1) field.");
        } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) {
            throw new IllegalArgumentException(
                    "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") fields.");
        }

        int maxFieldIndex = (dataStream.getType()).getArity();
        for (int i = 0; i < fieldIndexes.length; i++) {
            Preconditions.checkElementIndex(fieldIndexes[i], maxFieldIndex);
        }

        this.dataStream = dataStream;
        this.fieldIndexes = fieldIndexes;
    }

    /**
     * Chooses a projectTupleX according to the length of {@link
     * org.apache.flink.streaming.api.datastream.StreamProjection#fieldIndexes}.
     *
     * @return The projected DataStream.
     * @see org.apache.flink.api.java.operators.ProjectOperator.Projection
     */
    @SuppressWarnings("unchecked")
    public  SingleOutputStreamOperator projectTupleX() {
        SingleOutputStreamOperator projOperator = null;

        switch (fieldIndexes.length) {
            case 1:
                projOperator = (SingleOutputStreamOperator) projectTuple1();
                break;
            case 2:
                projOperator = (SingleOutputStreamOperator) projectTuple2();
                break;
            case 3:
                projOperator = (SingleOutputStreamOperator) projectTuple3();
                break;
            case 4:
                projOperator = (SingleOutputStreamOperator) projectTuple4();
                break;
            case 5:
                projOperator = (SingleOutputStreamOperator) projectTuple5();
                break;
            case 6:
                projOperator = (SingleOutputStreamOperator) projectTuple6();
                break;
            case 7:
                projOperator = (SingleOutputStreamOperator) projectTuple7();
                break;
            case 8:
                projOperator = (SingleOutputStreamOperator) projectTuple8();
                break;
            case 9:
                projOperator = (SingleOutputStreamOperator) projectTuple9();
                break;
            case 10:
                projOperator = (SingleOutputStreamOperator) projectTuple10();
                break;
            case 11:
                projOperator = (SingleOutputStreamOperator) projectTuple11();
                break;
            case 12:
                projOperator = (SingleOutputStreamOperator) projectTuple12();
                break;
            case 13:
                projOperator = (SingleOutputStreamOperator) projectTuple13();
                break;
            case 14:
                projOperator = (SingleOutputStreamOperator) projectTuple14();
                break;
            case 15:
                projOperator = (SingleOutputStreamOperator) projectTuple15();
                break;
            case 16:
                projOperator = (SingleOutputStreamOperator) projectTuple16();
                break;
            case 17:
                projOperator = (SingleOutputStreamOperator) projectTuple17();
                break;
            case 18:
                projOperator = (SingleOutputStreamOperator) projectTuple18();
                break;
            case 19:
                projOperator = (SingleOutputStreamOperator) projectTuple19();
                break;
            case 20:
                projOperator = (SingleOutputStreamOperator) projectTuple20();
                break;
            case 21:
                projOperator = (SingleOutputStreamOperator) projectTuple21();
                break;
            case 22:
                projOperator = (SingleOutputStreamOperator) projectTuple22();
                break;
            case 23:
                projOperator = (SingleOutputStreamOperator) projectTuple23();
                break;
            case 24:
                projOperator = (SingleOutputStreamOperator) projectTuple24();
                break;
            case 25:
                projOperator = (SingleOutputStreamOperator) projectTuple25();
                break;
            default:
                throw new IllegalStateException("Excessive arity in tuple.");
        }

        return projOperator;
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public  SingleOutputStreamOperator> projectTuple1() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType = new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public  SingleOutputStreamOperator> projectTuple2() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType = new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public  SingleOutputStreamOperator> projectTuple3() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType = new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public  SingleOutputStreamOperator> projectTuple4() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator> projectTuple5() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator> projectTuple6() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator> projectTuple7() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator> projectTuple8() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator> projectTuple9() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator>
                    projectTuple10() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator>
                    projectTuple11() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator>
                    projectTuple12() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(
                        fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple13>
                    projectTuple13() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo>(
                        fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN, Tuple13>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple14>
                    projectTuple14() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo> tType =
                new TupleTypeInfo<
                        Tuple14>(
                        fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN, Tuple14>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple15<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14>>
                    projectTuple15() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo>
                tType =
                        new TupleTypeInfo<
                                Tuple15<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple15>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple16<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15>>
                    projectTuple16() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo>
                tType =
                        new TupleTypeInfo<
                                Tuple16<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple16<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple17<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16>>
                    projectTuple17() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple17<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16>>
                tType =
                        new TupleTypeInfo<
                                Tuple17<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple17<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple18<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16,
                                    T17>>
                    projectTuple18() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple18<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17>>
                tType =
                        new TupleTypeInfo<
                                Tuple18<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16,
                                        T17>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple18<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public 
            SingleOutputStreamOperator<
                            Tuple19<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16,
                                    T17,
                                    T18>>
                    projectTuple19() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple19<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18>>
                tType =
                        new TupleTypeInfo<
                                Tuple19<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16,
                                        T17,
                                        T18>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple19<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public <
                    T0,
                    T1,
                    T2,
                    T3,
                    T4,
                    T5,
                    T6,
                    T7,
                    T8,
                    T9,
                    T10,
                    T11,
                    T12,
                    T13,
                    T14,
                    T15,
                    T16,
                    T17,
                    T18,
                    T19>
            SingleOutputStreamOperator<
                            Tuple20<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16,
                                    T17,
                                    T18,
                                    T19>>
                    projectTuple20() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple20<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19>>
                tType =
                        new TupleTypeInfo<
                                Tuple20<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16,
                                        T17,
                                        T18,
                                        T19>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple20<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public <
                    T0,
                    T1,
                    T2,
                    T3,
                    T4,
                    T5,
                    T6,
                    T7,
                    T8,
                    T9,
                    T10,
                    T11,
                    T12,
                    T13,
                    T14,
                    T15,
                    T16,
                    T17,
                    T18,
                    T19,
                    T20>
            SingleOutputStreamOperator<
                            Tuple21<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16,
                                    T17,
                                    T18,
                                    T19,
                                    T20>>
                    projectTuple21() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple21<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19,
                                T20>>
                tType =
                        new TupleTypeInfo<
                                Tuple21<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16,
                                        T17,
                                        T18,
                                        T19,
                                        T20>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple21<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19,
                                T20>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public <
                    T0,
                    T1,
                    T2,
                    T3,
                    T4,
                    T5,
                    T6,
                    T7,
                    T8,
                    T9,
                    T10,
                    T11,
                    T12,
                    T13,
                    T14,
                    T15,
                    T16,
                    T17,
                    T18,
                    T19,
                    T20,
                    T21>
            SingleOutputStreamOperator<
                            Tuple22<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16,
                                    T17,
                                    T18,
                                    T19,
                                    T20,
                                    T21>>
                    projectTuple22() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple22<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19,
                                T20,
                                T21>>
                tType =
                        new TupleTypeInfo<
                                Tuple22<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16,
                                        T17,
                                        T18,
                                        T19,
                                        T20,
                                        T21>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple22<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19,
                                T20,
                                T21>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public <
                    T0,
                    T1,
                    T2,
                    T3,
                    T4,
                    T5,
                    T6,
                    T7,
                    T8,
                    T9,
                    T10,
                    T11,
                    T12,
                    T13,
                    T14,
                    T15,
                    T16,
                    T17,
                    T18,
                    T19,
                    T20,
                    T21,
                    T22>
            SingleOutputStreamOperator<
                            Tuple23<
                                    T0,
                                    T1,
                                    T2,
                                    T3,
                                    T4,
                                    T5,
                                    T6,
                                    T7,
                                    T8,
                                    T9,
                                    T10,
                                    T11,
                                    T12,
                                    T13,
                                    T14,
                                    T15,
                                    T16,
                                    T17,
                                    T18,
                                    T19,
                                    T20,
                                    T21,
                                    T22>>
                    projectTuple23() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        Tuple23<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19,
                                T20,
                                T21,
                                T22>>
                tType =
                        new TupleTypeInfo<
                                Tuple23<
                                        T0,
                                        T1,
                                        T2,
                                        T3,
                                        T4,
                                        T5,
                                        T6,
                                        T7,
                                        T8,
                                        T9,
                                        T10,
                                        T11,
                                        T12,
                                        T13,
                                        T14,
                                        T15,
                                        T16,
                                        T17,
                                        T18,
                                        T19,
                                        T20,
                                        T21,
                                        T22>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        Tuple23<
                                T0,
                                T1,
                                T2,
                                T3,
                                T4,
                                T5,
                                T6,
                                T7,
                                T8,
                                T9,
                                T10,
                                T11,
                                T12,
                                T13,
                                T14,
                                T15,
                                T16,
                                T17,
                                T18,
                                T19,
                                T20,
                                T21,
                                T22>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public <
                    T0,
                    T1,
                    T2,
                    T3,
                    T4,
                    T5,
                    T6,
                    T7,
                    T8,
                    T9,
                    T10,
                    T11,
                    T12,
                    T13,
                    T14,
                    T15,
                    T16,
                    T17,
                    T18,
                    T19,
                    T20,
                    T21,
                    T22,
                    T23>
            SingleOutputStreamOperator<
                            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>>
                    projectTuple24() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        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>>
                tType =
                        new TupleTypeInfo<
                                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>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        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>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    /**
     * Projects a {@link Tuple} {@link DataStream} to the previously selected fields.
     *
     * @return The projected DataStream.
     * @see Tuple
     * @see DataStream
     */
    public <
                    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>
            SingleOutputStreamOperator<
                            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>>
                    projectTuple25() {
        TypeInformation[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
        TupleTypeInfo<
                        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>>
                tType =
                        new TupleTypeInfo<
                                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>>(fTypes);

        return dataStream.transform(
                "Projection",
                tType,
                new StreamProject<
                        IN,
                        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>>(
                        fieldIndexes,
                        tType.createSerializer(
                                dataStream.getExecutionConfig().getSerializerConfig())));
    }

    public static TypeInformation[] extractFieldTypes(int[] fields, TypeInformation inType) {

        TupleTypeInfo inTupleType = (TupleTypeInfo) inType;
        TypeInformation[] fieldTypes = new TypeInformation[fields.length];

        for (int i = 0; i < fields.length; i++) {
            fieldTypes[i] = inTupleType.getTypeAt(fields[i]);
        }

        return fieldTypes;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy