flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Márton Balassi (JIRA) <j...@apache.org>
Subject [jira] [Created] (FLINK-2812) KeySelectorUtil.getSelectorForKeys and TypeExtractor.getKeySelectorTypes are incompatible
Date Fri, 02 Oct 2015 15:41:26 GMT
Márton Balassi created FLINK-2812:

             Summary: KeySelectorUtil.getSelectorForKeys and TypeExtractor.getKeySelectorTypes
are incompatible
                 Key: FLINK-2812
                 URL: https://issues.apache.org/jira/browse/FLINK-2812
             Project: Flink
          Issue Type: Bug
          Components: Type Serialization System
    Affects Versions: 0.10
            Reporter: Márton Balassi
            Priority: Minor

The following code snippet fails, because {{KeySelectorUtil.getSelectorForKeys}} returns the
base {{Tuple}} type.

TypeInformation<Tuple2<Integer, Integer>> typeInfo = TypeExtractor
.getForObject(Tuple2.of(0, 0));

ExecutionConfig config = new ExecutionConfig();

KeySelector<Tuple2<Integer, Integer>, ?> keySelector = KeySelectorUtil.getSelectorForKeys(
new Keys.ExpressionKeys<>(new int[]{0}, typeInfo), typeInfo, config);

// fails with InvalidTypesException
TypeExtractor.getKeySelectorTypes(keySelector, typeInfo); 

However if I manually define the key selector as follows the snippet works fine due to the
key type being an integer.

KeySelector<Tuple2<Integer, Integer>, Integer> keySelector =

new KeySelector<Tuple2<Integer, Integer>, Integer>() {
	public Integer getKey(Tuple2<Integer, Integer> value) throws Exception {
		return value.f0;

The error message looks like this:
org.apache.flink.api.common.functions.InvalidTypesException: Usage of class Tuple as a type
is not allowed. Use a concrete subclass (e.g. Tuple1, Tuple2, etc.) instead.
	at org.apache.flink.api.java.typeutils.TypeExtractor.createTypeInfoWithTypeHierarchy(TypeExtractor.java:401)
	at org.apache.flink.api.java.typeutils.TypeExtractor.privateCreateTypeInfo(TypeExtractor.java:379)
	at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:279)
	at org.apache.flink.api.java.typeutils.TypeExtractor.getKeySelectorTypes(TypeExtractor.java:229)
	at org.apache.flink.api.java.typeutils.TypeExtractor.getKeySelectorTypes(TypeExtractor.java:223)

This message was sent by Atlassian JIRA

View raw message