为什么 Cassandra 使用字节键(使用 Lazyboy)会表现得很奇怪?

发布于 2024-09-13 17:24:36 字数 1199 浏览 3 评论 0原文

我编写了一个测试程序来测试 Cassandra,但在读取数据时遇到了问题。看来卡桑德拉有时会把一把钥匙换成另一把钥匙。

这是我的测试程序:(

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())

所选的 UUID 是导致问题的示例)

以下是此脚本的输出:

root@ubuntu:/mnt/hgfs/TestMX# python test.py 
TestItem: {'test': 'foo'}
TestItem: {'test': 'foo'}

而不是预期结果:

root@ubuntu:/mnt/hgfs/TestMX# python test.py 
TestItem: {'test': 'foo'}
TestItem: {'test': 'bar'}

请注意,该脚本通常与其他随机选择的 UUID 配合使用效果很好,但有时则不然...

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖心男生 2024-09-20 17:24:36

听起来很像您正在点击 https://issues.apache.org/jira/ browser/CASSANDRA-1235 已在 0.6 分支中修复,并将在下一个稳定版本 0.6.5 中发布。

Sounds a lot like you're hitting https://issues.apache.org/jira/browse/CASSANDRA-1235 which is fixed in the 0.6 branch and will be in 0.6.5, the next stable release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文