Hector-based Cassandra client for JRuby
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
spec
.gitignore
.rspec
Gemfile
README.mkd
Rakefile
hector.gemspec
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