Databases Reference
In-Depth Information
Querying HBase
The simplest way to query an HBase store is via its shell. If you are logged in to the shell already —
meaning you have started it using bin/hbase shell and connected to the same local store where you
just entered some data — you may be ready to query for that data.
To get all data pertaining to post1 , simply query like so:
hbase(main):024:0> get 'blogposts', 'post1'
COLUMN CELL
multimedia:body timestamp=1302059666802,
value=body.png
multimedia:header timestamp=1302059638880,
value=header.png
post:author timestamp=1302059570361,
value=a blogger
post:body timestamp=1302059604738,
value=interesting content
post:title timestamp=1302059434638,
value=an interesting blog post
5 row(s) in 0.1080 seconds
Available for
download on
Wrox.com
blogposts.txt
This shows all the post1 attributes and their values. To get all data pertaining to post2 , simply
query like so:
hbase(main):025:0> get 'blogposts', 'post2'
COLUMN CELL
multimedia:body-image timestamp=1302059995926,
value=body_image.png
multimedia:body-video timestamp=1302060050405,
value=body_video.mpeg
post:author timestamp=1302059954733,
value=another blogger
post:body timestamp=1302060008837,
value=interesting content
post:title timestamp=1302059851203,
value=yet another blog post
5 row(s) in 0.0760 seconds
Available for
download on
Wrox.com
blogposts.txt
To get a fi ltered list containing only the title column for post1 , query like so:
hbase(main):026:0> get 'blogposts', 'post1', { COLUMN=>'post:title' }
COLUMN CELL
post:title timestamp=1302059434638,
value=an interesting blog post
1 row(s) in 0.0480 seconds
Available for
download on
Wrox.com
blogposts.txt
Search WWH ::




Custom Search