Return-Path: X-Original-To: apmail-avro-user-archive@www.apache.org Delivered-To: apmail-avro-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D86490C0 for ; Wed, 30 May 2012 06:05:20 +0000 (UTC) Received: (qmail 79333 invoked by uid 500); 30 May 2012 06:05:19 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 78928 invoked by uid 500); 30 May 2012 06:05:14 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 78896 invoked by uid 99); 30 May 2012 06:05:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2012 06:05:13 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of taton@wibidata.com designates 209.85.160.169 as permitted sender) Received: from [209.85.160.169] (HELO mail-gh0-f169.google.com) (209.85.160.169) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2012 06:05:06 +0000 Received: by ghrr18 with SMTP id r18so2951869ghr.0 for ; Tue, 29 May 2012 23:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wibidata.com; s=google; h=mime-version:x-originating-ip:date:message-id:subject:from:to :content-type; bh=5S6Csv9FRjy8EyuULN2g/jqpTqem/dqyn9nTlB47nRY=; b=lH388DQGE1MK9axrFu570T+0o0K9JqQ/rrzNjf1aO9PKUpTWfuGNgx5HDcVf+/6F3g E7FRiNsBygExNRlzakqO0skR0K9jteaC3ntnIAB2ccaZAwDALkcUb74Rq70NwXJQhHX1 pTKcwMnlnUZXwqTo27hcjs6lpdAmGLUQpFOdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=5S6Csv9FRjy8EyuULN2g/jqpTqem/dqyn9nTlB47nRY=; b=eAQHz3x1Q83nMiQMKAy8j5cRfVa+SZoNig4D73K/5RHDP5AHTYZFrOqsSS0tpe9t2/ DPugFOEIiycgPb58QItVuV4XvherNL+ItkTFvdAOkxnFMlMda5fUoEyhQNlS9Mt74Z1H +2ttOWzvoX9OiNgN5R8nT/qVaGbfVshygzudY0g2chYUg3shN3E1AKJxqQWjCiqfOk2U nHv4qDzZHsuy38P6bC5TfBZy7Pd89uv69rsMSYVkqIf6UvS5YVc54pNt+Hcq9hnflmFO 3zIvyh0CoA0dJWNvpbMRjMhijvGYFo5pFEeko2wkmxfqKGMEyZZ2/cK1ggRKQtdQfS9M z9UQ== MIME-Version: 1.0 Received: by 10.50.188.201 with SMTP id gc9mr837635igc.44.1338357884791; Tue, 29 May 2012 23:04:44 -0700 (PDT) Received: by 10.50.106.138 with HTTP; Tue, 29 May 2012 23:04:44 -0700 (PDT) X-Originating-IP: [50.0.93.114] Date: Tue, 29 May 2012 23:04:44 -0700 Message-ID: Subject: Scala API From: Christophe Taton To: user@avro.apache.org Content-Type: multipart/alternative; boundary=14dae93412374e2b6f04c13aba2b X-Gm-Message-State: ALoCoQkhGPMe1zqbMhlM9Ik7nju/f2O7PYvjXOl+6CqX9MRQU0r6/CE9ZPPyYXOoNGotdoFgtPJt --14dae93412374e2b6f04c13aba2b Content-Type: text/plain; charset=UTF-8 Hi people, Is there interest in a custom Scala API for Avro records and protocols? I am currently working on an schema compiler for Scala, but before I go deeper, I would really like to have external feedback. I would especially like to hear from anyone who has opinions on how to map Avro types onto Scala types. Here are a few hints on what I've been trying so far: - Records are compiled into two forms: mutable and immutable. - To avoid collisions with Java generated classes, scala classes are generated in a .scala sub-package. - Avro arrays are translated to Seq/List when immutable and Buffer/ArrayBuffer when mutable. - Avro maps are translated to immutable or mutable Map/HashMap. - Bytes/Fixed are translated to Seq[Byte] when immutable and Buffer[Byte] when mutable. - Avro unions are currently translated into Any, but I plan to: - translate union{null, X} into Scala Option[X] - compile union {T1, T2, T3} into a custom case classes to have proper type checking and pattern matching. - Scala records provide a method encode(encoder) to serialize as binary into a byte stream (appears ~30% faster than SpecificDatumWriter). - Scala mutable records provide a method decode(decoder) to deserialize a byte stream (appears ~25% faster than SpecificDatumReader). - Scala records implement the SpecificRecord Java interface (with some overhead), so one may still use the SpecificDatumReader/Writer when the custom encoder/decoder methods cannot be used. - Mutable records can be converted to immutable (ie. can act as builders). Thanks, Christophe --14dae93412374e2b6f04c13aba2b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi people,

Is there interest in a custom Scala API for A= vro records and protocols?
I am currently working on an schema co= mpiler for Scala, but before I go deeper, I would really like to have exter= nal feedback.
I would especially like to hear from anyone who has opinions on how to= map Avro types onto Scala types.
Here are a few hints on what I&= #39;ve been trying so far:
  • Records are compiled into two = forms: mutable and immutable.
  • To avoid collisions with Java generated classes, scala classes are= generated in a .scala sub-package.
  • Avro arrays are translated to Seq/List when immutable and Buffer/ArrayB= uffer when mutable.
  • Avro maps are translated to immutable or mutabl= e Map/HashMap.
  • Bytes/Fixed are translated to Seq[Byte] when immutab= le and Buffer[Byte] when mutable.
  • Avro unions are currently translated into Any, but I plan to:
  • <= ul>
  • translate union{null, X} into Scala Option[X]
  • compile union = {T1, T2, T3} into a custom case classes to have proper type checking and pa= ttern matching.
  • Scala records provide a method encode(encoder) to serialize as bin= ary into a byte stream (appears ~30% faster than SpecificDatumWriter).
  • Scala mutable records provide a method decode(decoder) to deserialize a= byte stream (appears ~25% faster than SpecificDatumReader).
  • Scala = records implement the SpecificRecord Java interface (with some overhead), s= o one may still use the SpecificDatumReader/Writer when the custom encoder/= decoder methods cannot be used.
  • Mutable records can be converted to immutable (ie. can act as builders)= .
  • Thanks,
    Christophe

    --14dae93412374e2b6f04c13aba2b--