Headline

A NoSQL implementation based on Technology:HBase

Motivation

In this implementation, the features of a Technology:Column-oriented database by example of Technology:HBase. It employs the column-wise ordering of data to accomplish data operations. The query language used is JRuby.

Illustration

A company is organized in two tables, one for employees and one for departments.

The employees table contains two column families: personal and corporate. The personal column family contains name and address columns, while the corporate family contains a salary column.

In the departments table there are two column families for personnel and corporate structure. Under personnel, employee and manager columns are maintained while the structure family contains a column for information on subdepartments.

Totalling employee salaries is implemented in a JRuby script that is executed by the HBase shell using a few helper classes from HBase's Language:Java library. First, the script establishes an access object to the employees table:

employees = HTable.new(@hbase.configuration, "meganalysis employees")

Then, a cursor on the table is obtained via a Scanner object. The scanner is iterated over and for each entry, the salary value is extracted and added to the total. Because the database just stores raw byte arrays, the stored value first has to be converted back into a floating point number which is taken care of by an HBase helper class.

total = 0.0
while (result = scanner.next())
  id = Bytes.toString(result.getRow())
  name = Bytes.toString(result.getValue(*jbytes('personal', 'name')))
  salary = Bytes.toDouble(result.getValue( *jbytes('corporate', 'salary')))

  print "ID: #{id}, Name: #{name}, Salary: #{salary}\n"
  total += salary
end

Cutting salaries is implemented similarily although rather than totalling the extracted salary, the new value is written back into the table by creating and submitting a proper put request.

  put cut = Put.new(namebytes)
  put cut.add( *(jbytes('corporate', 'salary') << Bytes.toBytes(salary / 2.0)))
  employees.put(put cut) if put cut

Usage

In the dbs subfolder are two HBase database dumps. Make sure to have a local installation of HBase running and execute

$ ./rebuild.sh

This will restore the employee and department tables for the meganalysis company.

The feature demonstrations are executed using the HBase shell. Simply run

$ ./total.sh # or cut.sh
.

The scripts will drop into the HBase shell which can be quit by simply typing 'quit'.


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.