incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samal <samalgo...@gmail.com>
Subject Re: How to store a list of values?
Date Mon, 26 Mar 2012 16:07:45 GMT
On Mon, Mar 26, 2012 at 9:20 PM, Ben McCann <ben@benmccann.com> wrote:

> Thanks for the reply Samal.
>


>  I did not realize that you could store a column with null value.
>
values can be null or any value like
[default@node] set hus['test']['wowq']='\{deeeee\'.de\;\}\+\^anything';
Value inserted.
Elapsed time: 4 msec(s).
[default@node]
[default@node]
[default@node] get hus['test'];
=> (column=wow, value={deeeee.de;}, timestamp=1332777722503000)
=> (column=wowq, value={deeeee'.de;}+^anything, timestamp=1332777767425000)
Returned 2 results.
Elapsed time: 65 msec(s).
[default@node]


>  Do you know if this solution would work with composite columns?  It seems
> super columns are being phased out in favor of composites, but I do not
> understand composites very well yet.
>
personally i have phased out Super Column year back, about CC didn't much
dig into it but know key and column name can be composite.

'ben'+'task1'={
   utf8+ascii:''
}


>  I'm trying to figure out if there's any way to accomplish what you've
> suggested using Astyanax <https://github.com/Netflix/astyanax>.
>
  this is the simplest approach, should work with every client available
since it is independent CF, here two call is required.


> Thanks for the help,
> Ben
>
>
> On Mon, Mar 26, 2012 at 8:46 AM, samal <samalgorai@gmail.com> wrote:
>
>> plus it is fully compatible with CQL.
>> SELECT * FROM UserSkill WHERE KEY='ben';
>>
>>
>> On Mon, Mar 26, 2012 at 9:13 PM, samal <samalgorai@gmail.com> wrote:
>>
>>> I would take simple approach. create one other CF "UserSkill"  with row
>>> key same as profile_cf key,
>>> In user_skill cf will add skill as column name and value null. Columns
>>> can be added or removed.
>>>
>>> UserProfile={
>>>   '*ben*'={
>>>    blah :blah
>>>    blah :blah
>>>    blah :blah
>>>  }
>>> }
>>>
>>> UserSkill={
>>>   '*ben*'={
>>>     'java':''
>>>     'cassandra':''
>>>   .
>>>   .
>>>   .
>>>   'linux':''
>>>   'skill':'infinity'
>>>
>>>  }
>>>
>>> }
>>>
>>>
>>> On Mon, Mar 26, 2012 at 12:34 PM, Ben McCann <ben@benmccann.com> wrote:
>>>
>>>> I have a profile column family and want to store a list of skills in
>>>> each profile.  In BigTable I could store a Protocol Buffer<http://code.google.com/apis/protocolbuffers/docs/overview.html>with
a repeated field, but I'm not sure how this is typically accomplished
>>>> in Cassandra.  One option would be to store a serialized Thrift<http://thrift.apache.org/>or
protobuf, but I'd prefer not to do this as I believe Cassandra doesn't
>>>> have knowledge of these formats, and so the data in the datastore would not
>>>> not human readable in CQL queries from the command line.  The other
>>>> solution I thought of would be to use a super column and put a random UUID
>>>> as the key for each skill:
>>>>
>>>> skills: {
>>>>   '4b27c2b3ac48e8df': 'java',
>>>>   '84bf94ea7bc92018': 'c++',
>>>>   '9103b9a93ce9d18': 'cobol'
>>>> }
>>>>
>>>> Is this a good way of handling lists in Cassandra?  I imagine there's
>>>> some idiom I'm not aware of.  I'm using the Astyanax<https://github.com/Netflix/astyanax/wiki>client
library, which only supports composite columns instead of super
>>>> columns, and so the solution I proposed above would seem quite awkward in
>>>> that case.  Though I'm still having some trouble understanding composite
>>>> columns as they seem not to be completely documented yet.  Would this
>>>> solution work with composite columns?
>>>>
>>>> Thanks,
>>>> Ben
>>>>
>>>>
>>>
>>
>

Mime
View raw message