lazyboy works vs an earlier version of trunk, so it's already incompatible with 0.3, but not yet compatible w/ latest 0.4 :)
On Mon, Aug 24, 2009 at 12:28 PM, Bruno Couto<[email protected]> wrote: > Jonathan, > > > First, thanks for answering so fast. > I´m using version 0.3-final of Cassandra, then I believe the api > version 0.4 is not the problem, am I correct? > I'll look for the null problem. > > > Bruno Couto > > > On Mon, Aug 24, 2009 at 11:50 AM, Jonathan Ellis<[email protected]> wrote: >> There's two things going on here, I think. >> >> One is that you're passing a null where there shouldn't be one. This >> is a thrift bug and will be addressed in the next beta. >> >> The other is that IIRC lazyboy needs to be updated to work with the >> latest 0.4 api. >> >> -Jonathan >> >> On Mon, Aug 24, 2009 at 9:09 AM, Bruno Couto<[email protected]> wrote: >>> Hi Guys, >>> >>> my name is Bruno and I'm from Brazil, first, sorry for my bad english. >>> I'm in my first steps with cassandra, and I´m trying to use Lazyboy >>> (python wrapper). >>> But when I run the layzyboy columnfamily.py example, I get the >>> following error messages. >>> Someone with more experience could help me? >>> >>> Thanks, >>> >>> Bruno Couto. >>> >>> >>> ---- >>> >>> Cassandra Error Message: >>> >>> DEBUG - batch_insert >>> ERROR - Internal error processing batch_insert >>> java.lang.NullPointerException >>> at >>> org.apache.cassandra.db.RowMutation.getRowMutation(RowMutation.java:284) >>> at >>> org.apache.cassandra.service.CassandraServer.batch_insert(CassandraServer.java:318) >>> at >>> org.apache.cassandra.service.Cassandra$Processor$batch_insert.process(Cassandra.java:968) >>> at >>> org.apache.cassandra.service.Cassandra$Processor.process(Cassandra.java:807) >>> at >>> org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:252) >>> at >>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) >>> at >>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) >>> at java.lang.Thread.run(Thread.java:619) >>> DEBUG - Disseminating load info ... >>> >>> ---- >>> >>> Python Error Message: >>> >>> localhost ~ # python columnfamily.py >>> {'table': 'UserData', 'superkey': None, 'key': >>> '3a63b82a947d4ee1a8cbee45944b5dcb', 'family': 'Users', 'supercol': >>> None} >>> {'username': 'ieure', 'email': '[email protected]'} >>> True >>> Traceback (most recent call last): >>> File "columnfamily.py", line 65, in <module> >>> u.save() # -> {'username': 'ieure', 'email': '[email protected]'} >>> File "/root/columnfamily.py", line 119, in save >>> >>> File "build/bdist.linux-i686/egg/lazyboy/connection.py", line 106, in func >>> lazyboy.exceptions.ErrorThriftMessage: Internal error processing >>> batch_insert >>> >>> ---- >>> >>> ColumnFamily.py >>> >>> # -*- coding: utf-8 -*- >>> # >>> # Lazyboy examples >>> # >>> # © 2009 Digg, Inc. All rights reserved. >>> # Author: Ian Eure <[email protected]> >>> # >>> # This example assumes the following schema: >>> # >>> # <Tables> >>> # <Table Name="UserData"> >>> # <ColumnFamily ColumnSort="Name" Name="Users"/> >>> # </Table> >>> # </Tables> >>> # >>> >>> >>> from lazyboy import * >>> >>> >>> # Define your cluster(s) >>> connection.add_pool('UserData', ['localhost:9160']) >>> >>> >>> # Subclass ColumnFamily to create an object of the correct type. >>> class User(columnfamily.ColumnFamily): >>> """A class representing a user in Cassandra.""" >>> >>> # _key is the key template. It's values are given to >>> # PrimaryKey.__init__ as keyword arguments any time a PK is >>> # instantiated for this object. >>> _key = {'table': 'UserData', # The table to store in >>> 'family': 'Users'} # The ColumnFamily name to store on >>> >>> # Anything in here _must_ be set before the object is saved >>> _required = ('username',) >>> >>> >>> # Create an empty object >>> u = User() >>> >>> # A PrimaryKey is generated for you: >>> print u.pk >>> # -> {'table': 'UserData', 'superkey': None, >>> # 'key': 'da6c8e19174f40cfa6d0b65a08eef62f', >>> # 'family': 'Users', 'supercol': None} >>> >>> data = {'username': 'ieure', 'email': '[email protected]'} >>> >>> # The object is a dict. All these are equivalent. >>> u.update(data) >>> u.update(data.items()) >>> u.update(**data) >>> for k in data: >>> u[k] = data[k] >>> >>> # Arguments to __init__ are passed to update() >>> u = User(data) >>> print u # -> {'username': 'ieure', 'email': '[email protected]'} >>> >>> # You can see if it's been modified. >>> print u.is_modified() # -> True >>> >>> # Save to Cassandra >>> u.save() # -> {'username': 'ieure', 'email': '[email protected]'} >>> >>> print u.is_modified() # -> False >>> >>> # Load it in a new instance. >>> u_ = User().load(u.pk.key) >>> print u_ # -> {'username': 'ieure', 'email': '[email protected]'} >>> >>> print u.is_modified() # -> False >>> del u['username'] >>> print u.valid() # -> False >>> print u.missing() # -> ('username',) >>> try: >>> u.save() # -> ('Missing required field(s):', ('username',)) >>> except Exception, e: >>> print e >>> >>> # Discard modifications >>> u.revert() >>> print u.is_modified() # -> False >>> print u.valid() # -> True >>> >> >
