Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby client for HBase's Stargate web service
Ruby
Branch: 1.6.0
Pull request Compare This branch is 8 commits ahead, 14 commits behind master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
Gemfile.lock
History.txt
LICENSE
README.textile
Rakefile
hbase-stargate.gemspec

README.textile

hbase-stargate

A Ruby client for HBase (http://hadoop.apache.org/hbase) that works with the Stargate interface.
Stargate is the RESTful web service front end for HBase that 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 -s http://gemcutter.org

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

config.gem 'hbase-stargate', :lib => "stargate", :source => "http://gemcutter.org"

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. Copy /contrib/stargate/hbase--stargate.jar into /lib
  4. Copy all the files in the /contrib/stargate/lib folder into /lib
  5. Start up HBase:
    $ /bin/start-hbase.sh
  6. Start up Stargate (append “-p 1234” at the end if you want to change the port):
    $ /bin/hbase org.apache.hadoop.hbase.stargate.Main

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

Something went wrong with that request. Please try again.