0.05
Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A Ruby client used to interact with HBase through its Stargate web service front-end
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

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