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 B7F3717E4D for ; Tue, 3 Feb 2015 22:16:10 +0000 (UTC) Received: (qmail 62448 invoked by uid 500); 3 Feb 2015 22:15:37 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 62390 invoked by uid 500); 3 Feb 2015 22:15:37 -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 62376 invoked by uid 99); 3 Feb 2015 22:15:37 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2015 22:15:37 +0000 Date: Tue, 3 Feb 2015 22:15:37 +0000 (UTC) From: "Sachin Goyal (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AVRO-1554) Avro should have support for common constructs like UUID and Date 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-1554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sachin Goyal updated AVRO-1554: ------------------------------- Attachment: AVRO-1554_3.patch Removed the DateEncoding from the patch as its already implemented in another patch. This patch contains only UUID patch. > Avro should have support for common constructs like UUID and Date > ----------------------------------------------------------------- > > Key: AVRO-1554 > URL: https://issues.apache.org/jira/browse/AVRO-1554 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.7.6 > Reporter: Sachin Goyal > Attachments: AVRO-1554.patch, AVRO-1554_2.patch, AVRO-1554_3.patch, CustomEncodingUnionBug.zip > > > Consider the following code: > {code} > public class AvroExample > { > public static void main (String [] args) throws Exception > { > ReflectData rdata = ReflectData.AllowNull.get(); > Schema schema = rdata.getSchema(Temp.class); > > ReflectDatumWriter datumWriter = > new ReflectDatumWriter (Temp.class, rdata); > DataFileWriter fileWriter = > new DataFileWriter (datumWriter); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > fileWriter.create(schema, baos); > fileWriter.append(new Temp()); > fileWriter.close(); > byte[] bytes = baos.toByteArray(); > GenericDatumReader datumReader = > new GenericDatumReader (); > SeekableByteArrayInput avroInputStream = > new SeekableByteArrayInput(bytes); > DataFileReader fileReader = > new DataFileReader(avroInputStream, datumReader); > schema = fileReader.getSchema(); > GenericRecord record = null; > record = fileReader.next(record); > System.out.println (record); > System.out.println (record.get("id")); > } > } > class Temp > { > UUID id = UUID.randomUUID(); > Date date = new Date(); > BigInteger bi = BigInteger.TEN; > } > {code} > Output from this code is: > {code:javascript} > {"id": {}, "date": {}, "bi": "10"} > {code} > UUID and Date type fields are very common in Java and can be found a lot in third-party code as well (where it may be difficult to put annotations). > So Avro should include a default serialization/deserialization support for such fields. -- This message was sent by Atlassian JIRA (v6.3.4#6332)