Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-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 1EF9010B30 for ; Tue, 24 Sep 2013 16:17:37 +0000 (UTC) Received: (qmail 15809 invoked by uid 500); 24 Sep 2013 16:17:30 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 15787 invoked by uid 500); 24 Sep 2013 16:17:30 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 15742 invoked by uid 99); 24 Sep 2013 16:17:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 16:17:27 +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 (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [209.85.223.179] (HELO mail-ie0-f179.google.com) (209.85.223.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 16:17:23 +0000 Received: by mail-ie0-f179.google.com with SMTP id e14so9463862iej.10 for ; Tue, 24 Sep 2013 09:17:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=I3mAVRL8JdyQXHsn6VRjxOfqWfa0uNyYLXaIlE/XbRs=; b=Hr/MMVGYPUTK34hhxSetmU3ATqQagfU0sJgulf4DS2CPM+17AjGuSD4XjWyoU6+7pZ NRMNlkoKphrslKDloK9a3WajlBc5mPIjNxHDlMJtV9TPyCTgIZ/ANnI5BBNvku90zaas v1WlbDky6yDaeEAplRMTDnwKv0xQOcDb2YORqEqlTlvvxACBTbytcHUnO5Aqz6qbIS9M dUEBsuV7YYJr57jCuUGN3jlgFg6it/zfsQXVi+mlCLdn7tOcWYXkYlK+wydY3Drc9lwP ucBJPnzZacy1BSuMhyYRa0DWdGJH9GFNFhQ8Ah5yylXcD1Jp5x9hfD9cgkJYrHkZ1t5S Lcsg== X-Gm-Message-State: ALoCoQlzqdel8LO7fqXzaD2KEO4d3fgxKVmj4aTyW3egXlD3pCRVX+CMbBxnm9Mrc87PtJThj2KB MIME-Version: 1.0 X-Received: by 10.42.50.74 with SMTP id z10mr727065icf.113.1380039422033; Tue, 24 Sep 2013 09:17:02 -0700 (PDT) Received: by 10.64.240.15 with HTTP; Tue, 24 Sep 2013 09:17:01 -0700 (PDT) X-Originating-IP: [210.212.85.60] In-Reply-To: References: Date: Tue, 24 Sep 2013 21:47:01 +0530 Message-ID: Subject: =?UTF-8?Q?Re=3A_is_this_correct=2C_thrift_unportable_to_CQL3=C5=A0=2E?= From: Vikas Goyal To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=90e6ba8e4d8686d12a04e723779e X-Virus-Checked: Checked by ClamAV on apache.org --90e6ba8e4d8686d12a04e723779e Content-Type: text/plain; charset=ISO-8859-1 Ok. Great. It works for String and Decimal/Float but not for integer data type.. i.e,, if I am passing "" to the composite key column which is either text or float, it works.. session.execute(boundStatement.bind(rowkey, "", ByteBuffer.wrap(value))); But not working with bigint, int or varint..and getting following exception; Exception:Invalid type for value 1 of CQL type varint, expecting class java.math.BigInteger but class java.lang.String provided ..I am exploring more though.. Thanks a ton, Vikas Goyal On Tue, Sep 24, 2013 at 9:05 PM, Sylvain Lebresne wrote: > > However,we tried missing the value but it didn't work :( >> > > Right, because not providing a value is akin to having a null value (in > the CQL3 sense of the term, which is different from what Dean asked about) > and null values are not allowed for primary key columns. > You could however insert an *empty* value if you wanted, which in you case > is just inserting an empty string since colname is a string. Thrift doesn't > allow more or less in that case. > > -- > Sylvain > > > >> >> So our code is like below where we are using 3 values if colname is not >> null..else 2 values.. >> >> if (key != null) { >> PreparedStatement statement = session.prepare("INSERT >> INTO keys.StringIndice (id, colname, colvalue) VALUES (?, ?, ?)"); >> BoundStatement boundStatement = new >> BoundStatement(statement); >> >> session.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.class, >> rowKey), key, ByteBuffer.wrap(value))); >> } else { >> PreparedStatement statement = session.prepare("INSERT >> INTO " + keys + "." + table + "(id, colvalue) VALUES (?, ?)"); >> BoundStatement boundStatement = new >> BoundStatement(statement); >> >> session.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.class, >> rowKey), ByteBuffer.wrap(value))); >> } >> >> And, I did that and getting this exception: >> >> Exception:Missing PRIMARY KEY part colname since colvalue is set >> >> And just FYI. Our Column Family definition is below: >> >> CREATE TABLE keys.StringIndice (id text, >> colname text, >> colvalue blob, >> PRIMARY KEY (id,colname, colvalue)) WITH COMPACT STORAGE) >> >> Thanks again, >> Vikas Goyal >> >> >> >> On Tue, Sep 24, 2013 at 7:02 PM, Sylvain Lebresne wrote: >> >>> Short answer: not, this is not correct. >>> >>> Longer answer: what you call "null" is actually an empty value (which is >>> *not* the same thing, unless you consider an empty string is the same thing >>> than a null string). As it happens, C* always an empty value as a valid >>> value for any type and that's true of both thrift and CQL3. What is true is >>> that CQL3 discourage the use of empty values for type for which it doesn't >>> particularly make sense (integers typically) by not having a particular >>> easy to use syntax to input them. But that's supported nonetheless. If you >>> use a prepared statement for instance (where you send values already >>> serialized), nothing will prevent you from sending an empty value. Even if >>> you don't want to use a prepared statement, CQL3 has conversion functions ( >>> http://cassandra.apache.org/doc/cql3/CQL.html#blobFun) that allows to >>> do it (for instance, "blobAsInt(0x)" will be an empty int value). >>> >>> -- >>> Sylvain >>> >>> >>> >>> On Tue, Sep 24, 2013 at 2:36 PM, Hiller, Dean wrote: >>> >>>> Many applications in thrift use the wide row with composite column name >>>> and as an example, let's say golf score for instance and we end up with >>>> golf score : pk like so >>>> >>>> null : pk56 >>>> null : pk45 >>>> 89 : pk90 >>>> 89: pk87 >>>> 90: pk101 >>>> 95: pk17 >>>> >>>> Notice that there are some who do not have a golf score(zero would not >>>> quite make sense and would be interpreted as a golf score). I am hearing >>>> from this post if they are correct that this is not portable to CQL3??? Is >>>> this true? >>>> http://stackoverflow.com/questions/18963248/how-can-i-have-null-column-value-for-a-composite-key-column-in-cql3 >>>> >>>> (This sounds like a major deficit to me as the wide row now can only be >>>> used where actual values exist?????). Is it possible to port this pattern >>>> to CQL3? >>>> >>>> Thanks, >>>> Dean >>>> >>>> >>>> >>> >> > --90e6ba8e4d8686d12a04e723779e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Ok. Great. It works for String and Decimal/Float but not f= or integer data type..
i.e,, if I am passing "" to the compos= ite key column which is either text or float, it works..

session.execute(boundStatement.bind= (rowkey, "", ByteBuffer.wrap(value)));

But not working with bigint, int or varint..and getting following exceptio= n;

Exception:Invalid type for value 1 of CQL type vari= nt, expecting class java.math.BigInteger but class java.lang.String provide= d

..I am exploring more though..

Thanks a ton,
=
Vikas Goyal


On Tue, Sep 24, 2013 at 9:05 PM, S= ylvain Lebresne <sylvain@datastax.com> wrote:

However,we tried missing the value but it didn&#= 39;t work :(

Right, becau= se not providing a value is akin to having a null value (in the CQL3 sense = of the term, which is different from what Dean asked about) and null values= are not allowed for primary key columns.
You could however insert an *empty* value if you wanted, which in you = case is just inserting an empty string since colname is a string. Thrift do= esn't allow more or less in that case.

--
Sylvain

=A0

So our code is like below where we are using 3 val= ues if colname is not null..else 2 values..

=A0 =A0 =A0 =A0 =A0 = =A0 if (key !=3D null) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PreparedStatement statement =3D session.p= repare("INSERT INTO keys.StringIndice (id, colname, colvalue) VALUES (= ?, ?, ?)");
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Bou= ndStatement boundStatement =3D new BoundStatement(statement);
<= div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sess= ion.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.= class, rowKey), key, ByteBuffer.wrap(value)));
=A0 =A0 =A0 =A0 =A0 =A0 } else {
=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 PreparedStatement statement =3D session.prepare("INSERT INTO &= quot; + keys + "." + table + "(id, colvalue) VALUES (?, ?)&q= uot;);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Bou= ndStatement boundStatement =3D new BoundStatement(statement);
<= div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sess= ion.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.= class, rowKey), ByteBuffer.wrap(value)));
=A0 =A0 =A0 =A0 =A0 }
<= div>
And, I did that and getting this exception:
Exception:Missing PRIMARY KEY part col= name since colvalue is set

And just FYI. Our Column Family definition is below:

CREATE TABLE keys.StringIndice (id text,
colname text,
colvalue blob,
PRIMARY KEY (id,= colname, colvalue)) WITH COMPACT STORAGE)

Thanks again,
Vikas Goyal



On Tue, Sep 24, 2013 at 7:02 PM, Sylvain Lebresne <sylvain@datastax.com= > wrote:
Short answer: not, this is not correct.
Longer answer: what you call "null" is actually an= empty value (which is *not* the same thing, unless you consider an empty s= tring is the same thing than a null string). As it happens, C* always an em= pty value as a valid value for any type and that's true of both thrift = and CQL3. What is true is that CQL3 discourage the use of empty values for = type for which it doesn't particularly make sense (integers typically) = by not having a particular easy to use syntax to input them. But that's= supported nonetheless. If you use a prepared statement for instance (where= you send values already serialized), nothing will prevent you from sending= an empty value. Even if you don't want to use a prepared statement, CQ= L3 has conversion functions (http://cassandra.apache.org/doc/cql3/= CQL.html#blobFun) that allows to do it (for instance, "blobAsInt(0= x)" will be an empty int value).

--
Sylvain



On Tue, Sep 24, 2013 = at 2:36 PM, Hiller, Dean <Dean.Hiller@nrel.gov> wrote:
Many applications in thrift use the wide row with composit= e column name and as an example, let's say golf score for instance and = we end up with golf score : pk like so

null : pk56
null : pk45
89 : pk90
89: pk87
90: pk101
95: pk17

Notice that there are some who do not have a golf score(zero would not quit= e make sense and would be interpreted as a golf score). =A0I am hearing fro= m this post if they are correct that this is not portable to CQL3??? =A0Is = this true? =A0http://stackoverflow.com/questions/18963248/how-can-i-have-null-colum= n-value-for-a-composite-key-column-in-cql3

(This sounds like a major deficit to me as the wide row now can only be use= d where actual values exist?????). =A0Is it possible to port this pattern t= o CQL3?

Thanks,
Dean






--90e6ba8e4d8686d12a04e723779e--