cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shuge Lee <shuge....@gmail.com>
Subject Re: how to store list data in Apache Cassndra ?
Date Tue, 06 Apr 2010 15:06:42 GMT
>     'girls': pickle.dumps(['java', 'actionscript', 'python'])

I think this is a really bad idea, I can't do any search if using Pickle.

> use a SuperColumnFamily
sounds nice :)

I'm try handle it with following:

 value = {
    'name': 'Lee Li',
    'age'; '21',
    'girls': {
        'java': '',
        'actionscript': '',
        'python': '',
        ),
 }

2010/4/6 David Strauss <david@fourkitchens.com>

> Another option is to use a SuperColumnFamily, but that extends the depth
> of all such values to be arrays. The "name" and "age" columns would
> therefore also need to be SuperColumns -- just with a single sub-column
> each.
>
> Like many things in Cassandra, the preferred storage method depends on
> your application's access patterns. It's quite unlike the normalization
> procedure for an RDBMS, which is possible without knowing future queries.
>
> On 2010-04-06 09:12, Michael Pearson wrote:
> > Column Families are keyed attribute/value pairs, your 'girls' column
> > will need to be serialised on save, and deserialiased on load so that
> > it can treated as your intended array.  Pickle will do this for you
> > (http://docs.python.org/library/pickle.html)
> >
> > eg:
> >
> >  import pycassa
> >  import pickle
> >  client = pycassa.connect()
> >  cf = pycassa.ColumnFamily(client, 'mygame', 'user')
> >
> >  key = '1234567890'
> >  value = {
> >      'name': 'Lee Li',
> >      'age'; '21',
> >      'girls': pickle.dumps(['java', 'actionscript', 'python'])
> >  }
> >
> > cf.insert(key, value)
> >
> > hope that helps
> >
> > -michael
> >
> >
> > On Tue, Apr 6, 2010 at 6:49 PM, Shuge Lee <shuge.lee@gmail.com> wrote:
> >> Dear firends:
> >>
> >> how to store list data in Apache Cassndra ?
> >>
> >> For example:
> >> user['lee'] = {
> >>     'name': 'lee',
> >>     'age'; '21',
> >>     'girls': ['java', 'actionscript', 'python'],
> >> }
> >> Notice key `gils`
> >>
> >> I using pycassa (a python lib of cassandra)
> >>
> >> import pycassa
> >> client = pycassa.connect()
> >> cf = pycassa.ColumnFamily(client, 'mygame', 'user')
> >>
> >> key = '1234567890'
> >> value = {
> >>     'name': 'Lee Li',
> >>
> >>     'age'; '21',
> >>     'girls': ['java', 'actionscript', 'python'],
> >> }
> >>
> >> cf.insert(key, value)
> >>
> >>
> >> Oops, get error while save a `value` like above.
> >>
> >> So, how to store list data in Apache Cassndra ?
> >>
> >>
> >> Thanks for reply.
> >>
> >>
> >>
> >>
> >> --
> >> Shuge Lee | Lee Li
> >>
>
>
> --
> David Strauss
>   | david@fourkitchens.com
> Four Kitchens
>   | http://fourkitchens.com
>   | +1 512 454 6659 [office]
>   | +1 512 870 8453 [direct]
>
>


-- 
Shuge Lee | Lee Li | 李蠡

Mime
View raw message