I access cassandra from the ruby gem. I want to retrive data from cassandra db by specifying which columns I want to. whenever I run this
conn.get(:column_family, ‘key1’, [63,62])
I get the following error,
TypeError: can't convert Array into String
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/gems/thrift-0.8.0/lib/thrift/transport/framed_transport.rb:84:in `write'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/gems/thrift-0.8.0/lib/thrift/protocol/binary_protocol.rb:112:in `write_string'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/gems/thrift-0.8.0/lib/thrift/client.rb:35:in `write'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/gems/thrift-0.8.0/lib/thrift/client.rb:35:in `send_message'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/cassandra-7474449189f3/vendor/0.8/gen-rb/cassandra.rb:107:in `send_multiget_slice'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/cassandra-7474449189f3/vendor/0.8/gen-rb/cassandra.rb:102:in `multiget_slice'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/thrift_client-00893a3accc5/lib/thrift_client/abstract_thrift_client.rb:150:in `handled_proxy'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/thrift_client-00893a3accc5/lib/thrift_client/abstract_thrift_client.rb:60:in `multiget_slice'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/cassandra-7474449189f3/lib/cassandra/protocol.rb:64:in `_multiget'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/cassandra-7474449189f3/lib/cassandra/cassandra.rb:619:in `multi_get'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/bundler/gems/cassandra-7474449189f3/lib/cassandra/cassandra.rb:592:in `get'
from (irb):5:in `block in irb_binding'
from /home/ubuntu/.rvm/gems/ruby-1.9.2-p180@spaghetti/gems/connection_pool-0.1.0/lib/connection_pool.rb:41:in `with'
from (irb):4
from /home/ubuntu/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
A python package ‘pycassa’ provides the option to specify which columns to be retrieved. How to do that in ruby??
Currently
.get()and.multi_get()do not accept a list of column names. There is an open issue for this on GitHub. As a work around you can use.get_columns()instead.This returns an array of values in the same order as you specified for your column names. Alternatively you could use the
cassandra-cqlgem: