Return-Path: X-Original-To: apmail-cassandra-client-dev-archive@minotaur.apache.org Delivered-To: apmail-cassandra-client-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 21C7110584 for ; Sat, 1 Mar 2014 00:13:44 +0000 (UTC) Received: (qmail 2051 invoked by uid 500); 1 Mar 2014 00:13:43 -0000 Delivered-To: apmail-cassandra-client-dev-archive@cassandra.apache.org Received: (qmail 1909 invoked by uid 500); 1 Mar 2014 00:13:43 -0000 Mailing-List: contact client-dev-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: client-dev@cassandra.apache.org Delivered-To: mailing list client-dev@cassandra.apache.org Received: (qmail 1901 invoked by uid 99); 1 Mar 2014 00:13:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Mar 2014 00:13:42 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gcdcc-client-dev@m.gmane.org designates 80.91.229.3 as permitted sender) Received: from [80.91.229.3] (HELO plane.gmane.org) (80.91.229.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Mar 2014 00:13:36 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WJXYG-0008Ns-FE for client-dev@cassandra.apache.org; Sat, 01 Mar 2014 01:13:12 +0100 Received: from c-67-160-201-218.hsd1.ca.comcast.net ([67.160.201.218]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 Mar 2014 01:13:12 +0100 Received: from mikhail.stepura by c-67-160-201-218.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 Mar 2014 01:13:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: client-dev@cassandra.apache.org From: Mikhail Stepura Subject: Re: How should clients handle the user defined types in 2.1? Date: Fri, 28 Feb 2014 16:12:58 -0800 Lines: 90 Message-ID: References: <530CE407.7060406@outlook.com> <530CEBF5.6090104@outlook.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-67-160-201-218.hsd1.ca.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Thunderbird/27.0 In-Reply-To: X-Virus-Checked: Checked by ClamAV on apache.org Hi Theo, Take a look at https://github.com/datastax/python-driver/blob/master/cassandra/cqltypes.py#L111 On 2/25/14, 23:09, Theo Hultberg wrote: > thanks mikhail. > > it bothers me a bit that there is the possibility of arbitrarily deeply > nested types (it's great for usability, but a headache for me as a driver > implementer). it feels like just throwing a couple of regexes at this is > the wrong solution, the string has too much structure and hierarchy for > that and I think that not doing it with a proper parser will cause trouble > in the future. and then trying to use the parsed type structure to properly > encode something that the user wants to store will be very complex. kind of > like having to implement a whole orm. it's going to be a challenge. > > I see that you took the parser route in the python driver so I can at least > get some inspiration from there. what do you do when the user passes an > object in a custom type field and that object doesn't look like the type at > all? > > T# > > > On Tue, Feb 25, 2014 at 8:16 PM, Mikhail Stepura < > mikhail.stepura@outlook.com> wrote: > >> I just realized that your driver returns fields' names in the type itself >> (which unfortunately is not the case with python driver) so you don't need >> step #3. >> >> -M >> >> >> >> On 2/25/14, 10:42, Mikhail Stepura wrote: >> >>> The driver shall parse that. >>> I'm not sure if there is a doc for that, but here is what I did for CQLSH >>> >>> 1. UserType is a CompositeType, where 1s subtype is a KS name, and 2nd >>> is hex-encoded name of the type >>> 2. Remainder of subtypes are types of Usertype's columns. So you can >>> easily decode *values* for fields >>> 3. Information about field *names* is stored in system.schema_usertypes >>> table >>> 4. The driver has to combine pieces 1-3 and create a new class/type for >>> a user. It was easy in Python, I guess it should be easy in Ruby as well >>> >>> -M >>> >>> >>> On 2/22/14, 12:29, Theo Hultberg wrote: >>> >>>> Hi, >>>> >>>> Is there any documentation on how CQL clients should handle the new user >>>> defined types coming in 2.1? There's nothing in the protocol >>>> specification >>>> on how to handle custom types as far as I can understand. >>>> >>>> For example, I tried creating the "address" type from the description of >>>> CASSANDRA-5590, and this is how its metadata looks (the metadata for a >>>> query contains a column with a custom type and this is the description of >>>> it): >>>> >>>> org.apache.cassandra.db.marshal.UserType(user_defined_ >>>> types,61646472657373,737472656574:org.apache. >>>> cassandra.db.marshal.UTF8Type,63697479:org.apache.cassandra. >>>> db.marshal.UTF8Type,7a69705f636f6465:org.apache.cassandra.db.marshal. >>>> Int32Type,70686f6e6573:org.apache.cassandra.db.marshal. >>>> SetType(org.apache.cassandra.db.marshal.UTF8Type)) >>>> >>>> >>>> Is the client supposed to parse that description, and in that case how? I >>>> could probably figure it out but it would be great if someone could point >>>> me to the right docs. >>>> >>>> yours, >>>> Theo (author of cql-rb, the Ruby driver) >>>> >>>> >>> >>> >>> >> >> >