Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Hector-based Cassandra client for JRuby

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.mkd
Octocat-spinner-32 Rakefile
Octocat-spinner-32 hector.gemspec
Octocat-spinner-32 pom.xml
README.mkd

hector.rb

A Cassandra client for JRuby, backed by Hector.

Usage

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.

History

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.

References

Author

Nate Murray nate@natemurray.com http://www.xcombinator.com

Something went wrong with that request. Please try again.