Why do I get an error when inserting rows with Net::Cassandra::Easy and Cassandra 0.5x?
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
精彩评论