Skip to content

sishen/hbase-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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.

# 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

# 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
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 <[email protected]>
Distributed under MIT License

About

ruby client for Hadoop HBase

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages