Project

hbase2-rb

0.0
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

~> 10.0

Runtime

~> 0.9.3
 Project Readme

Hbase Thrift2 interface for Ruby

inspired by https://github.com/highgroove/hbase-rb

Installation

Bundler

Add to Gemfile and run bundle install:

gem 'hbase2-rb'

Without Bundler

Install the gem:

gem install hbase2-rb

Require it explicitly in your scripts:

require "rubygems"
require "hbase2-rb"

Versioning

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

For instance, when using HBase 1.2.0:

gem 'hbase-rb', '~> 1.2.0'

Usage

For example:

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

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

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

Writing Rows

# Assuming a table "mytable" and a column family "c"
column_value = HBase2::TColumnValue.new
column_value.family = 'c'
column_value.qualifier = 'foo'
column_value.value = 'bar'
put = HBase2::TPut.new row: 'abc123', columnValues: [column_value]
client.put('mytable', put)

Reading Rows

# Assuming a table "mytable" and a column family "c"
get = HBase2::TGet.new row: 'abc123'
result = client.get('mytable', get)
if result.row
  result.columnValues.each do |column|
    puts "#{column.family}:#{column.qualifier} #{column.value}"
  end
end

API Reference