Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby client for HBase's Stargate web service

branch: master

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.
latest commit 075467501a
Greg Lu authored
Octocat-spinner-32 lib Decided to make the timestamp definitions explicit, instead of conver… November 26, 2011
Octocat-spinner-32 spec Decided to make the timestamp definitions explicit, instead of conver… November 26, 2011
Octocat-spinner-32 .gitignore Started documentation with Yard November 20, 2011
Octocat-spinner-32 Gemfile Bumped to version 1.6.0 November 04, 2011
Octocat-spinner-32 Gemfile.lock Bumped to version 1.6.0 November 04, 2011
Octocat-spinner-32 History.txt Bumped to version 1.6.0 November 04, 2011
Octocat-spinner-32 LICENSE Updates for JRuby compatibility January 18, 2010
Octocat-spinner-32 README.textile Bumped to version 1.6.0 November 04, 2011
Octocat-spinner-32 Rakefile Updated for Ruby 1.9 and now using the yajl json parsing library November 02, 2011
Octocat-spinner-32 hbase-stargate.gemspec Updated gemspec file November 04, 2011
README.textile

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

Something went wrong with that request. Please try again.