为什么使用 Net::Cassandra::Easy 和 Cassandra 0.5x 插入行时会出现错误?

发布于 2024-08-25 14:38:26 字数 892 浏览 6 评论 0原文

使用 Perl 模块 Net::Cassandra::Easy 进行接口时使用 Cassandra,我使用以下代码从列系列 Standard1 中的行 row[123] 读取列 col[123]

my $cassandra = Net::Cassandra::Easy->new(keyspace => 'Keyspace1', server => 'localhost');
$cassandra->connect();
my $result = $cassandra->get(['row1', 'row2', 'row3'], family => 'Standard1', byname => ['col1', 'col2', 'col3']);

这有效正如预期的那样。

但是,当尝试使用 .. .. 插入行 row1

$result = $cassandra->mutate(['row1'], family => 'Standard1', insertions => { "col1" => "Value to set." });

,我收到错误消息 Can't use string ("0") as a SCALAR ref while "strict refs" in use at .../Net/GenThrift/Thrift/BinaryProtocol.pm 第 376 行

我做错了什么?

When using the Perl module Net::Cassandra::Easy to interface with Cassandra I use the following code to read colums col[123] from rows row[123] in the column-family Standard1:

my $cassandra = Net::Cassandra::Easy->new(keyspace => 'Keyspace1', server => 'localhost');
$cassandra->connect();
my $result = $cassandra->get(['row1', 'row2', 'row3'], family => 'Standard1', byname => ['col1', 'col2', 'col3']);

This works as expected.

However, when trying to insert row row1 with ..

$result = $cassandra->mutate(['row1'], family => 'Standard1', insertions => { "col1" => "Value to set." });

.. I get the error message Can't use string ("0") as a SCALAR ref while "strict refs" in use at .../Net/GenThrift/Thrift/BinaryProtocol.pm line 376.

What am I doing wrong?

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

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

发布评论

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

评论(3

蝶…霜飞 2024-09-01 14:38:26

它看起来像库中的错误:(

sub readByte
{
    my $self  = shift;
    my $value = shift;

    my $data = $self->{trans}->readAll(1);
    my @arr = unpack('c', $data);
    $value = $arr[0];    # <~ line 376
    return 1;
}

来自 Net::GenThrift::Thrift::BinaryProtocol

显然,该 sub 是从库中的某个位置调用的,其中 $value不是变量,而是常量标量。我会向作者报告该错误。

It looks like a bug in the library:

sub readByte
{
    my $self  = shift;
    my $value = shift;

    my $data = $self->{trans}->readAll(1);
    my @arr = unpack('c', $data);
    $value = $arr[0];    # <~ line 376
    return 1;
}

(from Net::GenThrift::Thrift::BinaryProtocol)

Apparently that sub is being called from somewhere in the library where $value is not a variable, but a constant scalar. I'd report the bug to the authors.

怕倦 2024-09-01 14:38:26

该代码在 Cassandra 0.6.x 下按预期工作,但在 Cassandra 0.5.x 下失败。

看起来好像 Net::Cassandra::Easy 仅针对 Cassandra 0.6.x。

升级到 Cassandra 0.6.x 可以解决该问题。

The code works as expected under Cassandra 0.6.x, but fails under Cassandra 0.5.x.

It appears as if Net::Cassandra::Easy is targeting Cassandra 0.6.x only.

Upgrading to Cassandra 0.6.x solves the problem.

比忠 2024-09-01 14:38:26

嗯,对我来说,处理异常时它看起来更像是 Perl 绑定错误。

我相信 0.6 已经为你解决了这个问题,因为界面确实发生了变化,所以 0.6 不再引发 thrift 异常,但 thrift 中的 bug 仍然存在。我打开了一个 JIRA 案例,我们会看到 thrift 团队对此的说明:

https ://issues.apache.org/jira/browse/THRIFT-758

hmm, it looks more like a Perl binding bug when handling exception to me.

I believe that 0.6 fixes it for you because the interface has indeed changed, so 0.6 is not raising a thrift exception anymore, but the bug in thrift remains. I've opened a JIRA case, we'll see that thrift team says about it:

https://issues.apache.org/jira/browse/THRIFT-758

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