Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9CBB11313 for ; Fri, 25 Jul 2014 23:32:39 +0000 (UTC) Received: (qmail 77566 invoked by uid 500); 25 Jul 2014 23:32:39 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 77492 invoked by uid 500); 25 Jul 2014 23:32:39 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 77477 invoked by uid 99); 25 Jul 2014 23:32:39 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2014 23:32:39 +0000 Date: Fri, 25 Jul 2014 23:32:39 +0000 (UTC) From: "Keegan Witt (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AVRO-1468) implement interface-based code-generation 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/AVRO-1468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14075130#comment-14075130 ] Keegan Witt commented on AVRO-1468: ----------------------------------- Would the ability to do polymorphic interface references like this be out of the scope of this Jira? {code} { "type": "record", "name": "Cat", "namespace":"the.universe", "fields": [ {"name":"name", "type":"string"}, {"name":"collarSize", "type":"int"}, {"name":"aloofness", "type":"int"}, ] } { "type": "record", "name": "Dog", "namespace":"the.universe", "fields": [ {"name":"name", "type":"string"}, {"name":"collarSize", "type":"int"}, {"name":"friendliness", "type":"int"}, ] } {code} {code} public interface Pet { public String getName(); public void setName(String name); } public class Cat implements Pet { // ... } public class Dog implements Pet { // ... } public class ExampleUsage { public static void main(String[] args) { List pets = PetUtil.listPets(); Map petNames = new HashMap<>(); for (Pet pet : pets) { petNames.put(pet.getname(), pet.getCollarSize()); } } } {code} > implement interface-based code-generation > ----------------------------------------- > > Key: AVRO-1468 > URL: https://issues.apache.org/jira/browse/AVRO-1468 > Project: Avro > Issue Type: New Feature > Reporter: Doug Cutting > > The current specific compiler generates a concrete class per record. Instead, we might generate an interface per record that might be implemented in different ways. Implementations might include: > - A wrapper for a generic record. This would permit the schema that is compiled against to differ from that of the runtime instance. A field that was added since code-generation could be retained as records are filtered or sorted and re-written. > - A concrete record. This would be similar to the existing specific. > - A wrapped POJO. The generated class could wrap a POJO using reflection. Aliases could map between the schema used at compilation and that of the POJO, so field and class names need not match exactly. This would permit one to evolve from a POJO-based Avro application to using generated code without breaking existing code. > This approach was first described in http://s.apache.org/AvroFlex -- This message was sent by Atlassian JIRA (v6.2#6252)