开发者

Why do I get an error when inserting rows with Net::Cassandra::Easy and Cassandra 0.5x?

开发者 https://www.devze.com 2022-12-23 12:05 出处:网络
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:

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?


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消