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 00E50200D04 for ; Mon, 11 Sep 2017 12:39:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F3ABB1609C4; Mon, 11 Sep 2017 10:39:05 +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 45B4A1609C3 for ; Mon, 11 Sep 2017 12:39:05 +0200 (CEST) Received: (qmail 915 invoked by uid 500); 11 Sep 2017 10:39:04 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list user@flink.apache.org Received: (qmail 905 invoked by uid 99); 11 Sep 2017 10:39:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Sep 2017 10:39:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 9850C1A55A2 for ; Mon, 11 Sep 2017 10:39:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.284 X-Spam-Level: ** X-Spam-Status: No, score=2.284 tagged_above=-999 required=6.31 tests=[SPF_HELO_PASS=-0.001, SPF_SOFTFAIL=0.972, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 5aEi2fx8U0NE for ; Mon, 11 Sep 2017 10:38:58 +0000 (UTC) Received: from n4.nabble.com (n4.nabble.com [162.253.133.72]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id DF0335FBE2 for ; Mon, 11 Sep 2017 10:38:57 +0000 (UTC) Received: from mben.nabble.com (localhost [127.0.0.1]) by n4.nabble.com (Postfix) with ESMTP id 77DD41431A1B0 for ; Mon, 11 Sep 2017 03:38:55 -0700 (MST) Date: Mon, 11 Sep 2017 03:38:55 -0700 (MST) From: yunfan123 To: user@flink.apache.org Message-ID: <1505126335488-0.post@n4.nabble.com> Subject: Keyed function type erasure problem. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit archived-at: Mon, 11 Sep 2017 10:39:06 -0000 Just small change from PojoExample: PojoExample.java public class PojoExample { private SelectorContainer selectorContainer; // KeySelector class like this can't be used in flink !!! public static class SelectorContainer implements KeySelector { public KeySelector keySelector; public SelectorContainer(KeySelector keySelector) { this.keySelector = keySelector; } @Override public K getKey(Word value) throws Exception { return keySelector.getKey(value); } } public void run() { dataStream.keyed(selectorContainer); } } This will cause: Type of TypeVariable 'K' in 'class org.apache.flink.streaming.examples.wordcount.PojoExample$SelectorContainer' 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). org.apache.flink.api.java.typeutils.TypeExtractor.createTypeInfoWithTypeHierarchy(TypeExtractor.java:915) org.apache.flink.api.java.typeutils.TypeExtractor.privateCreateTypeInfo(TypeExtractor.java:836) org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:622) org.apache.flink.api.java.typeutils.TypeExtractor.getKeySelectorTypes(TypeExtractor.java:443) org.apache.flink.api.java.typeutils.TypeExtractor.getKeySelectorTypes(TypeExtractor.java:436) org.apache.flink.streaming.api.datastream.KeyedStream.(KeyedStream.java:108) org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:263) org.apache.flink.streaming.examples.wordcount.PojoExample.execute(PojoExample.java:86) org.apache.flink.streaming.examples.wordcount.PojoExample.main(PojoExample.java:108) It sames can't use a class contains the KeySelector ? -- Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/