Search in sources :

Example 1 with KeyExtractingMapper

use of org.apache.flink.api.java.operators.translation.KeyExtractingMapper in project flink by apache.

the class KeyFunctions method appendKeyExtractor.

@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;
}
Also used : KeyExtractingMapper(org.apache.flink.api.java.operators.translation.KeyExtractingMapper) TwoKeyExtractingMapper(org.apache.flink.api.java.operators.translation.TwoKeyExtractingMapper) MapOperatorBase(org.apache.flink.api.common.operators.base.MapOperatorBase) UnaryOperatorInformation(org.apache.flink.api.common.operators.UnaryOperatorInformation) Tuple2(org.apache.flink.api.java.tuple.Tuple2) MapFunction(org.apache.flink.api.common.functions.MapFunction)

Aggregations

MapFunction (org.apache.flink.api.common.functions.MapFunction)1 UnaryOperatorInformation (org.apache.flink.api.common.operators.UnaryOperatorInformation)1 MapOperatorBase (org.apache.flink.api.common.operators.base.MapOperatorBase)1 KeyExtractingMapper (org.apache.flink.api.java.operators.translation.KeyExtractingMapper)1 TwoKeyExtractingMapper (org.apache.flink.api.java.operators.translation.TwoKeyExtractingMapper)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1