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 ------------------------------------------------------------------------------ - [[TableOfContents(2)]] + [[TableOfContents(3)]] ---- = Hbase Shell Introduction = @@ -46, +46 @@ '''Note''' that attribute values are quoted with either single or double quotes. == Basic Query Commands == + === Basic administration commands === ||<bgcolor="#ececec">'''Command''' ||<bgcolor="#ececec">'''Explanation''' || ||Help ||<99%>'''Help''' command provides information about the use of shell script.[[BR]][[BR]]~-''HELP [function_name];''-~ || ||Show ||<99%>'''Show''' command lists tables.[[BR]][[BR]]~-''SHOW tables;''-~ || @@ -55, +56 @@ ||Clear ||<99%>'''Clear''' the screen.[[BR]][[BR]]~-''CLEAR;''-~ || ||Exit ||<99%>'''Exit''' from the current shell script.[[BR]][[BR]]~-''EXIT;''-~ || + === Data definition commands === - and, Definition commands to define data tables. + Data definition commands to define data tables ||<bgcolor="#ececec">'''Command''' ||<bgcolor="#ececec">'''Explanation''' || ||Create ||<99%>'''Create''' command creates a new table.[[BR]][[BR]]~-''CREATE TABLE table_name ([[BR]]{{{ }}}column_family_definition[[BR]]{{{ }}}[, column_family_spec][[BR]]{{{ }}}...[[BR]])[[BR]][[BR]]''-~'''colum_family_definition:'''~-''[[BR]]column_family_name[[BR]]{{{ }}}[MAX_VERSIONS=n][[BR]]{{{ }}}[MAX_LENGTH=n][[BR]]{{{ }}}[COMPRESSION=NONE|BLOCK|RECORD][[BR]]{{{ }}}[IN_MEMORY][[BR]]{{{ }}}[BLOOMFILTER=NONE|BLOOM|COUNTING|RETOUCHED VECTOR_SIZE=n NUM_HASH=n]''-~ || @@ -63, +65 @@ ||Drop ||'''Drop''' command drops columnfamilies in a table or tables.[[BR]][[BR]]~-''DROP TABLE table_name1[, table_name2, ...];''-~ || ||Truncate ||'''Truncate''' command cleans all data from a table. [[BR]][[BR]]~-''TRUNCATE TABLE table_name;''-~ || + === Data manipulation commands === - And, Commands to manually manipulate data on more detailed parts. + Data manipulation commands to manually manipulate data on more detailed parts ||<bgcolor="#ececec">'''Command''' ||<bgcolor="#ececec">'''Explanation''' || ||Insert ||<99%>'''Insert''' command inserts one row into the table with a value for specified column in the table.[[BR]][[BR]]~-''INSERT INTO table_name (colmn_name, ...)[[BR]]{{{ }}}VALUES ('value', ...)[[BR]]{{{ }}}WHERE row = 'row-key'[[BR]]{{{ }}}[TIMESTAMP 'timestamp'];''-~ || @@ -78, +81 @@ ||Substitute ||<99%>'''Substitute''' specific algebraic expression to specified string[[BR]][[BR]]~-''A = Projection(column-list);''-~ || ||Save ||<99%>'''Save''' command will save results to specified table or matrix. [[BR]][[BR]]~-''A = Table('table_name'); [[BR]]B = A.Selection(condition_expression); [[BR]]Save B Into table(result_table);''-~ || + === Relational Algebra Operators === + + ||<bgcolor="#E5E5E5">'''Operator''' ||<bgcolor="#E5E5E5">'''Explanation''' || + ||Projection ||<99%>'''Projection''' of a relation ~+R+~, It makes a new relation as the set that is obtained when all rows in ~+R+~ are restricted to the set {columnfamily,,1,,,...,columnfamily,,n,,}.[[BR]][[BR]]~-''A = Table('table_name');[[BR]]B = A.Projection(column-list);''-~ || + ||Selection ||<99%>'''Selection''' of a relation ~+R+~, It makes a new relation as the set of specified rows of the relation ~+R+~.[[BR]]'''Set Operations''' : ~-''OR, AND, NOT''-~[[BR]][[BR]]~-''A = Table('table_name');[[BR]]B = A.Selection(condition_expression);''-~ || + ||JOIN ||<99%>Table '''JOIN''' operations, linking and extracting data from two different internal source.[[BR]][[BR]]~-''R = Table('table_name1');[[BR]]S = Table('table_name2');[[BR]]C = R.Join(condition_expression) and S;''-~ || + ||Group ||<99%>'''Group''' tuples by value of an attribute and apply aggregate function independently to each group of tuples.[[BR]]'''Aggregate Functions''' : ~-''AVG(attribute), SUM(attribute), COUNT(attribute), MIN(attribute), MAX(attribute)''-~[[BR]][[BR]]~-''A = Table('table_name');[[BR]]B = A.Group(column-list);''-~ || + ---- - = Example = + = Examples = == Example Of Basic Query Command Uses == - - * [#create Create the table in a Hbase] - * [#select Select data from a table] - * [#insert Insert data into a table] - * [#jars How to use external jars in Hbase Shell] - - [[Anchor(create)]] === Create the table in a Hbase === {{{ @@ -125, +129 @@ --> anchor max_length=256 bloomfilter=counting --> vector_size=1000000 num_hash=4); }}} - [[Anchor(select)]] + === Select data from a table === {{{ hql > help select; @@ -160, +164 @@ hql > SELECT 'studioName:YoungGu Art, Corp.' FROM movieLog_table WHERE row = 'D-War'; }}} - [[Anchor(insert)]] + === Insert data into a table === {{{ hql > help insert; @@ -186, +190 @@ --> VALUES ('1977', '124', 'true', 'Fox', '5', 'George Lucas', 'Mark Hamill') --> WHERE row='Star Wars'; }}} - [[Anchor(jars)]] + === How to use external jars in Hbase Shell === {{{ @@ -198, +202 @@ }}} == Example Of Relational Algebraic Query Command Uses == - * Relational Algebra Operations - * [#projection Relational Projection] - * [#selection Relational Selection] - * [#group Relational Group] - * [#join Relational Join] - * [#mixture Query mixture examples] - [[Anchor(projection)]] - === Relational Projection === + === Relational projection === * selects a subset of the columnfamilies of a relation * Result = Ï ,,column_list,, (Relation) @@ -230, +227 @@ | Mighty Ducks 1991 104 | +------------------------------+ }}} - [[Anchor(selection)]] - === Relational Selection === + === Relational selection === * selects a subset of the rows in a relation that satisfy a selection condition * Result = Ï ,,selection_condition,, (Relation) {{{ @@ -255, +251 @@ | Star Wars 1977 124 true Fox Entertainment Group, Inc. | +--------------------------------------------------------------------+ }}} - [[Anchor(group)]] + - === Relational Group === + === Relational group === * Aggregation functions on collections of data values: average, minimum, maximum, sum, count. * Group rows by value of an columnfamily and apply aggregate function independently to each group of rows. * <Grouping columnfamilies> Æ ,,function_list,, (Relation) @@ -264, +260 @@ {{{ Hbase > Group Relation by (studioName, SUM('vote:user')); }}} - [[Anchor(join)]] + - === Relational Join === + === Relational join === * The join of two relations R1(A,,1,, ,A,,2,, ,...,A,,n,,) and R2(B,,1,, ,B,,2,, ,...,B,,m,,) is a relation with degree k=n+m and attributes (A,,1,, ,A,,2,, ,...,A,,n,, , B,,1,, ,B,,2,, ,...,B,,m,,) that satisfy the join condition * Result = R1 â·â ,,θ join_condition,, R2 {{{ @@ -329, +325 @@ hql > R2 = table('stockCompany_info'); hql > result = R1.join(R1.studioName = R2.corporation) and R2; }}} - [[Anchor(mixture)]] + === Query mixture examples === '''(ex. 1)''' Search the subject and the year of the movies which were produced by 'Fox' company and where running time is more than 100 minutes.