Coder Social home page Coder Social logo

ok_hbase's Introduction

ok_hbase

Welcome HBase cowboys.

Read the pages site!

Installation

Add this line to your application's Gemfile:

gem 'ok_hbase'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ok_hbase

Usage

# simple example showing how to:
# 1) connect
# 2) create a table
# 3) write rows
# 4) scan for rows
# 5) get a row by key
# 6) delete a table

require 'ok_hbase'

# get a connection
conn = OkHbase::Connection.new(
  host: 'localhost',
  port: 9090,
  auto_connect: true
)

# create a new table with column family 'd'
table = conn.create_table('ok_hbase_test', d: {})

puts 'putting a bunch of data in the table.'
('hbaaa'..'hbzzz').each_with_index do |row_key, index|
  table.put(
    row_key,
    {
      'd:row_number' => "#{index+1}",
      'd:message' => "this is row number #{index+1}"
    }
  )
print "wrote row: #{row_key}\r"
end

puts "\nscanning for all rows, starting with 'hbzza'"
table.scan(start_row: 'hbzza') do |row_key, columns|
  puts row_key, columns, "\n"
end

puts "\nscanning for all rows, stopping with 'hbaaz'"
# stop_row is NOT inclusive, so use the next greatest value
table.scan(stop_row: 'hbab') do |row_key, columns|
  puts row_key, columns, "\n"
end

puts "\nscanning for the row with keys 'hbase' and 'hbasf'"
# stop_row is NOT inclusive, so use the next greatest value
table.scan(start_row: 'hbase', stop_row: 'hbasg') do |row_key, columns|
  puts row_key, columns, "\n"
end

puts "\nscanning for all rows with keys beginning with 'hba'"
table.scan(row_prefix: 'hba')do |row_key, columns|
  puts row_key, columns, "\n"
end

puts "\ngetting the row with the row key 'hbase'"
puts table.row('hbase')

puts "\ncleaning up"
conn.delete_table('ok_hbase_test', true)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

ok_hbase's People

Contributors

kmcminn avatar

Watchers

Red Siwon Choi avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.