Project

hbase-rb

0.01
No commit activity in last 3 years
No release in over 3 years
Everything you need to build a Ruby client for HBase
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0.7.0
 Project Readme

HBase For Ruby Made Easy

To use HBase with Apache Thrift, you might have to manually generate Ruby code from generic *.thrift files.

This gem tries to alleviate that slight annoyance by packaging everything you need to communicate with HBase.

Installation

Bundler

Add to Gemfile and run bundle install:

gem 'hbase-rb'

Without Bundler

Install the gem:

gem install hbase-rb

Require it explicitly in your scripts:

require "rubygems"
require "hbase-rb"

Versioning

The version of the gem matches the version of HBase the interface was generated against.

For instance, when using HBase 0.90.4:

gem 'hbase-rb', '0.90.4'

Usage

This library simply exposes the generated Ruby code from Thrift. Therefore it is not necessarily very idiomatic Ruby.

For example:

socket    = Thrift::Socket.new('localhost', 9090)

transport = Thrift::BufferedTransport.new(socket)
transport.open

protocol  = Thrift::BinaryProtocol.new(transport)
client    = HBase::Client.new(protocol)

puts client.getTableNames

Writing Rows

# Assuming a table "mytable" and a column family "c"
client.mutateRow("mytable", "abc123", [HBase::Mutation.new(column: "c:foo", value: "bar")])

Reading Rows

# Assuming a table "mytable" and a column family "c"
results = client.getRow("mytable", "abc123")
if result = results.first
  result.columns.each do |key, cell|
    puts "#{key}: #{cell.value}"
  end
end

API Reference