public
Description: ruby client for Hadoop HBase
Homepage: http://sishen.lifegoo.com
Clone URL: git://github.com/sishen/hbase-ruby.git
Ye Dingding (author)
Sun Mar 08 11:23:11 -0700 2009
commit  2b483ccc9137084e4ca49c414f64542e55b61d05
tree    801a7f5cea4f5327d93cbb17d4cb516983b2e500
parent  ba430d6090f86c1ed9958ad27eca55df5b9b1cd7
name age message
file .gitignore Fri Sep 26 01:04:54 -0700 2008 add .gitigonre file [kaichen]
file History.txt Tue Oct 14 21:32:17 -0700 2008 update History [yong]
file MIT-LICENSE Mon Jul 28 09:30:19 -0700 2008 row delete [sishen]
file Manifest.txt Tue Oct 14 21:59:48 -0700 2008 add scanner.rb and scanner_response.rb [yong]
file README.textile Loading commit data...
file Rakefile Sun Oct 26 09:37:21 -0700 2008 table alter enhance: need HBase-960 patch [Ye Dingding]
file hbase-ruby.gemspec
directory lib/
directory spec/
directory tasks/
README.textile

hbase-ruby is a pure ruby client for HBase (http://hadoop.apache.org/hbase). It works with the most recent version of HBase REST interface.

Versions

  • “hbase-0.20dev version”: http://github.com/sishen/hbase-ruby/tree/master
  • “hbase-0.19 version”: http://github.com/sishen/hbase-ruby/tree/hbase-0.19

INSTALLTION

$gem sources -a http://gems.github.com
$gem install sishen-hbase-ruby

For those who wants to use hbase in their rails application, can add this line to the environment.rb:
{{{
config.gem ‘sishen-hbase-ruby’, :lib => “hbase”, :source => “http://gems.github.com”
}}}

To build the gem yourself:

$rake gem

USAGE

First download the recent version of hbase (svn checkout http://svn.apache.org/repos/asf/hadoop/hbase/trunk hbase), compile it with ‘ant’, then launch HBase server:

$bin/start-hbase.sh

Here is the example:
{{{
require ‘hbase’

client = HBase::Client.new(“http://localhost:60010/api”) # this url is the default.

  1. 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.disable_table(‘users’) # disable table users
    client.enable_table(‘users’) # enable table users
    client.delete_table(‘users’) # delete table users
  1. 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’
  1. Scanner Operation
    scanner = client.open_scanner(‘users’, ‘habbit:’)
    rows = client.get_rows(scanner)
    client.close_scanner(scanner)
    }}}

Testing

First you want to install rspec gem:

{{{
sudo gem install rspec
}}}

Now, you can run the spec by following rake task:

{{{
rake hbase
}}}

Copyright

Copyright © 2008 Dingding Ye <yedingding@gmail.com>
Distributed under MIT License