Trying to call get_key_range against cassandra 0.6.4 generates an
exception, which is expected (replaced with get_range_slices). What
isn't expected is which exception it returns.
Code used (from examples):
eval {
my $what
= $client->get_key_range( 'Keyspace1', 'Standard1', '', '', 100,
Net::Cassandra::Backend::ConsistencyLevel::QUORUM );
warn "Keys: ", join( ', ', @$what );
};
warn $@->why if $@;
What it returns with stock Net::Cassandra 0.35:
Can't locate object method "why" via package "Can't use string ("0") as
a SCALAR ref while "strict refs" in use at
/usr/local/share/perl5/Net/Cassandra/Backend/Thrift/BinaryProtocol.pm
line 376.
" (perhaps you forgot to load "Can't use string ("0") as a SCALAR ref
while "strict refs" in use at
/usr/local/share/perl5/Net/Cassandra/Backend/Thrift/BinaryProtocol.pm
line 376.
"?) at ./get_key_range line 24.
Attached patch changes the read calls to use references and implements a
simple why sub.
What it returns after the patch:
[1] Invalid method name: 'get_key_range' at ./get_key_range line 24.
Subject: | TApplicationException.diff |
--- Net/Cassandra/Backend/Thrift.pm.orig 2010-08-20 17:37:08.000000000 -0500
+++ Net/Cassandra/Backend/Thrift.pm 2010-08-20 17:29:55.000000000 -0500
@@ -93,11 +93,12 @@
my $ftype = 0;
my $fid = 0;
- $xfer += $input->readStructBegin($fname);
+ $xfer += $input->readStructBegin(\$fname);
+
while (1)
{
- $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+ $xfer += $input->readFieldBegin($fname, \$ftype, \$fid);
if ($ftype == Net::Cassandra::Backend::TType::STOP) {
last; next;
}
@@ -107,7 +108,7 @@
/1/ && do{
if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString($self->{message});
+ $xfer += $input->readString(\$self->{message});
} else {
$xfer += $input->skip($ftype);
}
@@ -117,7 +118,7 @@
/2/ && do{
if ($ftype == Net::Cassandra::Backend::TType::I32) {
- $xfer += $input->readI32($self->{code});
+ $xfer += $input->readI32(\$self->{code});
} else {
$xfer += $input->skip($ftype);
}
@@ -174,4 +175,11 @@
return $self->{code};
}
+sub why
+{
+ my $self = shift;
+
+ return "[".$self->{code}."] ".$self->{message};
+}
+
1;