overview-example
CoreServlets - Hbase Installation
Let's walk through an example
Create a table
• Define column families
Populate table with data records
• Multiple records
Access data
• Count, get and scan
Edit data
Delete records
Drop table
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
colums need not be defined create table time. thus , put can be used to add columns along it s values
coumn is qualified using
columqualifier : coulmnname (info:date)
Last updated