hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hadoop Wiki] Trivial Update of "Hbase/HbaseShell/HQL" by udanax
Date Sat, 09 Feb 2008 04:58:59 GMT
Dear Wiki user,

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

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

------------------------------------------------------------------------------
  = HQL plan for Hbase 0.2 =
  
- Add plan content here.
+ == HQLClient API ==
  
- == Comparison table between SQL and HQL ==
+ !ResultSet object is used for return the results instead of direct call to scanner.[[BR]]
+ The following code shows how to perform a query on the Hbase.
+   
+ {{{  }}}''/* Initializes  a hql client object */''[[BR]]
+ {{{  }}}''HQLClient hql = HQLClient(...);''
  
+ {{{  }}}''/* !ResultSet object to hold the result of query */''[[BR]]
+ {{{  }}}''!ReulstSet rs = null;''
- ||<bgcolor="#ececec">'''SQL''' ||<bgcolor="#ececec">'''HQL 0.0.2'''||
- ||'''Select Statement'''[[BR]]SELECT "column_name" FROM "table_name"||O||
- ||'''Distinct'''[[BR]]SELECT DISTINCT "column_name"[[BR]]FROM "table_name"||O ||
- ||'''Where'''[[BR]]SELECT "column_name"[[BR]]FROM "table_name"[[BR]]WHERE "condition"||Only
row/column/timestamp ||
- ||'''And/Or'''[[BR]]SELECT "column_name"[[BR]]FROM "table_name"[[BR]]WHERE "simple condition"[[BR]{[AND|OR]
"simple condition"}+ ||X ||
- ||'''In'''[[BR]]SELECT "column_name"[[BR]]FROM "table_name"[[BR]]WHERE "column_name" IN
('value1', 'value2', ...) ||X ||
- ||'''Between'''[[BR]]SELECT "column_name"[[BR]]FROM "table_name"[[BR]]WHERE "column_name"
BETWEEN 'value1' AND 'value2'||X ||
- ||'''Like'''[[BR]]SELECT "column_name"[[BR]]FROM "table_name"[[BR]]WHERE "column_name" LIKE
{PATTERN} ||X ||
- ||'''Order By'''[[BR]]SELECT "column_name"[[BR]]FROM "table_name"[[BR]][WHERE "condition"][[BR]]ORDER
BY "column_name" [ASC, DESC] ||X ||
- ||'''Count/Sum/Min/Max/Avg'''[[BR]]SELECT COUNT("column_name")[[BR]]FROM "table_name" ||Only
COUNT() ||
- ||'''Group By'''[[BR]]SELECT "column_name1", SUM("column_name2")[[BR]]FROM "table_name"[[BR]]GROUP
BY "column_name1"||X ||
- ||'''Having'''[[BR]]SELECT "column_name1", SUM("column_name2")[[BR]]FROM "table_name"[[BR]]GROUP
BY "column_name1"[[BR]]HAVING (arithematic function condition)||X ||
- ||'''Create Table Statement'''[[BR]]CREATE TABLE "table_name"[[BR]]("column 1" "data_type_for_column_1",[[BR]]"column
2" "data_type_for_column_2",[[BR]]... ) ||O ||
- ||'''Drop Table Statement'''[[BR]]DROP TABLE "table_name"||O ||
- ||'''Truncate Table Statement'''[[BR]]TRUNCATE TABLE "table_name" ||O ||
- ||'''Insert Into Statement'''[[BR]]INSERT INTO "table_name" ("column1", "column2", ...)[[BR]]VALUES
("value1", "value2", ...) ||O ||
- ||'''Update Statement'''[[BR]]UPDATE "table_name"[[BR]]SET "column_1" = [new value][[BR]]WHERE
{condition} ||X ||
- ||'''Delete From Statement'''[[BR]]DELETE FROM "table_name"[[BR]]WHERE {condition} ||O ||
  
+ {{{  }}}''/* execute the hql and put the results in the !ResultSet object*/''[[BR]]
+ {{{  }}}''rs = stmt.executeQuery("query");''
+ 
+ {{{  }}}''while(rs.next())''[[BR]]
+ {{{  }}}''{''[[BR]]
+ {{{    }}}''// Iterate through the !ResultSet''[[BR]]
+ {{{    }}}''// and return the actual row/column/timestamp attribute names and cell value''
+ 
+ {{{    }}}''Text row = rs.getRowName();''[[BR]]
+ {{{    }}}''Text column = rs.getColumnName();''[[BR]]
+ {{{    }}}''long timestamp = rs.getTimeStamp(); /* or rs.getDate(); */''[[BR]]
+ {{{    }}}''!DataType value = rs.getValue("datatype");''[[BR]]
+ {{{  }}}''}''
+ 
+ == Parallel Execution Features ==
+ 
+ === Parallel Query ===
+ Parallel execution can significantly reduce the elapsed time for large queries, but it doesn't
apply to every query. 
+ 
+ {{{  }}}''hql > alter table tbl_name parallel(map 4 reduce 1);''[[BR]]
+ {{{  }}}''hql > select count(*) from tbl_name;''[[BR]]
+ {{{  }}}''hql > alter table tbl_name noparallel;''[[BR]]
+ 
+ === Parallel Data Loading ===
+ HQL Loader utility loads data into Hbase tables from external files.[[BR]]
+ If you have a large amount of data to load, [[BR]]
+ HQL Loader's parallel support can dramatically reduce the elapsed time needed to perform
that load.
+ 
+ {{{  }}}''hql > load data file 'hdfs://hbase/big.dat';''[[BR]]
+ {{{    }}}''--> into table tbl_name''[[BR]]
+ {{{    }}}''--> fields terminated by '\t' ''[[BR]]
+ {{{    }}}''--> lines terminated by '\n' ''[[BR]]
+ {{{    }}}''--> (column1[, column2, ...]);''[[BR]]
+ 

Mime
View raw message