<commit_before># hbase-jruby

*hbase-jruby* is a Ruby-esque interface for accessing HBase from JRuby.

With JRuby, you can of course just use the native Java APIs of HBase,
but doing so requires lots of keystrokes even for the most basic operations and
can lead to having overly verbose code that will be frowned upon by Rubyists.
Anyhow, JRuby is Ruby, not Java, right?

*hbase-jruby* provides the followings:
- Easy, Ruby-esque interface for the fundamental HBase operations
- ActiveRecord-like method chaining for data retrieval
- Automatic Hadoop/HBase dependency resolution

## A quick example

```ruby
require 'hbase-jruby'

HBase.resolve_dependency! 'cdh4.1.2'

hbase = HBase.new
table = hbase.table(:test_table)

# PUT
table.put :rowkey1 => { 'cf1:a' => 100, 'cf2:b' => "Hello" }

# GET
row = table.get(:rowkey1)
number = row.fixnum('cf1:a')
string = row.string('cf1:b')

# SCAN
table.range('rowkey1'..'rowkey9').
      filter('cf1:a' => 100..200,             # cf1:a between 100 and 200
             'cf1:b' => 'Hello',              # cf1:b = 'Hello'
             'cf2:c' => /world/i,             # cf2:c matches /world/i
             'cf2:d' => ['foo', /^BAR/i]).    # cf2:d = 'foo' OR matches /^BAR/i
      project('cf1:a', 'cf2').
      each do |row|
  puts row.fixnum('cf1:a')
end

# DELETE
table.delete(:rowkey9)
```

## Installation

    $ gem install hbase-jruby

## Setting up

### Resolving Hadoop/HBase dependency

To be able to access HBase from JRuby, Hadoop/HBase dependency must be satisfied.
This can be done by either setting up CLASSPATH variable beforehand
or by `require`ing relevant JAR files after launching JRuby.
However, that's a lot of work, so *hbase-jruby* provides `HBase.resolve_dependency!` helper method,
which automatically resolves Hadoop/HBase dependency.

#### Preconfigured dependencies

Apache Maven is the de facto standard dependency management mechanism for Java projects.
Current version of *hbase-jruby* is shipped with Maven dependency specifications<commit_msg>how to build from source<commit_after># hbase-jruby

*hbase-jruby* is a Ruby-esque interface for accessing HBase from JRuby.

With JRuby, you can of course just use the native Java APIs of HBase,
but doing so requires lots of keystrokes even for the most basic operations and
can lead to having overly verbose code that will be frowned upon by Rubyists.
Anyhow, JRuby is Ruby, not Java, right?

*hbase-jruby* provides the followings:
- Easy, Ruby-esque interface for the fundamental HBase operations
- ActiveRecord-like method chaining for data retrieval
- Automatic Hadoop/HBase dependency resolution

## A quick example

```ruby
require 'hbase-jruby'

HBase.resolve_dependency! 'cdh4.1.2'

hbase = HBase.new
table = hbase.table(:test_table)

# PUT
table.put :rowkey1 => { 'cf1:a' => 100, 'cf2:b' => "Hello" }

# GET
row = table.get(:rowkey1)
number = row.fixnum('cf1:a')
string = row.string('cf1:b')

# SCAN
table.range('rowkey1'..'rowkey9').
      filter('cf1:a' => 100..200,             # cf1:a between 100 and 200
             'cf1:b' => 'Hello',              # cf1:b = 'Hello'
             'cf2:c' => /world/i,             # cf2:c matches /world/i
             'cf2:d' => ['foo', /^BAR/i]).    # cf2:d = 'foo' OR matches /^BAR/i
      project('cf1:a', 'cf2').
      each do |row|
  puts row.fixnum('cf1:a')
end

# DELETE
table.delete(:rowkey9)
```

## Installation

### From Rubygems

    gem install hbase-jruby

### From source

    git clone -b devel https://github.com/junegunn/hbase-jruby.git
    cd hbase-jruby
    rake build
    gem install pkg/hbase-jruby-0.1.6-java.gem

## Setting up

### Resolving Hadoop/HBase dependency

To be able to access HBase from JRuby, Hadoop/HBase dependency must be satisfied.
This can be done by either setting up CLASSPATH variable beforehand
or by `require`ing relevant JAR files after launching JRuby.
However, that's a lot of work, so *hbase-jruby* provides `HBase.resolve_dependency!` helper method,
which automatically resolves Hadoop/HBase dependency.

#### Preconfigured dependencies

Apache Maven is the de facto standard dependency management mechanism for Java projects.
Current version of *hbase-jruby* is shipped with Maven dependency specifications
{'fraction_non_alphanumeric': 0.10990052108005685, 'fraction_numerical': 0.018711511132164852, 'mean_word_length': 3.5654054054054054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7402102', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1347, 'n_words': 477}