Return-Path: X-Original-To: apmail-crunch-user-archive@www.apache.org Delivered-To: apmail-crunch-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 749F9F8C6 for ; Wed, 27 Mar 2013 04:02:53 +0000 (UTC) Received: (qmail 50499 invoked by uid 500); 27 Mar 2013 04:02:53 -0000 Delivered-To: apmail-crunch-user-archive@crunch.apache.org Received: (qmail 50335 invoked by uid 500); 27 Mar 2013 04:02:48 -0000 Mailing-List: contact user-help@crunch.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@crunch.apache.org Delivered-To: mailing list user@crunch.apache.org Received: (qmail 50308 invoked by uid 99); 27 Mar 2013 04:02:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Mar 2013 04:02:48 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jwills@cloudera.com designates 209.85.215.50 as permitted sender) Received: from [209.85.215.50] (HELO mail-la0-f50.google.com) (209.85.215.50) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Mar 2013 04:02:42 +0000 Received: by mail-la0-f50.google.com with SMTP id ec20so14954732lab.9 for ; Tue, 26 Mar 2013 21:02:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type:x-gm-message-state; bh=Gorto8CC6VFSJIYLRy+oCQKqXMjPebF/LJKyGJnjYJs=; b=bU4bQqosELsAYgaFYUl/9RjvpPGhNK1X1/G1m8gM9lTYgDcrLGs8msM1Td7wTY47S1 UeGNpk5wMfhR/YevHbEWtP9ldnx8cFOLEYmi/AKMTogIMF+aT+0VuLCgwCOR2wyOCpdn DasmtIl4q5XCWPtl/hJ6P3vZRYx2LGkOyO42Ft8xiTGrXbBXHKBcdbct6ZDXisI0HC5m uiv2TyVby5Jiifcy6XBqIeMjOLMP5AykzTpB3tL/mxxROqmei6P93AJpaXWjCWblEqeo wUAH2EnWSedMO04MggfvXNS1SE/TJqvO9U8A4ysLU2FYYOjqfvSRlt0928z0L5O05lJC SPuA== X-Received: by 10.112.98.227 with SMTP id el3mr9429980lbb.131.1364356942086; Tue, 26 Mar 2013 21:02:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.82.7 with HTTP; Tue, 26 Mar 2013 21:02:02 -0700 (PDT) In-Reply-To: References: From: Josh Wills Date: Tue, 26 Mar 2013 21:02:02 -0700 Message-ID: Subject: Re: Mixing Writables and Avros PTypes To: user@crunch.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkFgT+3TeKCt4DotnwY4w+XrQXj/kUf1ktJgZ70mW2T/13rThGLl0o07QYt+Sj5mXTJcjQt X-Virus-Checked: Checked by ClamAV on apache.org PTypeFamily has an as(...) method right now that knows how to convert primitive and collection types from one PTypeFamily to another. I was thinking of extending it to support derived types and the more common kind of generic types-- so like Avros.generics and Writables.writables, which should be able to be converted from one type family to another with a little bit of magic. On Mon, Mar 25, 2013 at 7:15 PM, Micah Whitacre wrote: > Is this what you are thinking when you mentioned the PType.as(...) method? > http://pastebin.com/cjwss9Hs > (note i realize not really code complete but just as an example) > > Its similar to what you suggested for the UUID support enhancement. > > or you were really thinking the PType interface would get an "as(...)" > method? that took in the converted PTypeFamily (e.g. > PType.as(PTypeFamily destinationFamily)). > > I could see how making the code on pastebin more generic to at least > support Avros.toWritables(Class) would be useful. > > All of these seem like good enhancements to me. > > On Tue, Mar 19, 2013 at 7:43 PM, Josh Wills wrote: >> Hey Micah, >> >> Agreed that this isn't an ideal state of affairs. I think the trick for >> PTables should be to have the key type determine the value type, and have >> derived types that would either convert the PType automatically (via the >> PType.as(...) or some such thing), or convert the Avro type to a >> BytesWritable (for Writable keys) or the Writable type to use the >> Avros.writables functionality. I don't think it would be super-complicated >> to try it out and see if there are any edge cases here that I'm missing. >> >> J >> >> >> On Tue, Mar 19, 2013 at 4:31 PM, Micah Whitacre >> wrote: >>> >>> Out of curiosity why can we not mix PTypes between Writables and >>> Avros? The situation I'm encountering are cases where someone wants >>> to create a PTable. UUID is hidden behind a >>> UUIDWritable (+ MapFn implementations) and exposed as a PType using >>> Writables.derive(...). SomeAvro's PType is exposed using >>> Avros.records(SomeAvro.class). >>> >>> If consumers want to create the PTable they can either >>> do Avros.tableOf(UUID.PTYPE, SomeAvros.PTYPE) or >>> Writables.tableOf(UUID.PType, SomeAvros.PTYPE) but that will throw an >>> IllegalArgumentException because in both cases something doesn't >>> extend the correct type. >>> >>> Part of the confusion is that the method signatures for both are just >>> PType and don't document or restrict the allowed types until runtime. >>> Is there a way that we might be missing to make both flavors of PTypes >>> play nicely and be able to create tables, pairs, etc easily? >>> >>> I was kind of hoping most data providers could hide whether they are >>> Avro, Writable, or whatever by just exposing PTypes for consumer to >>> use but now it seems consumer might need to implement twice as many >>> PTypes and wrappers for a mixed pipeline to work well. >>> >>> Thanks, >>> Micah >> >> >> >> >> -- >> Director of Data Science >> Cloudera >> Twitter: @josh_wills -- Director of Data Science Cloudera Twitter: @josh_wills