Ruby client for HBase's Stargate web service
Ruby
Latest commit 0754675 Nov 26, 2011 @greglu Decided to make the timestamp definitions explicit, instead of conver…
…ting from seconds to milliseconds underneath. This is because reading back a row whose timestamp you defined will give back a different value, and that's strange behaviour.
Failed to load latest commit information.
lib
spec Decided to make the timestamp definitions explicit, instead of conver… Nov 26, 2011
.gitignore
Gemfile
Gemfile.lock
History.txt
LICENSE
README.textile
Rakefile
hbase-stargate.gemspec Updated gemspec file Nov 4, 2011

README.textile

hbase-stargate

A Ruby client for HBase (http://hadoop.apache.org/hbase) that works with the REST (previously known as Stargate) interface. The RESTful web service front end for HBase can serve up a number of formats including XML, JSON, and protobufs.

This project is based off the work of Dingding Ye <yedingding@gmail.com> at http://github.com/sishen/hbase-ruby

Installation

$ gem install hbase-stargate

To work with this gem in your Rails application, add this to the environment.rb file:

config.gem 'hbase-stargate', :lib => "stargate"

To build the gem yourself:

$ rake build

Getting Started

  1. Download and unpack the most recent release of HBase from http://hadoop.apache.org/hbase/releases.html#Download
  2. Edit /conf/hbase-env.sh and uncomment/modify the following line to correspond to your Java home path:
    export JAVA_HOME=/usr/lib/jvm/java-6-sun
  3. Start up HBase:
    $ /bin/start-hbase.sh
  4. Start up Stargate (append “-p 1234” at the end if you want to change the port):
    $ /bin/hbase rest start

Usage

Here are some examples:


require 'stargate'

# Direct connection
# client = Stargate::Client.new("http://localhost:8080") # this url is the default for stargate.
# Connection through a proxy
client = Stargate::Client.new("http://localhost:8080", { :proxy => "10.2.3.4:8080" }) 

# Table Operation
tables = client.list_tables                              # list available tables
table = client.create_table('users', 'habbit')           # create a table whose column_family is habbit
table = client.show_table('users')                       # show the meta info of table users 
client.delete_table('users')                             # delete 'users' table

# Row Operation
row = client.show_row('users', 'sishen')                 # show the data of row 'sishen' in table 'users'
row2 = client.create_row('users', 'sishen', Time.now.to_i, {:name => 'habbit:football', :value => 'i like football'}) # create the row 'sishen' with the data in the table 'users'
client.delete_row('users', 'sishen', nil, 'habbit:football')  # delete the row 'sishen' of table 'users' with the optional column 'habbit:football'

# Scanner Operation (see spec/stargate-client/operation/scanner_operation_spec.rb for more examples)
scanner = client.open_scanner('users', {:start_row => "row2", :batch => 5, :columns => ["habbit:"]}) # See more options from Stargate::Model::Scanner.AVAILABLE_OPTS
rows = client.get_rows(scanner)
client.close_scanner(scanner)

Testing

Run the specs with the following rake task:

$ rake spec

or pass it the URL to the HBase Stargate server as an argument:

$ rake spec STARGATE_URL=http://localhost:8080

Copyright

Copyright © 2008 Openplaces.org
Distributed under MIT License