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 2C86C78CA for ; Wed, 17 Aug 2011 07:01:03 +0000 (UTC) Received: (qmail 96695 invoked by uid 500); 17 Aug 2011 07:01:00 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 96492 invoked by uid 500); 17 Aug 2011 07:00:54 -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 96465 invoked by uid 99); 17 Aug 2011 07:00:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 07:00:51 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of yulinyen@gmail.com designates 209.85.215.170 as permitted sender) Received: from [209.85.215.170] (HELO mail-ey0-f170.google.com) (209.85.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 07:00:43 +0000 Received: by eyd10 with SMTP id 10so460328eyd.1 for ; Wed, 17 Aug 2011 00:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ky3ZYocmSmxVnPXL6TzqWhApcc/lFc6GDOieQ488ahk=; b=Koj+7w58oSGOzyn9cEZDE9aiQ3yH/BGkWrTiBYtMSsQe7Ehc5GHuvEzsqJegiMD4zi cHp4Ln/lPmiLGInImRqAH8kXJxCzX/ymsjIHZCy5BhpjqzqToFtMtCCuAnt9NIfN/9iQ j1WpQSeAbGZqhGnDGdtt+dRAq0EausF0iCCww= MIME-Version: 1.0 Received: by 10.14.146.66 with SMTP id q42mr175200eej.73.1313564423142; Wed, 17 Aug 2011 00:00:23 -0700 (PDT) Received: by 10.14.47.141 with HTTP; Wed, 17 Aug 2011 00:00:23 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Aug 2011 15:00:23 +0800 Message-ID: Subject: Re: HOW TO select a column or all columns that start with X From: Boris Yen To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=bcaec51ba66bd4bb7304aaae0c1c X-Virus-Checked: Checked by ClamAV on apache.org --bcaec51ba66bd4bb7304aaae0c1c Content-Type: text/plain; charset=ISO-8859-1 Each compositeType consistes of a few components. Use ("bob", 1982) as an example, it contains two components, I assume it is (utf8, integer). So when you want to use a slice query, you need the start and end columns by add components to them. That is what start.addCompo.... and end.addCompo... means. For more information please refer to https://issues.apache.org/jira/browse/CASSANDRA-2231 For you question, I think replace "abc" with "bob" should do the trick. On Wed, Aug 17, 2011 at 4:56 AM, Alvin UW wrote: > Hello, > > can anyone give an explanation of > start.addComponent("abc", StringSerializer.get()) ; > end.addComponent("abc", StringSerializer.get(), "UTF8Type", > AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL) ; > > > Suppose my composite column names are like ("bob", 1982), ("bob", 1976). > There are more than one "bob" in my table. > now I only know I want to query "bob", but don't know the birth year, how > can I get all the column values of "Bob"? with the help of composite type. > > > > > 2011/8/4 Boris Yen > >> Assume you have a column family named "testCF" with comparator * >> CompositeType*(AsciiType, IntegerType(reversed=true), IntegerType); and a >> few columns have been inserted into record key "a". >> >> ____________________________________ >> Composite start = new Composite() ; >> Composite end = new Composite() ; >> start.addComponent("abc", StringSerializer.get()) ; >> end.addComponent("abc", StringSerializer.get(), "UTF8Type", >> AbstractComposite.ComponentEquality.GREATER_THAN_EQUAL) ; >> >> SliceQuery query = >> HFactory.createSliceQuery(keyspace, StringSerializer.get(), >> ByteBufferSerializer.get(), ByteBufferSerializer.get()); >> query.setKey("a"); >> query.setColumnFamily("testCF"); >> query.setRange(start.serialize(), end.serialize(), false, 100); >> >> List> columns = >> query.execute().get().getColumns(); >> >> >> On Thu, Aug 4, 2011 at 3:19 PM, CASSANDRA learner < >> cassandralearner@gmail.com> wrote: >> >>> Can you please gimme an example on this using hector client >>> >>> >>> On Thu, Aug 4, 2011 at 7:18 AM, Boris Yen wrote: >>> >>>> It seems to me that your column name consists of two components. If you >>>> have the luxury to upgrade your cassandra to 0.8.1+, I think you can think >>>> about using the composite type/column. Conceptually, it might suit your use >>>> case better. >>>> >>>> >>>> On Wed, Aug 3, 2011 at 5:28 AM, Eldad Yamin wrote: >>>> >>>>> Hello, >>>>> I wonder if I can select a column or all columns that start with X. >>>>> E.g I have columns ABC_1, ABC_2, ZZZ_1 and I want to select all columns >>>>> that start with ABC_ - is that possible? >>>>> >>>>> >>>>> >>>>> Thanks! >>>>> >>>> >>>> >>> >> > --bcaec51ba66bd4bb7304aaae0c1c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Each compositeType consistes of a few components. Use=A0("bob", 1982) as an example,= it contains two components, I assume it is (utf8, integer). So when you wa= nt to use a slice query, you need the start and end columns by add componen= ts to them. That is what start.addCompo.... and end.addCompo... means. For = more information please refer to=A0https://issues.apache.org/jira/browse/CASSA= NDRA-2231

For you question, I think rep= lace "abc" with "bob" should do the trick.

On Wed, Aug 17, 2011 at 4:56 AM, Alvin UW <alvinuw@gmail.com> wrote:
Hello,

can anyone give an explanation of
start.addComponent("abc", StringSerializer.get()= ) ;
end.addComponent("abc", S= tringSerializer.get(), "UTF8Type", AbstractComposite.ComponentEqu= ality.GREATER_THAN_EQUAL) ;


Suppose my composite = column names are like ("bob", 1982),=A0 ("bob", 1976). There ar= e more than one "bob" in my table.
now I only know I want to query "bob", but don't know the bir= th year, how can I get all the column values of "Bob"? with the h= elp of composite type.




2011/8/4 Boris Yen <yulinyen@gmail.com>
Assume you have a column family named "testCF" with comparator=A0= CompositeType(AsciiType, IntegerType(reversed=3Dtrue),= =A0IntegerType); and= a few columns have been inserted into record key "a".

_______________________= _____________
Composite start =3D new Composite() ;
Composite end =3D new Composite() ;=
start.addComponent("abc", StringSerializer.get()= ) ;
end.addComponent("abc", S= tringSerializer.get(), "UTF8Type", AbstractComposite.ComponentEqu= ality.GREATER_THAN_EQUAL) ;

SliceQuery<String, ByteBuffer, ByteBuffer> query =3D HFactory.cr= eateSliceQuery(keyspace, StringSerializer.get(), ByteBufferSerializer.get()= , ByteBufferSerializer.get());
query.setKey("a");
query.setColumnFamily("tes= tCF");
query.setRange(start.serialize(), end.serialize(), fa= lse, 100);

List<HColumn<= ByteBuffer, ByteBuffer>> columns =3D query.execute().get().getColumns= ();

=

On Thu, Aug 4, 2011 at 3:19 = PM, CASSANDRA learner <cassandralearner@gmail.com> = wrote:
Can you please gimme an= example on this using hector client


On Thu, Aug 4, 2011 at 7:18 AM, Boris Yen <yulinyen@gmail.com> wrote:
It seems to me that you= r column name consists of two components. If you have the luxury to upgrade= your cassandra to 0.8.1+, I think you can think about using the composite = type/column. Conceptually, it might suit your use case better.


On Wed, Aug 3, 2011 at 5:28 AM, Eldad Yamin = <eldad87@gmail.com> wrote:
Hello,
I wonder if I can select a column or all column= s that start with X.
E.g I have columns ABC_1, ABC_2, ZZZ_1 and I= want to select all columns that start with ABC_ - is that possible?



Thanks!





--bcaec51ba66bd4bb7304aaae0c1c--