Ruby client for HBase's Stargate web service
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.



A Ruby client for 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 <> at


$ 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
  2. Edit /conf/ 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/
  4. Start up Stargate (append “-p 1234” at the end if you want to change the port):
    $ /bin/hbase rest start


Here are some examples:

require 'stargate'

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

# 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',, {: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)


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 © 2008
Distributed under MIT License