Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed insert and batch insert $columns argument type

  • Loading branch information...
commit 5f2c7b6059b597cfb1b974f0dd424225cbcf6556 1 parent fc27c86
@fmgoncalves authored
View
6 README
@@ -12,12 +12,12 @@ DESCRIPTION
using Cassandra.
SYNOPSYS
- #Assuming the keyspace 'simple' and the column family 'simple' exist
-
my ($keyspace, $column_family) = qw/simple simple/;
my $conn = Cassandra::Simple->new(keyspace => $keyspace,);
+ $conn->create_column_family( $keyspace, $column_family);
+
$conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] );
$conn->get($column_family, 'KeyA');
@@ -118,7 +118,7 @@ SYNOPSYS
timestamp, ttl, consistency_level_write
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 =>
value, column => value } }"
View
6 examples/cassandra_simple_test.pm
@@ -40,8 +40,8 @@ my $conn = Cassandra::Simple->new(
#batch_insert 100% 100%
#remove 100% 100%
-println "\$conn->insert($column_family, 'ChaveA', [ [ 'ColunaA1' => 'ValorA1' ], [ 'ColunaA2' => 'ValorA2' ] ] )";
-$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' } );
println "\$conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/ ] })";
println Dumper $conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/ ] });
@@ -49,7 +49,7 @@ println Dumper $conn->get($column_family, 'ChaveA', { columns => [ qw/ColunaA1/
println "\$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 Dumper $conn->get($column_family, 'ChaveA', { column_count => 1, column_reversed => 1 });
View
1  examples/super_column_support.pm
@@ -61,7 +61,6 @@ println "\$conn->get_count($column_family, 'KeyA')";
println Dumper $conn->get_count($column_family, 'KeyA');
#Expected result: 3
-
##NOT IMPLEMENTED IN CASSANDRA YET
#println "\$conn->remove($column_family, ['KeyA'], {super_column => 'SuperColumnC'})";
#println Dumper $conn->remove($column_family, ['KeyA'], {super_column => 'SuperColumnC'});
View
16 lib/Cassandra/Simple.pm
@@ -21,12 +21,12 @@ This module attempts to abstract the underlying Thrift methods as much as possib
=head1 SYNOPSYS
- #Assuming the keyspace 'simple' and the column family 'simple' exist
-
my ($keyspace, $column_family) = qw/simple simple/;
my $conn = Cassandra::Simple->new(keyspace => $keyspace,);
+ $conn->create_column_family( $keyspace, $column_family);
+
$conn->insert($column_family, 'KeyA', [ [ 'ColumnA' => 'AA' ], [ 'ColumnB' => 'AB' ] ] );
$conn->get($column_family, 'KeyA');
@@ -541,7 +541,7 @@ sub get_indexed_slices {
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:
@@ -574,8 +574,8 @@ sub insert {
column =>
new Cassandra::Column(
{
- name => $_->[0],
- value => $_->[1],
+ name => $_,
+ value => $columns->{$_},
timestamp => $opt->{timestamp} // time,
ttl => $opt->{ttl} // undef,
}
@@ -584,7 +584,7 @@ sub insert {
)
}
)
- } @{$columns};
+ } keys % $columns;
$self->client->batch_mutate( { $key => { $column_family => \@mutations } },
$level );
@@ -592,7 +592,7 @@ sub insert {
=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 } } >>
@@ -657,7 +657,7 @@ sub insert_super {
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:
Please sign in to comment.
Something went wrong with that request. Please try again.