Skip to content

Instantly share code, notes, and snippets.

@shigaku
Created July 10, 2010 14:46
Show Gist options
  • Select an option

  • Save shigaku/470750 to your computer and use it in GitHub Desktop.

Select an option

Save shigaku/470750 to your computer and use it in GitHub Desktop.
Using Cassandra on Mac OS X with Ruby
#!/usr/bin/ruby
$KCODE='u'
require 'cassandra'
transport = Thrift::BufferedTransport.new(Thrift::Socket.new("127.0.0.1","9160"))
transport.open
client = CassandraThrift::Cassandra::Client.new(Thrift::BinaryProtocol.new(transport))
puts client.describe_version()
columnpath = CassandraThrift::ColumnPath.new
columnpath.column_family = "Super1"
columnpath.super_column = "sample1"
columnpath.column = "foo"
n=1000
time_start = Time.now
while n>0
client.insert("Keyspace1",
"super_sample#{n}",
columnpath,
"test#{n}",
Time.now.to_i,
CassandraThrift::ConsistencyLevel::ZERO)
#c = client.get("Keyspace1",
# "super_sample#{n}",
# columnpath,
# CassandraThrift::ConsistencyLevel::ONE)
# puts c.column.value
n-=1
end
time_end = Time.now
duration = (time_end-time_start)
qps = 1000/duration
puts "START : #{time_start}"
puts "END : #{time_end}"
puts "DURATION : #{duration}sec."
puts "QPS : #{qps}"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment