Return-Path: X-Original-To: apmail-flink-issues-archive@minotaur.apache.org Delivered-To: apmail-flink-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6C3AE18828 for ; Fri, 26 Feb 2016 15:40:21 +0000 (UTC) Received: (qmail 71784 invoked by uid 500); 26 Feb 2016 15:40:18 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 71735 invoked by uid 500); 26 Feb 2016 15:40:18 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 71722 invoked by uid 99); 26 Feb 2016 15:40:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Feb 2016 15:40:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 189502C1F58 for ; Fri, 26 Feb 2016 15:40:18 +0000 (UTC) Date: Fri, 26 Feb 2016 15:40:18 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-3519) Subclasses of Tuples don't work if the declared type of a DataSet is not the descendant MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-3519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15169202#comment-15169202 ] ASF GitHub Bot commented on FLINK-3519: --------------------------------------- Github user ggevay commented on the pull request: https://github.com/apache/flink/pull/1724#issuecomment-189326695 I have also added that a subclass of TupleN can only be a POJO. (see TypeExtractor.java:1686) > Subclasses of Tuples don't work if the declared type of a DataSet is not the descendant > --------------------------------------------------------------------------------------- > > Key: FLINK-3519 > URL: https://issues.apache.org/jira/browse/FLINK-3519 > Project: Flink > Issue Type: Bug > Components: Type Serialization System > Affects Versions: 1.0.0 > Reporter: Gabor Gevay > Priority: Minor > > If I have a subclass of TupleN, then objects of this type will turn into TupleNs when I try to use them in a DataSet. > For example, if I have a class like this: > {code} > public static class Foo extends Tuple1 { > public short a; > public Foo() {} > public Foo(int f0, int a) { > this.f0 = f0; > this.a = (short)a; > } > @Override > public String toString() { > return "(" + f0 + ", " + a + ")"; > } > } > {code} > And then I do this: > {code} > env.fromElements(0,0,0).map(new MapFunction>() { > @Override > public Tuple1 map(Integer value) throws Exception { > return new Foo(5, 6); > } > }).print(); > {code} > Then I don't have Foos in the output, but only Tuples: > {code} > (5) > (5) > (5) > {code} > The problem is caused by the TupleSerializer not caring about subclasses at all. I guess the reason for this is performance: we don't want to deal with writing and reading subclass tags when we have Tuples. > I see three options for solving this: > 1. Add subclass tags to the TupleSerializer: This is not really an option, because we don't want to loose performance. > 2. Document this behavior in the javadoc of the Tuple classes. > 3. Make the Tuple types final: this would be the clean solution, but it is API breaking, and the first victim would be Gelly: the Vertex and Edge types extend from tuples. (Note that the issue doesn't appear there, because the DataSets there always have the type of the descendant class.) > When deciding between 2. and 3., an important point to note is that if you have your class extend from a Tuple type instead of just adding the f0, f1, ... fields manually in the hopes of getting the performance boost associated with Tuples, then you are out of luck: the PojoSerializer will kick in anyway when the declared types of your DataSets are the descendant type. > If someone knows about a good reason to extend from a Tuple class, then please comment. > For 2., this is a suggested wording for the javadoc of the Tuple classes: > Warning: Please don't subclass Tuple classes, but if you do, then be sure to always declare the element type of your DataSets to your descendant type. (That is, if you have a "class A extends Tuple2", then don't use instances of A in a DataSet, but use DataSet.) -- This message was sent by Atlassian JIRA (v6.3.4#6332)