flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gyula Fora (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-3566) Input type validation often fails on custom TypeInfo implementations
Date Wed, 02 Mar 2016 15:20:18 GMT

    [ https://issues.apache.org/jira/browse/FLINK-3566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15175770#comment-15175770
] 

Gyula Fora commented on FLINK-3566:
-----------------------------------

Another example with KeySelectors and interfaces:

interface Event {
		String getKey();
	}

	public static class MyEvent implements Event {
		@Override
		public String getKey() {
			return "";
		}

	}

	public static void main(String[] args) {
		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		DataStream<MyEvent> events = env.fromElements(new MyEvent());
		applyKeySelector(events);
	}

	private static <E extends Event> void applyKeySelector(DataStream<E> events)
{
		events.keyBy(e -> e.getKey());
	}

This gives a following exception: Input mismatch: Generic object type 'package.TypeTest.MyEvent'
expected but was 'package.TypeTest.Event'.

> Input type validation often fails on custom TypeInfo implementations
> --------------------------------------------------------------------
>
>                 Key: FLINK-3566
>                 URL: https://issues.apache.org/jira/browse/FLINK-3566
>             Project: Flink
>          Issue Type: Bug
>          Components: Type Serialization System
>            Reporter: Gyula Fora
>
> Input type validation often fails when used with custom type infos. One example of this
behaviour can be reproduced by creating a custom type info with our own field type:
> StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
> env.generateSequence(1, 10).map(new MapFunction<Long, Tuple1<Optional<Long>>>()
{
> 			@Override
> 			public Tuple1<Optional<Long>> map(Long value) throws Exception {
> 				return Tuple1.of(Optional.of(value));
> 			}
> 		}).returns(new TupleTypeInfo<>(new OptionTypeInfo<Long>(BasicTypeInfo.LONG_TYPE_INFO)))
> 				.keyBy(new KeySelector<Tuple1<Optional<Long>>, Optional<Long>>()
{
> 					@Override
> 					public Optional<Long> getKey(Tuple1<Optional<Long>> value) throws
Exception {
> 						return value.f0;
> 					}
> 				});
> This will fail on Input type validation at the KeySelector (or any other function for
example a mapper) with the following exception:
> Input mismatch: Basic type expected.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message