Hello,
I wrote a test program for testing Cassandra, and I had problems reading data. Seems like Cassandra sometimes takes one key for another.
Here is my test program :
from lazyboy import *
from lazyboy.key import Key
import uuid
import random
class TestItemKey(Key):
def __init__(self, key=None):
Key.__init__(self, "TestMX", "TestCF", key)
class TestItem(record.Record):
def __init__(self, *args, **kwargs):
record.Record.__init__(self, *args, **kwargs)
self.key = TestItemKey(uuid.uuid1().bytes)
connection.add_pool('TestMX', ['localhost:9160'])
t1 = TestItem({'test':'foo'})
t1.key = TestItemKey(uuid.UUID('3cead15a-a54e-11df-87a2-000c298d2724').bytes)
t2 = TestItem({'test':'bar'})
t2.key = TestItemKey(uuid.UUID('3cebc15a-a54e-11df-87a2-000c298d2724').bytes)
t1.save()
t2.save()
print TestItem().load(t1.key.clone())
print TestItem().load(t2.key.clone())
(The chosen UUIDs are an example of the ones causing problems)
Here is the output of this script :
root@ubuntu:/mnt/hgfs/TestMX# python test.py
TestItem: {'test': 'foo'}
TestItem: {'test': 'foo'}
Instead of the expected result :
root@ubuntu:/mnt/hgfs/TestMX# python test.py
TestItem: {'test': 'foo'}
TestItem: {'test': 'bar'}
Note that the script usually works great with other randomely-chosen UUIDs, but sometimes not...