A Cassandra client for JRuby, backed by Hector.
cluster = Hector.cluster("Hector", "127.0.0.1:9160")
ks_name = java.util.UUID.randomUUID.to_s.gsub("-","")
client = Hector.new(nil, @cluster, :retries => 2, :exception_classes => [])
column_families = [{:name =>"a"}, {:name => "b", :type => :super}]
client.add_keyspace({:name => ks_name, :strategy => :local, :replication => 1, :column_families => column_families})
client.keyspace = ks_name
sopts = {:n_serializer => :string, :v_serializer => :string, :s_serializer => :string}
client.put_row("a", "row-key", {"k" => "v"})
client.get_rows("a", ["row-key"], sopts) # => {"row-key" => {'k' => 'v'}}
client.get_columns("a", "row-key", ["k"], sopts) # => {'k' => 'v'}
client.put_row("b", "row-key",
{ "SuperCol" => {"k" => "v", "k2" => "v2"},
"SuperCol2" => {"k" => "v", "k2" => "v2"} })
client.get_super_columns("b", "row-key", "SuperCol", ["k2"], sopts) # => {"k2" => "v2"}
For more examples, see the tests.
hector.rb started as a fork of the cassandra
gem. However the
API is now similar to clj-hector
.
We may make this gem API compatible with the cassandra
gem in
the future.
- https://github.com/pingles/clj-hector
- http://prettyprint.me/2010/02/23/hector-a-java-cassandra-client/
- https://github.com/fauna/cassandra
Nate Murray [email protected] http://www.xcombinator.com