Skip to content

Commit

Permalink
Changed insert and batch insert $columns argument type
Browse files Browse the repository at this point in the history
  • Loading branch information
fmgoncalves committed Jul 18, 2011
1 parent fc27c86 commit 5f2c7b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README
Expand Up @@ -12,12 +12,12 @@ DESCRIPTION
using Cassandra. using Cassandra.


SYNOPSYS SYNOPSYS
#Assuming the keyspace 'simple' and the column family 'simple' exist

my ($keyspace, $column_family) = qw/simple simple/; my ($keyspace, $column_family) = qw/simple simple/;


my $conn = Cassandra::Simple->new(keyspace => $keyspace,); my $conn = Cassandra::Simple->new(keyspace => $keyspace,);


$conn->create_column_family( $keyspace, $column_family);

$conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] ); $conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] );


$conn->get($column_family, 'KeyA'); $conn->get($column_family, 'KeyA');
Expand Down Expand Up @@ -118,7 +118,7 @@ SYNOPSYS
timestamp, ttl, consistency_level_write timestamp, ttl, consistency_level_write


insert_super insert_super
Usage: "insert($column_family, $key, $columns[, opt])" Usage: "insert_super($column_family, $key, $columns[, opt])"


The $columns is an *HASH* of the form "{ super_column => { column => The $columns is an *HASH* of the form "{ super_column => { column =>
value, column => value } }" value, column => value } }"
Expand Down
6 changes: 3 additions & 3 deletions examples/cassandra_simple_test.pm
Expand Up @@ -40,16 +40,16 @@ my $conn = Cassandra::Simple->new(
#batch_insert 100% 100% #batch_insert 100% 100%
#remove 100% 100% #remove 100% 100%


println "\$conn->insert($column_family, 'ChaveA', [ [ 'ColunaA1' => 'ValorA1' ], [ 'ColunaA2' => 'ValorA2' ] ] )"; println "\$conn->insert($column_family, 'ChaveA', { 'ColunaA1' => 'ValorA1' , 'ColunaA2' => 'ValorA2' } )";
$conn->insert($column_family, 'ChaveA', [ [ 'ColunaA1' => 'ValorA1' ], [ 'ColunaA2' => 'ValorA2' ] ] ); $conn->insert($column_family, 'ChaveA', { 'ColunaA1' => 'ValorA1' , 'ColunaA2' => 'ValorA2' } );


println "\$conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/ ] })"; println "\$conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/ ] })";
println Dumper $conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/ ] }); println Dumper $conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/ ] });
#Expected result: ValorA1 #Expected result: ValorA1


println "\$conn->get($column_family, 'ChaveA')"; println "\$conn->get($column_family, 'ChaveA')";
println Dumper $conn->get($column_family, 'ChaveA'); println Dumper $conn->get($column_family, 'ChaveA');
#Expected result: [ [ 'ColunaA1' => 'ValorA1' ], [ 'ColunaA2' => 'ValorA2' ] ] #Expected result: { 'ColunaA1' => 'ValorA1', 'ColunaA2' => 'ValorA2' }


println "\$conn->get($column_family, 'ChaveA', { column_count => 1, column_reversed => 1 })"; println "\$conn->get($column_family, 'ChaveA', { column_count => 1, column_reversed => 1 })";
println Dumper $conn->get($column_family, 'ChaveA', { column_count => 1, column_reversed => 1 }); println Dumper $conn->get($column_family, 'ChaveA', { column_count => 1, column_reversed => 1 });
Expand Down
1 change: 0 additions & 1 deletion examples/super_column_support.pm
Expand Up @@ -61,7 +61,6 @@ println "\$conn->get_count($column_family, 'KeyA')";
println Dumper $conn->get_count($column_family, 'KeyA'); println Dumper $conn->get_count($column_family, 'KeyA');
#Expected result: 3 #Expected result: 3



##NOT IMPLEMENTED IN CASSANDRA YET ##NOT IMPLEMENTED IN CASSANDRA YET
#println "\$conn->remove($column_family, ['KeyA'], {super_column => 'SuperColumnC'})"; #println "\$conn->remove($column_family, ['KeyA'], {super_column => 'SuperColumnC'})";
#println Dumper $conn->remove($column_family, ['KeyA'], {super_column => 'SuperColumnC'}); #println Dumper $conn->remove($column_family, ['KeyA'], {super_column => 'SuperColumnC'});
Expand Down
16 changes: 8 additions & 8 deletions lib/Cassandra/Simple.pm
Expand Up @@ -21,12 +21,12 @@ This module attempts to abstract the underlying Thrift methods as much as possib
=head1 SYNOPSYS =head1 SYNOPSYS
#Assuming the keyspace 'simple' and the column family 'simple' exist
my ($keyspace, $column_family) = qw/simple simple/; my ($keyspace, $column_family) = qw/simple simple/;
my $conn = Cassandra::Simple->new(keyspace => $keyspace,); my $conn = Cassandra::Simple->new(keyspace => $keyspace,);
$conn->create_column_family( $keyspace, $column_family);
$conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] ); $conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] );
$conn->get($column_family, 'KeyA'); $conn->get($column_family, 'KeyA');
Expand Down Expand Up @@ -541,7 +541,7 @@ sub get_indexed_slices {
Usage: C<< insert($column_family, $key, $columns[, opt]) >> Usage: C<< insert($column_family, $key, $columns[, opt]) >>
The C<$columns> is an I<ARRAYREF> of the form C<< [ [ column => value ] ] >> The C<$columns> is an I<HASHREF> of the form C<< { column => value, column => value } >>
C<$opt> is an I<HASH> and can have the following keys: C<$opt> is an I<HASH> and can have the following keys:
Expand Down Expand Up @@ -574,8 +574,8 @@ sub insert {
column => column =>
new Cassandra::Column( new Cassandra::Column(
{ {
name => $_->[0], name => $_,
value => $_->[1], value => $columns->{$_},
timestamp => $opt->{timestamp} // time, timestamp => $opt->{timestamp} // time,
ttl => $opt->{ttl} // undef, ttl => $opt->{ttl} // undef,
} }
Expand All @@ -584,15 +584,15 @@ sub insert {
) )
} }
) )
} @{$columns}; } keys % $columns;


$self->client->batch_mutate( { $key => { $column_family => \@mutations } }, $self->client->batch_mutate( { $key => { $column_family => \@mutations } },
$level ); $level );
} }


=head2 insert_super =head2 insert_super
Usage: C<< insert($column_family, $key, $columns[, opt]) >> Usage: C<< insert_super($column_family, $key, $columns[, opt]) >>
The C<$columns> is an I<HASH> of the form C<< { super_column => { column => value, column => value } } >> The C<$columns> is an I<HASH> of the form C<< { super_column => { column => value, column => value } } >>
Expand Down Expand Up @@ -657,7 +657,7 @@ sub insert_super {
Usage: C<batch_insert($column_family, $rows[, opt])> Usage: C<batch_insert($column_family, $rows[, opt])>
C<$rows> is an I<HASH> of the form C<< { key => [ [ column => value ] , [ column => value ] ], key => [ [ column => value ] , [ column => value ] ] } >> C<$rows> is an I<HASH> of the form C<< { key => { column => value , column => value }, key => { column => value , column => value } } >>
C<$opt> is an I<HASH> and can have the following keys: C<$opt> is an I<HASH> and can have the following keys:
Expand Down

0 comments on commit 5f2c7b6

Please sign in to comment.