为什么使用 Net::Cassandra::Easy 和 Cassandra 0.5x 插入行时会出现错误?
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它看起来像库中的错误:(
来自
Net::GenThrift::Thrift::BinaryProtocol
)显然,该 sub 是从库中的某个位置调用的,其中
$value
不是变量,而是常量标量。我会向作者报告该错误。It looks like a bug in the library:
(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.该代码在 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.
嗯,对我来说,处理异常时它看起来更像是 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