cassandra-rb / cassandra Goto Github PK
View Code? Open in Web Editor NEWA Ruby client for the Cassandra distributed database
License: Apache License 2.0
A Ruby client for the Cassandra distributed database
License: Apache License 2.0
Thrift does not compile without alterations to struct.c relating to strlcpy. With this file fixed, Thrift 0.2.5 (from latest thrift git) does not appear to work with cassandra:
james@hometree:~/cassandra$ irb irb(main):001:0> require 'thrift' => true irb(main):002:0> require 'cassandra' ArgumentError: wrong number of arguments (4 for 2) from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/vendor/gen-rb/cassandra_types.rb:32:in `' from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/vendor/gen-rb/cassandra_types.rb:26:in `' from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/vendor/gen-rb/cassandra_types.rb:8:in `' from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/vendor/gen-rb/cassandra.rb:8:in `require' from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/vendor/gen-rb/cassandra.rb:8:in `' from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/lib/cassandra.rb:9:in `require' from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.8.1/lib/cassandra.rb:9:in `' from (irb):2:in `require' from (irb):2 from /usr/local/bin/irb:12:in `'
james@hometree:~/cassandra$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]
Hey there,
found a "bug" in the code to handle the conversion from ruby hashes to cassandra mutations. Basically the column value for super columns can be anything (since .to_s will be called) while normal columns will fail.
Add this to "test/cassandra_test.rb" to see the error:
def test_super_allows_for_non_string_values_while_normal_does_not columns = {'user_timelines' => {@uuids[4] => 4, @uuids[5] => 5}} # right now: this works @twitter.insert(:StatusRelationships, key, columns) # this fails @twitter.insert(:Statuses, key, { 'body' => 1 }) end
Error: "NoMethodError: undefined method `length' for 1:Fixnum"
Looking at the code at lib/cassandra/columns.rb
standard_insert_mutation does :value => value
while
super_insert_mutation does :value => sub_column_value.to_s
Just think thats a little inconsitent and confused the hell out of me because I could add Time instances to supercolumns but not normal ones. I know now that values HAVE to be byte[] aka Strings in ruby but thought I'd mention this since I think the behavior should be the same for both cases.
I have a SuperColumnFamily listed like this:
<ColumnFamily Name="AccessLog"
ColumnType="Super"
CompareWith="TimeUUIDType"
CompareSubcolumnsWith="UTF8Type"
KeysCached="0"
/>
Using get_range( :AccessLog, { :start = "20100827092532" }) gives the following error:
/Library/Ruby/Gems/1.8/gems/simple_uuid-0.1.1/lib/simple_uuid.rb:35:in `initialize': Expected "20100827092532" to cast to a SimpleUUID::UUID (invalid bytecount) (TypeError)
Looks to me like extract_and_validate_params is assuming that :start and :finish options always refer to the supercolumn structure, not the key structure.
patching file test/system/test_server.py
[trunk]: created 52c5e33: "Applied patch: "http://issues.apache.org/jira/secure/attachment/12417533/388.patch""
9 files changed, 129 insertions(+), 1238 deletions(-)
delete mode 100644 interface/gen-java/org/apache/cassandra/service/BatchMutationSuper.java
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1054 100 1054 0 0 18644 0 --:--:-- --:--:-- --:--:-- 0
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
rake aborted!
http://issues.apache.org/jira/secure/attachment/12417682/CASSANDRA-336-code.diff failed
/Library/Ruby/Gems/1.8/gems/cassandra-0.5.5/Rakefile:94
In moving from gem 0.6 to 0.7.2 my clients were no longer talking to the correct server ip.
It's possible that my problem is that I should have added something to the config files during the upgrade that I missed. I did a diff on them between versions and didn't see anything different though.
I tracked the problem to this method in cassandra.rb:
def all_nodes
ips = ::JSON.parse(@client.get_string_property('token map')).values
port = @servers.first.split(':').last
ips.map{|ip| "#{ip}:#{port}" }
end
As far as I know I don't have a token map defined, nor do I know how to define it. The client! method uses this all_nodes and overwrites the server attribute with the result of it.
Hi,
from time to time I get and error: "Required field 'timestamp' was not found in serialized data!".
It's happen randomly and I don't have any idea why.
I try to insert data in that way:
client = Cassandra.new('Test', '127.0.0.1:9160')
client.insert(:Cmessages, "ad26857a063b54659f3d7626b152864d698167c5" , {
body: "some utf8 string ĄŚĘŁÓąęśćół",
entry_url: "http://url.com/someurl",
posted_on: Date.today.to_s(:db)}.stringify_keys
)
and sometimes it's works.
schema:
org.apache.cassandra.locator.RackUnawareStrategy
1
org.apache.cassandra.locator.EndPointSnitch
backtrace:
Required field 'timestamp' was not found in serialized data! Struct: Column(name:62 6F 64 79, value:73 6F 6D 65 20 75 74 66 38 20 73 74 72 69 6E 67 20 C4 84 C5 9A C4 98 C5 81 C3 93 C4, timestamp:0)
.../thrift-0.2.0.4/lib/thrift/client.rb:65:in handle_exception' .../thrift-0.2.0.4/lib/thrift/client.rb:46:in
receive_message'
.../cassandra-0.8.2/vendor/gen-rb/cassandra.rb:219:in recv_batch_mutate' .../cassandra-0.8.2/vendor/gen-rb/cassandra.rb:211:in
batch_mutate'
.../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in send_rpc' .../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:161:in
send_rpc'
.../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:60:in proxy' .../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:151:in
proxy'
.../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:53:in handled_proxy' .../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:147:in
handled_proxy'
.../thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:23:in batch_mutate' .../cassandra-0.8.2/lib/cassandra/protocol.rb:8:in
_mutate'
.../cassandra-0.8.2/lib/cassandra/cassandra.rb:118:in `insert'
Could You help me?
Please, can you tell how to get first 100 values from some column family? Everything I tried didn't work (column family is standard, not super). Thanks.
Hi,
with this code :
require 'rubygems'
require 'cassandra'
cassandra = Cassandra.new('Twitter', '127.0.0.1:9160')
cassandra.clear_keyspace!()
I got this message :
cassandra = Cassandra.new('Proxi', '127.0.0.1:9160')
ThriftClient::NoServersAvailable: No live servers in ["127.0.0.1:9160"] since Sat May 22 16:47:04 +0200 2010.
It works if I connect remotely to the server with the same script....
Telnet en 127.0.0.1:9160 works
Any idea ?
Have a column family with super columns. Trying to create columns with tweet ids as the key, and nil as the value. I get an error on .insert.
"Required field value is unset!"
Exception is raised from the CassandraThrift Column class's validate method
at Line 42 in vendor/gen-rb/cassandra_types.rb
I pull out fauna/cassandra gem 0.10.0 from github.
I then tried to get a value from cassandra as such.
irb(main):002:0> require 'cassandra/0.7'
=> true
irb(main):003:0> client = Cassandra.new('Keyspace1', '127.0.0.1:9160')
=> #<Cassandra:70286805872140, @keyspace="Keyspace1", @Schema={}, @servers=["127.0.0.1:9160"]>
irb(main):004:0> client.insert(:Standard1, "5", {'screen_name' => "buttonscat"})
=> nil
irb(main):006:0> client.get(:Standard1, "5", 'screen_name')
NoMethodError: undefined method multiget' for #<ThriftClient:0x7fd9d82e5270> from /home/jpartogi/.rvm/gems/ruby-1.8.7-p302/gems/cassandra-0.10.0/lib/cassandra/0.7/protocol.rb:53:in
_multiget'
from /home/jpartogi/.rvm/gems/ruby-1.8.7-p302/gems/cassandra-0.10.0/lib/cassandra/cassandra.rb:198:in multi_get' from /home/jpartogi/.rvm/gems/ruby-1.8.7-p302/gems/cassandra-0.10.0/lib/cassandra/cassandra.rb:189:in
get'
from (irb):6
from :0
irb(main):007:0>
It turns out that the gem is still relying on thrift < 0.2.5 as can be seen on cassandra.rb.
Hi,
the current master branch is broken:
require "cassandra"
causes the following error:
LoadError: no such file to load -- cassandra/0.6/columns
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
from /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/../cassandra.rb:27
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
from /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/0.6.rb:7
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
from /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra.rb:12
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:ingem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in
require'
from (irb):1
The problem is that the Manifest file is not up-to-date. I've updated the Manifest file in http://github.com/flippingbits/cassandra/commit/91b157130821a36c989b12aab4cbb8f57d8b2c05.
Should I send a pull request?
Regards
Currently only strings are supported as column names.
The following code
client.insert(:Users, "5", { :screen_name => "buttonscat"})
will raise this error
can't convert Symbol into String
/Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/0.7/columns.rb:10:ininitialize' /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/0.7/columns.rb:10:in
new'
/Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/0.7/columns.rb:10:in_standard_insert_mutation' /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:123:in
insert'
/Library/Ruby/Gems/1.8/gems/uuid-2.2.0/lib/uuid.rb:140:incollect' /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:123:in
each'
/Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:123:incollect' /Library/Ruby/Gems/1.8/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:123:in
insert'
I've already fixed this in my local version. What do you think? Should symbols also be supported?
I'd like to send a pull request.
Kind regards
The README needs a slight update:
Instead of
client = Cassandra.new('Twitter', '127.0.0.1')
it should be
client = Cassandra.new('Twitter', '127.0.0.1:9160')
otherwise you'll get a "ArgumentError: Servers must be in the form "host:port"" when you try to insert a row.
Thanks for the library!
When writing to Cassandra, we regularly see "Unexpected State." The confusing thing is that this message is not consistent, after a number of failed inserts the writer will revert to normal behaviour and insert normally. No clear reason for the message is given.
Not sure if this is the result of cassandra or thrift.
A stack trace is as follows:
[ERROR] 2011-01-17 17:07:29 (Alex::Writer) :: Unexpected state
[ERROR] 2011-01-17 17:07:29 (Alex::Writer) :: /usr/local/lib/ruby/gems/1.9.1/gems/thrift_client-0.6.0/lib/thrift_client/event_machine.rb:86:in blocking_read' /usr/local/lib/ruby/gems/1.9.1/gems/thrift_client-0.6.0/lib/thrift_client/event_machine.rb:39:in
read'
/usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/transport/base_transport.rb:52:in read_all' /usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/transport/framed_transport.rb:78:in
read_frame'
/usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/transport/framed_transport.rb:49:in read' /usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/transport/base_transport.rb:52:in
read_all'
/usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/protocol/binary_protocol.rb:186:in read_i32' /usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/protocol/binary_protocol.rb:111:in
read_message_begin'
/usr/local/lib/ruby/gems/1.9.1/gems/thrift-0.5.0/lib/thrift/client.rb:45:in receive_message' /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/vendor/0.7/gen-rb/cassandra.rb:358:in
recv_describe_keyspace'
/usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/vendor/0.7/gen-rb/cassandra.rb:350:in describe_keyspace' /usr/local/lib/ruby/gems/1.9.1/gems/thrift_client-0.6.0/lib/thrift_client/abstract_thrift_client.rb:115:in
handled_proxy'
/usr/local/lib/ruby/gems/1.9.1/gems/thrift_client-0.6.0/lib/thrift_client/abstract_thrift_client.rb:57:in describe_keyspace' /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/lib/cassandra/0.7/cassandra.rb:31:in
schema'
/usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/lib/cassandra/0.7/columns.rb:19:in column_family_property' /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/lib/cassandra/columns.rb:20:in
column_name_class_for_key'
/usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/lib/cassandra/0.7/columns.rb:11:in column_name_class' /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/lib/cassandra/helpers.rb:20:in
extract_and_validate_params'
/usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.9.0/lib/cassandra/cassandra.rb:113:in `insert'
Hello,
The function add_column_family is not documented.
Could you tell how to use it?
Thanks a lot in advance
Sebastien Druon
need to require 'pp'
cf jberkel/cassandra@4b9a05a6de362e12eef273567175f40decb5ef0b
>> client.remove :Foo, "bar", "baz" NoMethodError: undefined method `validate' for 1281395191953732:Fixnum from /usr/local/lib/ruby/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/client.rb:35:in `write' from /usr/local/lib/ruby/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/client.rb:35:in `send_message' from /workspace/vendor/plugins/cassandra/lib/../vendor/0.7/gen-rb/cassandra.rb:179:in `send_remove' from /workspace/vendor/plugins/cassandra/lib/../vendor/0.7/gen-rb/cassandra.rb:174:in `remove' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:67:in `send' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:67:in `send_rpc' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:164:in `send_rpc' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:63:in `proxy' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:154:in `proxy' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:53:in `handled_proxy' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:150:in `handled_proxy' from /workspace/vendor/plugins/thrift_client/lib/thrift_client/abstract_thrift_client.rb:23:in `remove' from /workspace/vendor/plugins/cassandra/lib/cassandra/0.7/protocol.rb:12:in `_remove' from /workspace/vendor/plugins/cassandra/lib/cassandra/cassandra.rb:146:in `remove' from (irb):1
I started Cassandra 0.6 using standard instructions on cassandra web site (haven't used cassandra_helper script to do this). After this I installed cassandra gem and here is what I typed in irb:
require 'cassandra'
client = Cassandra.new('Twitter', '127.0.0.1:9160')
client.insert(:Users, "5", {'screen_name' => "buttonscat"})
I got :
Cassandra::AccessError: Keyspace "Twitter" not found. Available: ["Keyspace1", "system"]
Should I somehow create keyspace before using it? I thought that cassandra can dinamicly create such things.
Judging from the changelog on the latest release (which was a few hours ago), BatchMutation was merged into batch_insert.
I've poked a few pieces of cassandra/cassandra.rb and found that replacing CassandraThrift.BatchMutation.new roughly with @client.batch_insert seems to work.
I may pull a patch together, but thought it was worth reporting in the meantime.
Hi!
Using gem install, the installed version is 0.8.2, but the last version is 0.10.0.
Why is it so?
Thanks for the answer
Regards,
Sebastien
I'd done something completely stupid, and left my data in the test folder. When I upgraded the gem, the test folder got overwritten, and I lost my data.
Not sure if it's worth dealing with - but some sort of warning or note in the instructions about this probably wouldn't hurt. "Don't use the test folder for your data, as it will get overwritten when you update the gem."
It seems regardless of the parameters I supply it always complains about the wrong number of arguments
>> CASSANDRA.count_columns :Foo, "bar" ArgumentError: wrong number of arguments (3 for 4) from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in 'get_count' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in 'send' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in 'send_rpc' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:161:in 'send_rpc' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:60:in 'proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:151:in 'proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:53:in 'handled_proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:147:in 'handled_proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:23:in 'get_count' from /app/releases/20090716234923/vendor/plugins/cassandra/lib/cassandra/0.7/protocol.rb:16:in '_count_columns' from /app/releases/20090716234923/vendor/plugins/cassandra/lib/cassandra/cassandra.rb:156:in 'count_columns' from (irb):84 >> CASSANDRA.count_columns :Foo, "bar", "baz" ArgumentError: wrong number of arguments (3 for 4) from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in 'get_count' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in 'send' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in 'send_rpc' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:161:in 'send_rpc' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:60:in 'proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:151:in 'proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:53:in 'handled_proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:147:in 'handled_proxy' from /app/releases/20090716234923/vendor/plugins/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:23:in 'get_count' from /app/releases/20090716234923/vendor/plugins/cassandra/lib/cassandra/0.7/protocol.rb:16:in '_count_columns' from /app/releases/20090716234923/vendor/plugins/cassandra/lib/cassandra/cassandra.rb:156:in 'count_columns' from (irb):84
Hi,
there are no tests available for cassandra/0.7.
I'd offer to contribute tests for the whole 0.7 branch stuff but I prefer RSpec. Is this okay?
Regards
Using a nonexistent keyspace gives a stack overflow error, instead of an AccessError as is intended.
Commit at http://github.com/stephenjudkins/cassandra/commit/4bb123dee625bfb22105b0ec8acb3682df1a780c fixes this and adds a test. Pull request has been sent.
I'd like to be able to access the timestamp value as it is somewhat equivalent to Rails' updated_at field.
When I use Cassandra gem, I get this:
>> c = Cassandra.new('Onespot', 'removed:9160')
>> c.get(:ImageInfo, '0c8f0d9a9a64bb050d75e803d2d2cf7739c34fff')
=> {"02912452fc37dde56faf7474994b05f40594255c"=>"1", "selected"=>"02912452fc37dde56faf7474994b05f40594255c"}
But Cassandra's CLI gives me access:
cassandra> get Onespot.ImageInfo['0c8f0d9a9a64bb050d75e803d2d2cf7739c34fff']
=> (column=selected, value=02912452fc37dde56faf7474994b05f40594255c, timestamp=1267583251726377)
=> (column=02912452fc37dde56faf7474994b05f40594255c, value=1, timestamp=1267583251726377)
Returned 2 results.
I'd like to see an API that surfaces this info if possible.
Seems like something broke along the way...
How to reproduce:
"show keyspaces" in cassandra-cli shows the default keyspace:
connect localhost/9160
Connected to: "Test Cluster" on localhost/9160
[default@unknown] show keyspaces
Keyspace: system:
Replication Factor: 1
Column Families:
Trying to get all keyspaces with ruby means doesn't work:
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'cassandra'
=> true
irb(main):003:0> client = Cassandra.new 'system', '127.0.0.1:9160'
=> #<Cassandra:-610502768, @keyspace="system", @Schema={}, @servers=["127.0.0.1:9160"]>
irb(main):004:0> client.keyspacesCassandraThrift::Cassandra::Client::TransportException: CassandraThrift::Cassandra::Client::TransportException
from /var/lib/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/transport/socket.rb:119:in 'read'from /var/lib/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/transport/buffered_transport.rb:50:in 'read'
from /var/lib/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/transport/base_transport.rb:52:in 'read_all'
from /var/lib/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/protocol/binary_protocol.rb:186:in 'read_i32'
from /var/lib/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/protocol/binary_protocol.rb:111:in
'read_message_begin'from /var/lib/gems/1.8/gems/thrift-0.2.0.4/lib/thrift/client.rb:45:in 'receive_message'
from /var/lib/gems/1.8/gems/cassandra-0.8.2/lib/../vendor/gen-rb/cassandra.rb:236:in 'recv_get_string_property'
from /var/lib/gems/1.8/gems/cassandra-0.8.2/lib/../vendor/gen-rb/cassandra.rb:228:in 'get_string_property'
from /var/lib/gems/1.8/gems/thrift_client-0.5.0/lib/thrift_client/abstract_thrift_client.rb:115:in 'send'
from /var/lib/gems/1.8/gems/thrift_client-0.5.0/lib/thrift_client/abstract_thrift_client.rb:115:in 'handled_proxy'
from /var/lib/gems/1.8/gems/thrift_client-0.5.0/lib/thrift_client/abstract_thrift_client.rb:57:in 'get_string_property'
from /var/lib/gems/1.8/gems/cassandra-0.8.2/lib/cassandra/cassandra.rb:302:in 'all_nodes'
from /var/lib/gems/1.8/gems/cassandra-0.8.2/lib/cassandra/cassandra.rb:285:in 'reconnect!'
from /var/lib/gems/1.8/gems/cassandra-0.8.2/lib/cassandra/cassandra.rb:280:in 'client'
from /var/lib/gems/1.8/gems/cassandra-0.8.2/lib/cassandra/cassandra.rb:86:in 'keyspaces'
The exact same ruby code from above works with cassandra-0.6.6.
Ruby version:
ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
OS:
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"
Gem Version:
gem list cassandra
LOCAL GEMS
cassandra (0.8.2)
Cassandra is considered to be very fast. I have made little benchmark using ruby 1.9.2 (not release, but almost)
I have NewKeyspace keyspace and this is the value that Standard2 column has:
[default@NewKeyspace] get Standard2['jsmith']['first']
=> (column=first, value=John, timestamp=1282036446068000)
I was actually able to get this value using cassandra gem:
ruby-1.9.2-head > client.get(:Standard2, 'jsmith')
=> {"first"=>"John"}
And here is the performance:
ruby-1.9.2-head > Benchmark.measure { 900.times {client.get(:Standard2, 'jsmith') }}
=> 0.750000 0.050000 0.800000 ( 1.183909)
Is it ok? Am I doing something wrong? 900 requests per second isn't too much (considering that this value should be cached and it's just key-value storage)
I am running Ubuntu 10.04, My laptop isn't super powerfull (2x 1.8 Centrino Duo with 2.5 Gb or RAM), but I think that it should work faster.
>> twitter.get_range(:Timeline, :count => 1).length => 2 >> twitter.get_range(:Timeline, :count => 10).length => 2 >> twitter.get_range(:Timeline, :count => -1).length => 2
0.7 adds the ability to optional include a TTL option when inserting columns. This should be pretty trivial to include
I'm just trying to verify if Cassandra has a particular key in the keyspace.
>> require 'cassandra'
>> c = Cassandra.new 'Onespot', 'localhost:9160'
>> c.exists?(:UrlInfo, 'foo')
Thrift::ProtocolException: Required field start is unset!
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/cassandra-0.8.2/lib/../vendor/gen-rb/cassandra_types.rb:304:in `validate'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift-0.2.0.2/lib/thrift/client.rb:35:in `write'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift-0.2.0.2/lib/thrift/client.rb:35:in `send_message'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/cassandra-0.8.2/lib/../vendor/gen-rb/cassandra.rb:92:in `send_multiget_slice'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/cassandra-0.8.2/lib/../vendor/gen-rb/cassandra.rb:87:in `multiget_slice'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in `send'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:64:in `send_rpc'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:161:in `send_rpc'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:60:in `proxy'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:151:in `proxy'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:53:in `handled_proxy'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:147:in `handled_proxy'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/thrift_client-0.4.3/lib/thrift_client/abstract_thrift_client.rb:23:in `multiget_slice'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/cassandra-0.8.2/lib/cassandra/protocol.rb:69:in `_multiget'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/cassandra-0.8.2/lib/cassandra/cassandra.rb:216:in `exists?'
Cassandra fails to install because Thrift appears broken when trying to build
I am running on Ubuntu 9.04 and not sure what I need to do to fix this.
Here is the output from the install of the Thrift gem:
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/thrift-0.0.810255.1# ruby setup.rb
---> lib
---> lib/thrift
---> lib/thrift/server
<--- lib/thrift/server
---> lib/thrift/transport
<--- lib/thrift/transport
---> lib/thrift/serializer
<--- lib/thrift/serializer
---> lib/thrift/core_ext
<--- lib/thrift/core_ext
---> lib/thrift/protocol
<--- lib/thrift/protocol
<--- lib/thrift
<--- lib
---> ext
/usr/local/ruby-1.9.1-p243/bin/ruby /usr/local/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/thrift-0.0.810255.1/ext/extconf.rb
checking for strlcpy() in string.h... yes
creating Makefile
<--- ext
---> lib
---> lib/thrift
---> lib/thrift/server
<--- lib/thrift/server
---> lib/thrift/transport
<--- lib/thrift/transport
---> lib/thrift/serializer
<--- lib/thrift/serializer
---> lib/thrift/core_ext
<--- lib/thrift/core_ext
---> lib/thrift/protocol
<--- lib/thrift/protocol
<--- lib/thrift
<--- lib
---> ext
make
gcc -I. -I/usr/local/ruby-1.9.1-p243/include/ruby-1.9.1/i686-linux -I/usr/local/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward -I/usr/local/ruby-1.9.1-p243/include/ruby-1.9.1 -I/usr/local/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/thrift-0.0.810255.1/ext -DHAVE_STRLCPY -D_FILE_OFFSET_BITS=64 -fPIC -g -O2 -Wall -Werror -o struct.o -c struct.c
cc1: warnings being treated as errors
struct.c: In function ‘get_field_value’:
struct.c:286: error: implicit declaration of function ‘strlcpy’
make: *** [struct.o] Error 1
setup.rb:655:in command': system("make") failed (RuntimeError) from setup.rb:664:in
make'
from setup.rb:1258:in setup_dir_ext' from setup.rb:1532:in
block in traverse'
from setup.rb:1549:in dive_into' from setup.rb:1530:in
traverse'
from setup.rb:1524:in block in exec_task_traverse' from setup.rb:1519:in
each'
from setup.rb:1519:in exec_task_traverse' from setup.rb:1246:in
exec_setup'
from setup.rb:996:in exec_setup' from setup.rb:813:in
invoke'
from setup.rb:773:in invoke' from setup.rb:1578:in
I'm not sure this lives here really, but in a few related places the documentation suggestions specifying the IP and Port like this:
Cassandra.new('twitter', '127.0.0.1', 9160)
This particular instance is in from Evan's docs at http://blog.evanweaver.com/files/doc/fauna/cassandra/classes/Cassandra.html
The implementation of == in Cassandra::Comparable assumes that it's being used to compare with other Comparables, however this isn't always the case, currently uuid == false fails with an error:
Don't you know how can I create native secondary indexes for Cassandra 0.7?
I'm sorry.
I can speak English only a little.
However, I question.
Are there any reasons though schema method is protected?
Actually, the application that obtains the ColumnFamily list is made, and I want to use schema method.
Does not the problem occur even if this is used?
the keySpace is Examine
the CF is
I have doing:
conn.insert(:Ranks, "tmprank", {"1" => ... , "2"=>... "3" => ....})
conn.get_columns(:Ranks, "tmprank")
It throw
CassandraThrift::InvalidRequestException: CassandraThrift::InvalidRequestException
from /opt/ruby/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/../vendor/gen-rb/cassandra.rb:62:in recv_get_slice' from /opt/ruby/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/../vendor/gen-rb/cassandra.rb:52:in
get_slice'
from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:60:in send' from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:60:in
send_rpc'
from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:156:in send_rpc' from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:56:in
proxy'
from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:146:in proxy' from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:49:in
handled_proxy'
from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:142:in handled_proxy' from /opt/ruby/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:23:in
get_slice'
from /opt/ruby/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/protocol.rb:30:in _get_columns' from /opt/ruby/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:175:in
get_columns'
from (irb):16
my env is
cassandra server 0.6 rc1
ruby gems
cassandra 0.8.1
thrift 0.2.0
thrift_client 0.4.1
And How can I get_range to get keys with LongType?
When I set it to LongType
I get_range will be []
But touch the cassandra, I feel good.
Thx to this lib.
When cassanda gem tryies to find other cassandras though all_nodes it'll return 127.0.0.1 and won't work. That happes because single cassandra will think it's primary seed as 127.0.0.1. Putting in Seed hostname or ip address of interface does't work.
The problem arives only using single node from machine other than where cassandra installed. When two or more cassandras gossip they tell each other ip addresses of external interface of each other, so all_nodes will return valid result.
hi,
doing
client.insert(:Standard2, "bob", {"nom" => "bob", "age" => 41})
get
gems/thrift-0.2.0.4/lib/thrift/protocol/binary_protocol.rb:106:in write_string': undefined method
length' for 41:Fixnum (NoMethodError)
from /home/Tophe/.rvm/gems/ruby-1.9.2-p0@rails3/gems/thrift-0.2.0.4/lib/thrift/client.rb:35:in write' from /home/Tophe/.rvm/gems/ruby-1.9.2-p0@rails3/gems/thrift-0.2.0.4/lib/thrift/client.rb:35:in
send_message'
from /data/work/cassendra/cassandra/vendor/0.6/gen-rb/cassandra.rb:215:in send_batch_mutate' from /data/work/cassendra/cassandra/vendor/0.6/gen-rb/cassandra.rb:210:in
batch_mutate'
from /home/Tophe/.rvm/gems/ruby-1.9.2-p0@rails3/gems/thrift_client-0.5.0/lib/thrift_client/abstract_thrift_client.rb:115:in handled_proxy' from /home/Tophe/.rvm/gems/ruby-1.9.2-p0@rails3/gems/thrift_client-0.5.0/lib/thrift_client/abstract_thrift_client.rb:57:in
batch_mutate'
from /data/work/cassendra/cassandra/lib/cassandra/0.6/protocol.rb:8:in _mutate' from /data/work/cassendra/cassandra/lib/cassandra/cassandra.rb:130:in
insert'
from tx_cassandra.rb:25:in `
I believe this code in cassandra.rb does not respect the @servers parameter:
def new_client
thrift_client_class.new(CassandraThrift::Cassandra::Client, @servers, @thrift_client_options)
end
It seems to return a client which uses the default localhost value for @servers, which causes this to happen:
irb(main):005:0> cass = Cassandra.new(:OtherInbox,"10.208.130.191:9160")
=> #<Cassandra:77305550, @keyspace=:OtherInbox, @Schema={}, @servers=["10.208.130.191:9160"]>
irb(main):006:0> cass.instance_eval { @servers }
=> ["10.208.130.191:9160"]
irb(main):007:0> cass.get(:MerchantDomains,'example.com')
ThriftClient::NoServersAvailable: No live servers in ["127.0.0.1:9160"] since Wed Apr 07 14:11:45 +0000 2010.
from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:124:in next_server' from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:102:in
connect!'
from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:183:in connect!' from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:55:in
proxy'
from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:146:in proxy' from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:49:in
handled_proxy'
from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:142:in handled_proxy' from /usr/local/lib/ruby/gems/1.8/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:23:in
get_string_list_property'
from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:286:in check_keyspace' from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:282:in
reconnect!'
from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:275:in client' from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:270:in
schema'
from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/columns.rb:31:in column_family_property' from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/columns.rb:20:in
column_name_class_for_key'
from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/columns.rb:12:in column_name_class' from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/helpers.rb:20:in
extract_and_validate_params'
from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:197:in multi_get' from /usr/local/lib/ruby/gems/1.8/gems/cassandra-0.8.1/lib/cassandra/cassandra.rb:190:in
get'
from (irb
irb(main):009:0> cass.instance_eval { @servers }
=> ["127.0.0.1:9160"]
I am working on a patch but dont' fully understand how the thrift client works; thought I'd post here first in case this is already known to you.
[6:36pm] brett_: fwiw, ruby1.9 + snow_leopard + cassandra gem == https://gist.github.com/3b21e5aca7f9bf3d2f83
[6:36pm] brett_: will investigate shortly
[6:37pm] evn: damn you thrift
[6:37pm] evn: look for a thrift ruby 1.9 compat thing
[6:37pm] brett_: -Werror is almost always the wrong answer, imho
[6:46pm] brett_: fwiw: rb_raise(rb_eStandardError, str); should be rb_raise(rb_eStandardError, "%s", str);
[6:46pm] brett_: fin.
[6:46pm] evn: is that it?
[6:46pm] brett_: yeah, that fixes thrift
[6:47pm] brett_: gcc got pedantic at some point.
[6:47pm] evn: ok maybe i can find a magic checkout
[6:47pm] evn: that has that
[6:47pm] evn: otherwise i can just hack the gem
When using the git version of cassandra with bundler I get this error on bundle install:
Installing cassandra (0.7.6) from git://github.com/fauna/cassandra.git (at master) /usr/local/lib/site_ruby/1.8/rubygems/security.rb:759:in `read': No such file or directory - /Users/ryan/.gemkeys/gem-private_key.pem (Errno::ENOENT)
We'd like to use yajl-ruby's JSON gem compatibility API instead of the json gem. Would it be possible to remove the explicit dependency and just check for defined?(JSON) upon startup? Or remove the need for JSON at all (I noticed it's only used in one place)?
Question rather than a bug: what's the recommended approach for using this gem and load-balancing requests against a cassandra cluster for reads/writes?
Going through the source, it looks like all the connection magic is delegated to thrift_client, which in turn simply connects to a single server by default and sends all requests there (unless server_max_requests is set, at which point it reconnects to next server after issuing that number of requests?)
With auto-discovery on, we pass in the array of servers into thrift-client, but I don't see any shuffle logic, etc. Does this mean we're always connecting to the same instance by default?
Thoughts on using a load-balancer instead of built-in logic? Such as HAProxy? Some docs would be helpful on this.
Here is the ruby code I used:
require 'rubygems'
require 'cassandra/0.7'
include SimpleUUID
new_keyspace = Cassandra.new('NewKeyspace')
user = {'screen_name' => 'buttonscat'}
new_keyspace.insert('Standard2', 'jdoe', user)
As a result I get following error: http://pastie.org/1097589. (I really have NewKeyspace and Standard2 column family. I have created them manually and I could work with them through cassandra-cli). I created gem from the github master branch repository and have installed it.
Hi There,
I've found a little problem in cassandra.rb:
unless Cassandra.methods.include?("VERSION")
you should pass a symbol to include?, like this:
unless Cassandra.methods.include?(:VERSION)
or
unless Cassandra.respond_to?(VERSION)
otherwise 0.6 is always included for me.
best,
Tobi
Evan pushed a commit to thrift-rb this weekend that enables support for JRuby. With that in place, I am able to package and install cassandra gem under JRuby if I swap out 'json' for 'json-jruby'. I tried a couple of quick changes ("if defined?(JRUBY_VERSION) 'json-jruby' else 'jruby'") to the Echoe spec to enable automatic support for JRuby. However, nothing worked to satisfaction (i.e. package and install under both JRuby and MRI). I think the most straight-forward method maybe to create two separate specs for the two versions. Anyone have any other ideas?
Thrift_client has a public disconnect! method but Cassandra does not provide a close or disconnect method to wrap it. You can do this:
c = Cassandra.new(...)
c.client.disconnect!
But that's full of dangers (doesn't set @client to nil, creates the connection first if it doesn't exist, etc)
batch_mutate is only in Cassandra 0.6. Since 0.6 hasn't even been generally released yet, I think it would be nice to use the 0.5 API for a while where possible. Here's the API wiki page so you can verify any other API changes: http://wiki.apache.org/cassandra/API
qanat.4.log:Hoptoad: Thrift::ApplicationException: Invalid method name: 'batch_mutate'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift-0.0.810255.1/lib/thrift/client.rb:58:in `handle_exception'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift-0.0.810255.1/lib/thrift/client.rb:46:in `receive_message'
qanat.4.log:/home/onespot/.bundle/ruby/1.9.1/gems/cassandra-0.7.6/vendor/gen-rb/cassandra.rb:219:in `recv_batch_mutate'
qanat.4.log:/home/onespot/.bundle/ruby/1.9.1/gems/cassandra-0.7.6/vendor/gen-rb/cassandra.rb:211:in `batch_mutate'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:60:in `send_rpc'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:156:in `send_rpc'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:56:in `proxy'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:146:in `proxy'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:49:in `handled_proxy'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:142:in `handled_proxy'
qanat.4.log:/home/onespot/.bundle/ruby/1.9.1/gems/thrift_client-0.4.1/lib/thrift_client/abstract_thrift_client.rb:23:in `batch_mutate'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/cassandra-0.7.6/lib/cassandra/protocol.rb:8:in `_mutate'
qanat.4.log-/home/onespot/.bundle/ruby/1.9.1/gems/cassandra-0.7.6/lib/cassandra/cassandra.rb:110:in `insert'
Hi,
I'm not sure if this is a problem with the Cassandra gem, the Thrift gem, Thrift, or Cassanda, but I'll start at the top and work down ;-)
My script is as follows:
require 'rubygems'
require 'cassandra'
require 'simple_uuid'
include SimpleUUID
client = Cassandra.new 'MyKeyspace', '127.0.0.1:9160'
client.clear_keyspace!
def random_string length = 20
chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'
string = ''
length.times do
string << chars[rand(chars.size)]
end
string
end
count = 0
last_uuid = nil
while true
count += 1
print '.' if count % 1000 == 0
client.get : MyData, last_uuid unless last_uuid.nil?
current_uuid = UUID.new.to_guid
client.insert : MyData, current_uuid, {
'data_0' => random_string,
# snip
'data_9' => random_string
}
last_uuid = current_uuid
end
After about a minute:
/lib/ruby/gems/1.9.1/gems/thrift-0.2.0.2/lib/thrift/transport/socket.rb:108:in `read': Socket: Timed out reading 4096 bytes from 127.0.0.1:9160 (Thrift::TransportException)
The exception is not raised when I omit the data columns.
I am using Cassandra 0.6.1 and the Cassandra gem 0.8.2.
Any help much appreciated.
Hi,
Im trying to get the contents of an entire ColumnFamily. For that I am using get_range but this returns to me an key_slice array. Is there any method to convert this array to an OrderedHash?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.