Browse files

Removed CompositeType logic from Simple.pm and transfered the burden …

…to the user
  • Loading branch information...
1 parent 1e72e6f commit 408d3b3e3c9d038abe0aff49987193a0fe10b721 @fmgoncalves committed Oct 11, 2011
Showing with 11 additions and 13 deletions.
  1. +7 −0 README
  2. +2 −3 lib/Cassandra/Composite.pm
  3. +2 −10 lib/Cassandra/Simple.pm
View
7 README
@@ -184,6 +184,13 @@ BUGS
<https://github.com/fmgoncalves/p5-cassandra-simple>.
TODO
+ Thrift Type Checking and Packing/Unpacking
+
+ The defined types (or defaults) for each column family are known and
+ should therefore be complied with. Introducing Composite Types has
+ forcefully introduced this functionality to an extent, but there should
+ be a refactoring to make this ubiquitous to the client.
+
Error Handling
Exceptions raised when calling Cassandra code should be report in error
View
5 lib/Cassandra/Composite.pm
@@ -21,10 +21,9 @@ sub composite {
}
sub composite_to_array {
- my $self = shift;
my $name = shift;
- # print "Input -> ".Dumper $name;
+ #print "Input -> ".Dumper $name;
my $size = length($name);
my @a;
my $len = 0;
@@ -34,7 +33,7 @@ sub composite_to_array {
$len += $off + 3;
} while ( $len < $size );
- # print "Output ->". Dumper \@a;
+ #print "Output ->". Dumper \@a;
return \@a;
}
View
12 lib/Cassandra/Simple.pm
@@ -72,7 +72,6 @@ has 'username' => ( is => 'rw', isa => 'Str', default => '' );
use 5.010;
use Cassandra::Cassandra;
use Cassandra::Pool;
-use Cassandra::Composite qw/composite composite_to_array/;
use strict;
use warnings;
### Thrift Protocol/Client methods ###
@@ -140,16 +139,9 @@ sub _column_or_supercolumn_to_hash {
my $cf = shift;
my $c_or_sc = shift;
- my $is_composite = 0;
- $is_composite = 1 if $self->ksdef->{$cf}->{comparator} =~ m/CompositeType/;
-
my @result;
if ( exists $c_or_sc->{column} and $c_or_sc->{column} ) {
- my $name =
- $is_composite
- ? $self->composite_to_array( $_->{column}->{name} )
- : $_->{column}->{name};
- @result = ( $name, $_->{column}->{value} );
+ @result = ( $_->{column}->{name}, $_->{column}->{value} );
} elsif ( exists $c_or_sc->{super_column} ) {
@result = (
$c_or_sc->{super_column}->{name},
@@ -979,7 +971,7 @@ Introducing Composite Types has forcefully introduced this functionality to an e
B<Error Handling>
-Exceptions raised when calling Cassandra code should be report in error form with appropriate description.
+Exceptions raised when calling Cassandra code should be reported in error form with appropriate description.
B<Unit Tests>

0 comments on commit 408d3b3

Please sign in to comment.