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 C8AC810035 for ; Thu, 31 Oct 2013 15:28:21 +0000 (UTC) Received: (qmail 79973 invoked by uid 500); 31 Oct 2013 15:24:53 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 79864 invoked by uid 500); 31 Oct 2013 15:24:40 -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 79524 invoked by uid 99); 31 Oct 2013 15:24:28 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Oct 2013 15:24:28 +0000 Received: from localhost (HELO mail-pd0-f172.google.com) (127.0.0.1) (smtp-auth username cutting, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Oct 2013 15:24:28 +0000 Received: by mail-pd0-f172.google.com with SMTP id w10so2520027pde.17 for ; Thu, 31 Oct 2013 08:24:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hdcKR4f93OyH4l43Jx2QWjGAm6f9B4bX97xMrpf0gS0=; b=mu5X+7eLRTy/xX1UyZu11XXBGZuVjmdPnZs7n/grPnF8SqLQ4Q7YXnhPrDNMv3Ii2w hKcXIIw/K3Ru+Ex0/VOBsvqplapOH2nMe60HXO62x2cEEI8kdT8e/V/aQnqbT2H86jpF G0qdIE2+2TlmCx3hgGaQfY3TQJToxRMV/2FvJxu+ptPMbDy+oz45ICGkngaP2F6E7sor JN0wueixq/UOehAzA5hMewXqfU2pt7stzh6bVfdVKGpMyZ75NhPZSlavzuUXtTvOfcwk fJ2r9UukZGcwnRAaPs8idw0yg5zSEHmKdmCuTtta1nRFvCG8JIgYFz7xwe0TRu+O1gXN 6qOA== MIME-Version: 1.0 X-Received: by 10.68.197.36 with SMTP id ir4mr2503069pbc.96.1383233067856; Thu, 31 Oct 2013 08:24:27 -0700 (PDT) Received: by 10.70.65.138 with HTTP; Thu, 31 Oct 2013 08:24:27 -0700 (PDT) In-Reply-To: References: Date: Thu, 31 Oct 2013 11:24:27 -0400 Message-ID: Subject: Re: GenericDatumReader and datum reuse From: Doug Cutting To: "user@avro.apache.org" Content-Type: text/plain; charset=UTF-8 A simple approach to reuse is to pass the value previously returned from read(): GenericRecord record = null; while (...) { record = reader.read(record, decoder); ... code that does not retain a pointer to record ... } Doug On Wed, Oct 30, 2013 at 3:07 PM, kulkarni.swarnim@gmail.com wrote: > Hello, > > While going thorough the API for GenericDatumReader, I came across this > read[1] method and it wasn't immediately clear to me as to what the "reuse" > of the datum really means. > > So for instance if I have an evolving schema, should this datum be created > from the readerSchema or the writerSchema. So something like: > > record = new GenericData.Record(readerSchema); // created with readerSchema > > GenericDatumReader gdr = new > GenericDatumReader(writerSchema, readerSchema); > > record = gdr.read(record, binaryDecoder); > > Or is it better to simply leave it off as null? > > record = gdr.read(null, binaryDecoder); > > > Thanks, > > > [1] > http://avro.apache.org/docs/1.7.4/api/java/org/apache/avro/generic/GenericDatumReader.html#read(D, > org.apache.avro.io.Decoder)