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 03AE110DDF for ; Tue, 24 Sep 2013 17:25:19 +0000 (UTC) Received: (qmail 99084 invoked by uid 500); 24 Sep 2013 17:25:15 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 99068 invoked by uid 500); 24 Sep 2013 17:25:14 -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 99060 invoked by uid 99); 24 Sep 2013 17:25:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 17:25:13 +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: local policy) Received: from [207.46.163.209] (HELO na01-bl2-obe.outbound.protection.outlook.com) (207.46.163.209) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Sep 2013 17:25:07 +0000 Received: from BN1PR07CA027.namprd07.prod.outlook.com (10.141.56.42) by BN1PR07MB008.namprd07.prod.outlook.com (10.255.225.38) with Microsoft SMTP Server (TLS) id 15.0.775.9; Tue, 24 Sep 2013 17:24:26 +0000 Received: from BY2FFO11FD036.protection.gbl (2a01:111:f400:7c0c::175) by BN1PR07CA027.outlook.office365.com (2a01:111:e400:2a::42) with Microsoft SMTP Server (TLS) id 15.0.775.9 via Frontend Transport; Tue, 24 Sep 2013 17:24:26 +0000 Received: from xedge1.nrel.gov (192.174.58.251) by BY2FFO11FD036.mail.protection.outlook.com (10.1.14.221) with Microsoft SMTP Server (TLS) id 15.0.775.5 via Frontend Transport; Tue, 24 Sep 2013 17:24:26 +0000 Received: from XHUBA.nrel.gov (10.20.4.58) by xedge1.nrel.gov (192.174.58.251) with Microsoft SMTP Server (TLS) id 14.3.146.0; Tue, 24 Sep 2013 11:24:24 -0600 Received: from MAILBOX2.nrel.gov ([fe80::48b0:b121:8465:5e5]) by XHUBA.nrel.gov ([::1]) with mapi; Tue, 24 Sep 2013 11:24:25 -0600 From: "Hiller, Dean" To: "user@cassandra.apache.org" Date: Tue, 24 Sep 2013 11:24:19 -0600 Subject: =?iso-8859-2?Q?Re:_is_this_correct,_thrift_unportable_to_CQL3=A9.?= Thread-Topic: =?iso-8859-2?Q?is_this_correct,_thrift_unportable_to_CQL3=A9.?= Thread-Index: Ac65SunUUIv9Yj3WTIOa2V05pY9IqA== Message-ID: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.3.7.130812 acceptlanguage: en-US Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Forefront-Antispam-Report: CIP:192.174.58.251;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(24454002)(164054003)(43784003)(69234005)(377454003)(189002)(199002)(47446002)(4396001)(47736001)(19580395003)(49866001)(74502001)(83506001)(46102001)(83072001)(80976001)(50986001)(47976001)(54356001)(74366001)(76796001)(76786001)(77096001)(15975445006)(15395725003)(76176001)(56776001)(36756003)(56816003)(15202345003)(74662001)(31966008)(79102001)(81816001)(44976005)(81342001)(51856001)(53806001)(50466002)(6806004)(83322001)(19580405001)(63696002)(74706001)(80022001)(77982001)(59766001)(54316002)(76482001)(74876001)(81542001)(20776003)(65816001)(16796002)(53416003)(47776003)(69226001)(81686001)(24704002);DIR:OUT;SFP:;SCL:1;SRVR:BN1PR07MB008;H:xedge1.nrel.gov;CLIP:192.174.58.251;FPR:;RD:xedge1.nrel.gov;MX:1;A:1;LANG:en; X-Forefront-PRVS: 09796A1B83 X-OriginatorOrg: nrel.gov X-Virus-Checked: Checked by ClamAV on apache.org Java has Integer as opposed to int which is what I represent "golf scores" = with so to speak in my example. In this case, Integer can be null but of c= ourse maps to "empty" just fine. What about querying for all golf scores t= hat are "empty" then? Ie. This sounds like this solution would be perfect if we can get rid of th= e exception piece. Thanks much!!! Dean From: Sylvain Lebresne > Reply-To: "user@cassandra.apache.org" > Date: Tuesday, September 24, 2013 10:58 AM To: "user@cassandra.apache.org" > Subject: Re: is this correct, thrift unportable to CQL3=A9. On Tue, Sep 24, 2013 at 6:17 PM, Vikas Goyal > wrote: Ok. Great. It works for String and Decimal/Float but not for integer data t= ype.. i.e,, if I am passing "" to the composite key column which is either text o= r 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.. We're getting into details of the java driver at this point. For int, what = you can do is: boundStatement.setString("id", rowkey); boundStatement.setBytesUnsafe("columnname", ByteBuffer.wrap(new byte[0]))= ; boundStatement.setBytes("columnvalue", ByteBuffer.wrap(value)); In other words, the shorthand BoundStatement.bind() won't let you insert an= empty value for types that don't naturally have an empty value (like int; keep in mind that an em= pty value is not the same than null). But you can circumvent that using setBytesUnsafe if you really = want. Long story short, my advice would be to avoid using empty values for type t= hat don't naturally have one (anything else than text and blob really). If you do, that's going to b= e painful (but possible) to work with, at least with the java driver (but for good reasons, java just d= oesn't have a good to represent an empty int value (again, you can have a null Integer but that's= different)). -- Sylvain 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 nul= l..else 2 values.. if (key !=3D null) { PreparedStatement statement =3D session.prepare("INSERT INT= O keys.StringIndice (id, colname, colvalue) VALUES (?, ?, ?)"); BoundStatement boundStatement =3D new BoundStatement(statem= ent); session.execute(boundStatement.bind(StandardConverters.conv= ertFromBytes(String.class, rowKey), key, ByteBuffer.wrap(value))); } else { PreparedStatement statement =3D session.prepare("INSERT INT= O " + keys + "." + table + "(id, colvalue) VALUES (?, ?)"); BoundStatement boundStatement =3D new BoundStatement(statem= ent); session.execute(boundStatement.bind(StandardConverters.conv= ertFromBytes(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 *n= ot* the same thing, unless you consider an empty string is the same thing t= han a null string). As it happens, C* always an empty value as a valid valu= e for any type and that's true of both thrift and CQL3. What is true is tha= t CQL3 discourage the use of empty values for type for which it doesn't par= ticularly make sense (integers typically) by not having a particular easy t= o 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 wa= nt to use a prepared statement, CQL3 has conversion functions (http://cassa= ndra.apache.org/doc/cql3/CQL.html#blobFun) that allows to do it (for instan= ce, "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 s= core : 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). 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-col= umn-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?????). Is it possible to port this pattern to = CQL3? Thanks, Dean