Re: HOW TO select a column or all columns that start with X

2011-08-17 Thread Alvin UW
Thanks. it helps.

2011/8/17 Boris Yen 

> 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 <
>>> cassandralear...@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!
>>
>
>

>>>
>>
>


Re: HOW TO select a column or all columns that start with X

2011-08-17 Thread Boris Yen
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 <
>> cassandralear...@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!
>


>>>
>>
>


Re: HOW TO select a column or all columns that start with X

2011-08-16 Thread Alvin UW
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 <
> cassandralear...@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!

>>>
>>>
>>
>


Re: HOW TO select a column or all columns that start with X

2011-08-04 Thread 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 <
cassandralear...@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!
>>>
>>
>>
>


Re: HOW TO select a column or all columns that start with X

2011-08-04 Thread Benoit Perroud
https://github.com/edanuff/CassandraIndexedCollections

2011/8/4 CASSANDRA learner :
> 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!
>
>


Re: HOW TO select a column or all columns that start with X

2011-08-04 Thread CASSANDRA learner
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!
>>
>
>


Re: HOW TO select a column or all columns that start with X

2011-08-03 Thread Boris Yen
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!
>


Re: HOW TO select a column or all columns that start with X

2011-08-03 Thread Ed Anuff
I believe you can set start to be "ABC_" and finish to be "ABC_\" (for
UTF8) to get everything that contains exactly ABC_ and set finish to
"ABC_\" to get everything that starts with ABC_.  You probably want to
do a simple string comparison test to verify.


On Tue, Aug 2, 2011 at 6:50 PM, Tyler Hobbs  wrote:

> A minor correction:
>
> To get all columns starting with "ABC_", you would set column_start="ABC_"
> and column_finish="ABC`" (the '`' character comes after '_'), and ignore the
> last column in your results if it happened to be "ABC`".
>
> column_finish, or the "slice end" in other clients, is inclusive.  You
> could of course use "ABC_~" as column_finish and avoid the check if you know
> that you don't have column names like "ABC_~FOO" that you want to include.
>
> On Tue, Aug 2, 2011 at 7:17 PM, aaron morton wrote:
>
>> Yup, thats a pretty common pattern. How exactly depends on the client you
>> are using.
>>
>> Say you were using pycassam, you would do a get()
>> http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get
>>
>> with column_start="ABC_" , count to whatever, and column_finish not
>> provided.
>>
>> You can also provide a finish and use the highest encoded character, e.g.
>> ascii 126 is ~ so if you used column_finish = "ABC_~" you would get
>> everything that starts with ABC_
>>
>> Cheers
>>
>>  -
>> Aaron Morton
>> Freelance Cassandra Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>>
>> On 3 Aug 2011, at 09:28, 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!
>>
>>
>>
>
>
> --
> Tyler Hobbs
> Software Engineer, DataStax 
> Maintainer of the pycassa  Cassandra
> Python client library
>
>


Re: HOW TO select a column or all columns that start with X

2011-08-03 Thread Eldad Yamin
Thanks!

On Wed, Aug 3, 2011 at 3:03 PM, aaron morton wrote:

> and AsciiType
>
>
> -
> Aaron Morton
> Freelance Cassandra Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 3 Aug 2011, at 16:35, eldad87 wrote:
>
> Thank you!
> Will this situation work only for UTF8Type comparator?
>
>
> On Wed, Aug 3, 2011 at 4:50 AM, Tyler Hobbs  wrote:
>
>> A minor correction:
>>
>> To get all columns starting with "ABC_", you would set column_start="ABC_"
>> and column_finish="ABC`" (the '`' character comes after '_'), and ignore the
>> last column in your results if it happened to be "ABC`".
>>
>> column_finish, or the "slice end" in other clients, is inclusive.  You
>> could of course use "ABC_~" as column_finish and avoid the check if you know
>> that you don't have column names like "ABC_~FOO" that you want to include.
>>
>>
>> On Tue, Aug 2, 2011 at 7:17 PM, aaron morton wrote:
>>
>>> Yup, thats a pretty common pattern. How exactly depends on the client you
>>> are using.
>>>
>>> Say you were using pycassam, you would do a get()
>>> http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get
>>>
>>> with column_start="ABC_" , count to whatever, and column_finish not
>>> provided.
>>>
>>> You can also provide a finish and use the highest encoded character, e.g.
>>> ascii 126 is ~ so if you used column_finish = "ABC_~" you would get
>>> everything that starts with ABC_
>>>
>>> Cheers
>>>
>>>  -
>>> Aaron Morton
>>> Freelance Cassandra Developer
>>> @aaronmorton
>>> http://www.thelastpickle.com
>>>
>>> On 3 Aug 2011, at 09:28, 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!
>>>
>>>
>>>
>>
>>
>> --
>> Tyler Hobbs
>> Software Engineer, DataStax 
>> Maintainer of the pycassa  Cassandra
>> Python client library
>>
>>
>
>


Re: HOW TO select a column or all columns that start with X

2011-08-03 Thread aaron morton
and AsciiType


-
Aaron Morton
Freelance Cassandra Developer
@aaronmorton
http://www.thelastpickle.com

On 3 Aug 2011, at 16:35, eldad87 wrote:

> Thank you!
> Will this situation work only for UTF8Type comparator?
> 
> 
> On Wed, Aug 3, 2011 at 4:50 AM, Tyler Hobbs  wrote:
> A minor correction:
> 
> To get all columns starting with "ABC_", you would set column_start="ABC_" 
> and column_finish="ABC`" (the '`' character comes after '_'), and ignore the 
> last column in your results if it happened to be "ABC`".
> 
> column_finish, or the "slice end" in other clients, is inclusive.  You could 
> of course use "ABC_~" as column_finish and avoid the check if you know that 
> you don't have column names like "ABC_~FOO" that you want to include.
> 
> 
> On Tue, Aug 2, 2011 at 7:17 PM, aaron morton  wrote:
> Yup, thats a pretty common pattern. How exactly depends on the client you are 
> using. 
> 
> Say you were using pycassam, you would do a get() 
> http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get
> 
> with column_start="ABC_" , count to whatever, and column_finish not provided. 
> 
> You can also provide a finish and use the highest encoded character, e.g. 
> ascii 126 is ~ so if you used column_finish = "ABC_~" you would get 
> everything that starts with ABC_
> 
> Cheers
> 
> -
> Aaron Morton
> Freelance Cassandra Developer
> @aaronmorton
> http://www.thelastpickle.com
> 
> On 3 Aug 2011, at 09:28, 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!
> 
> 
> 
> 
> -- 
> Tyler Hobbs
> Software Engineer, DataStax
> Maintainer of the pycassa Cassandra Python client library
> 
> 



Re: HOW TO select a column or all columns that start with X

2011-08-02 Thread eldad87
Thank you!
Will this situation work only for UTF8Type comparator?


On Wed, Aug 3, 2011 at 4:50 AM, Tyler Hobbs  wrote:

> A minor correction:
>
> To get all columns starting with "ABC_", you would set column_start="ABC_"
> and column_finish="ABC`" (the '`' character comes after '_'), and ignore the
> last column in your results if it happened to be "ABC`".
>
> column_finish, or the "slice end" in other clients, is inclusive.  You
> could of course use "ABC_~" as column_finish and avoid the check if you know
> that you don't have column names like "ABC_~FOO" that you want to include.
>
>
> On Tue, Aug 2, 2011 at 7:17 PM, aaron morton wrote:
>
>> Yup, thats a pretty common pattern. How exactly depends on the client you
>> are using.
>>
>> Say you were using pycassam, you would do a get()
>> http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get
>>
>> with column_start="ABC_" , count to whatever, and column_finish not
>> provided.
>>
>> You can also provide a finish and use the highest encoded character, e.g.
>> ascii 126 is ~ so if you used column_finish = "ABC_~" you would get
>> everything that starts with ABC_
>>
>> Cheers
>>
>>  -
>> Aaron Morton
>> Freelance Cassandra Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>>
>> On 3 Aug 2011, at 09:28, 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!
>>
>>
>>
>
>
> --
> Tyler Hobbs
> Software Engineer, DataStax 
> Maintainer of the pycassa  Cassandra
> Python client library
>
>


Re: HOW TO select a column or all columns that start with X

2011-08-02 Thread Tyler Hobbs
A minor correction:

To get all columns starting with "ABC_", you would set column_start="ABC_"
and column_finish="ABC`" (the '`' character comes after '_'), and ignore the
last column in your results if it happened to be "ABC`".

column_finish, or the "slice end" in other clients, is inclusive.  You could
of course use "ABC_~" as column_finish and avoid the check if you know that
you don't have column names like "ABC_~FOO" that you want to include.

On Tue, Aug 2, 2011 at 7:17 PM, aaron morton wrote:

> Yup, thats a pretty common pattern. How exactly depends on the client you
> are using.
>
> Say you were using pycassam, you would do a get()
> http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get
>
> with column_start="ABC_" , count to whatever, and column_finish not
> provided.
>
> You can also provide a finish and use the highest encoded character, e.g.
> ascii 126 is ~ so if you used column_finish = "ABC_~" you would get
> everything that starts with ABC_
>
> Cheers
>
> -
> Aaron Morton
> Freelance Cassandra Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 3 Aug 2011, at 09:28, 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!
>
>
>


-- 
Tyler Hobbs
Software Engineer, DataStax 
Maintainer of the pycassa  Cassandra
Python client library


Re: HOW TO select a column or all columns that start with X

2011-08-02 Thread aaron morton
Yup, thats a pretty common pattern. How exactly depends on the client you are 
using. 

Say you were using pycassam, you would do a get() 
http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get

with column_start="ABC_" , count to whatever, and column_finish not provided. 

You can also provide a finish and use the highest encoded character, e.g. ascii 
126 is ~ so if you used column_finish = "ABC_~" you would get everything that 
starts with ABC_

Cheers

-
Aaron Morton
Freelance Cassandra Developer
@aaronmorton
http://www.thelastpickle.com

On 3 Aug 2011, at 09:28, 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!