Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6F602200B38 for ; Fri, 8 Jul 2016 12:27:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6DF6E160A5A; Fri, 8 Jul 2016 10:27:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9103D160A58 for ; Fri, 8 Jul 2016 12:27:44 +0200 (CEST) Received: (qmail 11982 invoked by uid 500); 8 Jul 2016 10:27:43 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@flink.apache.org Delivered-To: mailing list user@flink.apache.org Received: (qmail 11972 invoked by uid 99); 8 Jul 2016 10:27:43 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jul 2016 10:27:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3E056C6684 for ; Fri, 8 Jul 2016 10:27:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id LG4ReRApgYHX for ; Fri, 8 Jul 2016 10:27:42 +0000 (UTC) Received: from mail-vk0-f67.google.com (mail-vk0-f67.google.com [209.85.213.67]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 21E335F46F for ; Fri, 8 Jul 2016 10:27:42 +0000 (UTC) Received: by mail-vk0-f67.google.com with SMTP id r135so3581303vkf.3 for ; Fri, 08 Jul 2016 03:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=WqFjcyxQFSf3y+AWSOkVZ42/lWAaQgmTpFKkIH6zRPs=; b=ZVtDbzFVZOt/SyUpZznubefcFtPZN2PlcHp0ftcBklVlr6hIdqrybdWmTlax9ZVK6Z TIda3EK28YEqa7EbTacr/CuIBOf1CL6E4M8Vx9QT7NLv0N8f6ZJbm1DkewtxQS+xDK5N fotffvECC6F8qSrpN2aITLp4gLa1aWYYWO7WxusFhj+yEEyLlgLs4WZrr7Fakz3k6VR1 GmEbl0/Hwmrkysv6x6d3v+g0m9lZqaxl6Q8DTgpeT41IP6y2FmiDfV/2JcPyXEnwAMDp vjFWEOrvLh+5tJcXoF8c8/F/Xiis3YZGmG2VvuPYTVnKxNeB5+0GzM6YHzEmnMkQZE6W ytLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=WqFjcyxQFSf3y+AWSOkVZ42/lWAaQgmTpFKkIH6zRPs=; b=Sy6i1AHy8nE1H7RlkgptoN17jfqqcJ2pX2l4o9PcWjVM2CgjPsTe/I6jMebOarh0Cn gtJUQNAipe8DHzNKvvYYSWMKexmUYP1IJDGUL487bCWdgEL4dNzv2sz/YuWfJXm0Cjnp MYghgXeWOzEbxOxzno3pPwpEK/mDshFHWH9/UAs7puOHwEH/0TGC85KdTtze6XVNeKJV xBoNHGy6ah0sfQRtJ9OmqOP9gKOrcx19zsoSlgWHlxkibOuiCbcthZO7lKEtoQkDW0bw /5Nspgo4RFUpZAGGPeYyPl57UV4/QeQTcJM2qsaIzCvdx2ypZV1pmrhH/N9C40ZxJWsu Vjew== X-Gm-Message-State: ALyK8tLDc7wTU2pRVqbvh/r/Hd8evsT4bsZF0CaDqsKuUWq0j+krSV6TvlEaZdP0yljBAzMC1FDuFmRfC45cww== X-Received: by 10.31.171.74 with SMTP id u71mr2392436vke.119.1467973660624; Fri, 08 Jul 2016 03:27:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.75.211 with HTTP; Fri, 8 Jul 2016 03:27:40 -0700 (PDT) From: Yukun Guo Date: Fri, 8 Jul 2016 18:27:40 +0800 Message-ID: Subject: Extract type information from SortedMap To: user@flink.apache.org Content-Type: multipart/alternative; boundary=001a1143922c94cbf305371d40bf archived-at: Fri, 08 Jul 2016 10:27:45 -0000 --001a1143922c94cbf305371d40bf Content-Type: text/plain; charset=UTF-8 Hi, When I run the code implementing a generic FlatMapFunction, Flink complained about InvalidTypesException: public class GenericFlatMapper implements FlatMapFunction, Tuple2> { @Override public void flatMap(SortedMap m, Collector> out) throws Exception { for (Map.Entry entry : m.entrySet()) { out.collect(Tuple2.of(entry.getKey(), entry.getValue())); } } } *Exception in thread "main" org.apache.flink.api.common.functions.InvalidTypesException: The return type of function could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result of the transformation call, or by letting your function implement the 'ResultTypeQueryable' interface.* *...* *Caused by: org.apache.flink.api.common.functions.InvalidTypesException: Type of TypeVariable 'T' in 'class GenericFlatMapper' 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).* This puzzles me as Flink should be able to infer the type from arguments. I know returns(...) or other workarounds to give type hint, but they are kind of verbose. Any suggestions? --001a1143922c94cbf305371d40bf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,
When I run the code implementing a generic Fla= tMapFunction, Flink complained about InvalidTypesException:

publ=
ic class GenericFlatMapper<T> implements Flat=
MapFunction<SortedMap<T, Long>, Tuple2<T, Long>> {    @Override
= public void flatMap(= SortedMap<T, Long> m, Collector<<= span style=3D"color:rgb(166,83,0)">Tuple2
<T, Long>= > out) throws Exception
{
for
(Map.Entry<T, Long> entry : m.entrySet()) {
<= /span>out.collect(Tuple2.of(entry.getKey(), entry.getValue())); }
}
}
Exception in thread "main" org.apache.flink.api.comm= on.functions.InvalidTypesException: The return type of function could not b= e determined automatically, due to type erasure. You can give type informat= ion hints by using the returns(...) method on the result of the transformat= ion call, or by letting your function implement the 'ResultTypeQueryabl= e' interface.
...
Caused by: = org.apache.flink.api.common.functions.InvalidTypesException: Type of TypeVa= riable 'T' in 'class GenericFlatMapper' could not be determ= ined. This is most likely a type erasure problem. The type extraction curre= ntly supports types with generic variables only in cases where all variable= s in the return type can be deduced from the input type(s).

This puzzles me as Flink should be able to infer the type from arguments= . I know returns(...) or other workarounds to give type hint, but they are kind of verbose. Any= suggestions?

--001a1143922c94cbf305371d40bf--