mkjellman / perlcassa

a Perl client for Apache Cassandra
Apache License 2.0
20 stars 12 forks source link

How to Use Bulk_insert #43

Closed geetanjaligandhi closed 11 years ago

geetanjaligandhi commented 11 years ago

i have table like

CREATE TABLE test_all(key text PRIMARY KEY, country text, state text, city text,month_of_year int, store_name text, in_stock boolean, store_city text, store_state float,year int);

Want to bulk insert the data using bulk_insert of perlcassa my %bulk = (

'key' => ['Tri-State Green Pepper'],

'country'  => ['USA'], 
'state' => ['WA'] , 
'city' => ['Seattle'], 
    'month_of_year' => ['8] ,
'store_name' => ['Store 99'] ,
'in_stock' => ['0'],
'store_city' => ['WA'] ,
'store_state' => ['Novato'] ,
'year' => ['2020'] 

);

$obj->bulk_insert( 'key' => 'Tri-State Green Pepper', 'columns' => \%bulk );

With this getting below error $VAR1 = '[8] does not fit inside a 32-bit int at /usr/local/share/perl/5.10.1/perlcassa.pm line 1341. $VAR1 = '[2020] does not fit inside a 32-bit int at /usr/local/share/perl/5.10.1/perlcassa.pm line 1341.

If i comment month_of_year and year value then it shows no error but data is not inserted in the table.

Key for my new row will be ''Tri-State Green Pepper', do i need to mention in my hash

Please share the code to work this scenario.

Also share the code for the same to insert the data as shown in "compositetype_get_example.pl "

Thanks, Geetanjali

mkjellman commented 11 years ago

not sure why the scalar 8 isn't fitting in the lower 32 bits on your machine, so something is pretty wrong here.

what i'm more confused about is how are you even getting to that point in the code. From your bug you are creating a cql3 table and then accessing it with thrift (and >1.2.0 C* doesn't expose those cf's)

what version of Cassandra are you working with?

geetanjaligandhi commented 11 years ago

With C 1.1.9.3., i wanted to use bulk_insert method. How to create the hash for passing it to this method. with cql3 you mean by using boolean type in table ?

I just wanted to use this call... what should be the proper syntax or way to use this.

mkjellman commented 11 years ago

you are using the proper syntax as far as i can see. i don't have a copy of DSE handy so I can't test for you and figure out why the 32-bit mask is not packing correctly. And going forward the perlcassa project is only going to be supporting 1.2.0+ Cassandra and CQL3.

I would suggest you don't try to throw the numbers in quotes as I might of had a bug there.

CQL3 lets you batch the request using "BEGIN BATCH" etc but as you are on DSE this won't work yet until a version of DSE comes out that is based off of the 1.2 branch.