overview-example

CoreServlets - Hbase Installation

Let's walk through an example

  1. Create a table

• Define column families

  1. Populate table with data records

• Multiple records

  1. Access data

• Count, get and scan

  1. Edit data

  2. Delete records

  3. Drop table

  4. Create a table

Create table called 'Blog' with the following schema

– 2 families

• 'info' with 3 columns: 'title', 'author', and 'date'

• 'content' with 1 column family: 'post'

Various options to create tables and

families

– hbase> create 't1', {NAME => 'f1', VERSIONS => 5}

– hbase> create 't1', {NAME => 'f1', VERSIONS => 1,

TTL => 2592000, BLOCKCACHE => true}

– hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'},

{NAME => 'f3'}

– hbase> create 't1', 'f1', 'f2', 'f3'

hbase> create 'Blog', {NAME=>'info'}, {NAME=>'content'}

0 row(s) in 1.3580 seconds.

Note , column families need to be defined at the table creation time.

So, the above will create a table with Blog having families info, content.

NAME is keyword in hbase that will take .

Assignment operator will be => in jRuby ( Hbase shll will work in jRuby). So the statment

NAME=>'info' , will assign info to the one of the column familes

2: Populate Table With Data

Records

Put command format:

hbase> put 'table', 'row_id', 'family:column', 'value'

put 'Blog', 'Matt-001', 'info:title', 'Elephant'

put 'Blog', 'Matt-001', 'info:author', 'Matt'

put 'Blog', 'Matt-001', 'info:date', '2009.05.06'

put 'Blog', 'Matt-001', 'content:post', 'Do elephants like monkeys?'

Please note

  1. colums need not be defined create table time. thus , put can be used to add columns along it s values

  2. coumn is qualified using

columqualifier : coulmnname (info:date)

Last updated