cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alvin UW <alvi...@gmail.com>
Subject Re: HOW TO select a column or all columns that start with X
Date Tue, 16 Aug 2011 20:56:34 GMT
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 <yulinyen@gmail.com>

> 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<String, ByteBuffer, ByteBuffer> 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<HColumn<ByteBuffer, ByteBuffer>> 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 <yulinyen@gmail.com> 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 <eldad87@gmail.com> 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!
>>>>
>>>
>>>
>>
>

Mime
View raw message