You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by Apache Wiki <wi...@apache.org> on 2007/08/07 23:56:27 UTC

[Lucene-hadoop Wiki] Update of "Hbase/HbaseShell/Examples" by udanax

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lucene-hadoop Wiki" for change notification.

The following page has been changed by udanax:
http://wiki.apache.org/lucene-hadoop/Hbase/HbaseShell/Examples

New page:
= Example Of Hbase Shell Use =
[[TableOfContents(4)]]
----

== Basic Data Manipulation Examples On Hbase Shell ==

=== Create a table in an HBase ===

{{{
HBase > CREATE Movie (
    --> year, length, inColor, studioName, vote, producer)
    --> NUM_VERSIONS 10; 

HBase > CREATE MovieStar (
    --> biography, filmography, gender, birthDate)
    --> NUM_VERSIONS 10;
}}}

=== Insert data into a table ===
{{{
HBase > INSERT INTO Movie (year:, length:, inColor:, studioName:, vote:user_1, producer:)
    --> VALUES ('1977', '124', 'true', 'Fox', '5', 'George Lucas')
    --> WHERE row='Star Wars';


HBase > INSERT INTO MovieStar (biography:, 'filmography:Star Wars', gender:, birthDate:)
    --> VALUES ('blah blah', 'starring', 'male', 'March 31, 1971')
    --> WHERE row='Ewan Gordon Mc.Gregor'; 
}}}

=== Show all data in a table ===
{{{
HBase > SELECT * Movie;
}}}

||Row Key ||<-12>Column Families ||
||<rowbgcolor="#ececec">title ||<-2> year ||<-2>length ||<-2>inColor ||<-2> studioName ||<-2> vote ||<-2> producer ||
||Star Wars ||year: || 1977 ||length: || 124 ||inColor: || true ||studioName: || Fox || vote:''user_1'' || 5 || producer: || George Lucas ||
|| || || || || || || || || || vote:''user_2'' || 2 || || ||
||Mighty Ducks ||year: || 1991 ||length: || 104 ||inColor: || true ||studioName: || Disney || vote:''user_1'' || 2 || producer: || Blair Peters ||
|| || || || || || || || || || vote:''user_3'' || 4 || || ||
||Wayne's World ||year: || 1992 ||length: || 95 ||inColor: || true ||studioName: || Paramount || vote:''user_2'' || 3 || producer: || Penelope Spheeris ||
|| || || || || || || || || || vote:''user_3'' || 4 || || ||

{{{
HBase > SELECT * MovieStar;
}}}

||Row Key ||<-8>Column Families ||
||<rowbgcolor="#ececec">starName ||<-2> biography ||<-2>filmography ||<-2>gender ||<-2> birthDate ||
||Ewan Gordon Mc.Gregor ||biography: ||blah blah ||filmography:Star Wars ||starring ||gender: ||male ||birthDate: ||March 31, 1971 ||
|| || || ||filmography:Emma ||extra || || || || ||
||Kenan Thompson ||biography: ||blah blah ||filmography:Mighty Ducks ||starring ||gender: ||male ||birthDate: ||May 10, 1978 ||
|| || || ||filmography:Big Fat Liar  ||cameo || || || || ||
||keanu reeves ||biography: ||blah blah ||filmography:Constantine ||starring ||gender: ||male ||birthDate: ||September 2, 1964||
|| || || ||filmography:The Matrix Reloaded ||starring || || || || ||


=== Transactions ===

{{{
START TRANSACTION ON 'Star Wars' OF Movie;

INSERT INTO Movie ('character:Luke Skywalker', 'character:Han Solo')
  VALUES ('Mark Hamil', 'Harrison Ford') WHERE row = 'Star Wars';
INSERT INTO Movie (genre:) VALUES ('action, adventure, fantasy') WHERE row = 'Star Wars';

COMMIT; 
}}}


||Row Key ||<-12>Column Families ||
||<rowbgcolor="#ececec">title ||<-2> year ||<-2>length ||<-2>inColor ||<-2> studioName ||<-2> vote ||<-2> producer ||<-2> character ||<-2> genre ||
||Star Wars ||year: || 1977 ||length: || 124 ||inColor: || true ||studioName: || Fox || vote:''user_1'' || 5 || producer: || George Lucas || character:Luke Skywalker || Mark Hamil || genre: || action, adventure, fantasy ||
|| || || || || || || || || || vote:''user_2'' || 2 || || || character:Han Solo || Harrison Ford || || || ||
||Mighty Ducks ||year: || 1991 ||length: || 104 ||inColor: || true ||studioName: || Disney || vote:''user_1'' || 2 || producer: || Blair Peters || || || || || || ||
|| || || || || || || || || || vote:''user_3'' || 4 || || || || || || ||
||Wayne's World ||year: || 1992 ||length: || 95 ||inColor: || true ||studioName: || Paramount || vote:''user_2'' || 3 || producer: || Penelope Spheeris || || || || ||
|| || || || || || || || || || vote:''user_3'' || 4 || || || || || || ||


----
== Relational Operations Example On Hbase Altools ==
||Row Key ||||||||||||||||||||||||Column Families ||
||<rowbgcolor="#E5E5E5">title |||| year ||||length ||||inColor |||| studioName |||| vote |||| producer ||
||Star Wars ||year: || 1977 ||length: || 124 ||inColor: || true ||studioName: || Fox || vote:''user_1'' || 5 || producer: || George Lucas ||
|| || || || || || || || || || vote:''user_2'' || 2 || || ||
||Mighty Ducks ||year: || 1991 ||length: || 104 ||inColor: || true ||studioName: || Disney || vote:''user_1'' || 2 ||