Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 35725 invoked from network); 9 Feb 2008 05:10:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Feb 2008 05:10:47 -0000 Received: (qmail 17836 invoked by uid 500); 9 Feb 2008 05:10:40 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 17807 invoked by uid 500); 9 Feb 2008 05:10:40 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 17798 invoked by uid 99); 9 Feb 2008 05:10:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 21:10:40 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Feb 2008 05:10:31 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 22BB6D2DB for ; Sat, 9 Feb 2008 05:10:24 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: core-commits@hadoop.apache.org Date: Sat, 09 Feb 2008 05:10:24 -0000 Message-ID: <20080209051024.19627.38479@eos.apache.org> Subject: [Hadoop Wiki] Trivial Update of "Hbase/HbaseShell/HQL" by udanax X-Virus-Checked: Checked by ClamAV on apache.org 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 ------------------------------------------------------------------------------ !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]] + /* Initializes a hql client object */ - {{{ }}}''HQLClient hql = HQLClient(...);'' + HQLClient hql = HQLClient(...); + + /* !ResultSet object to hold the result of query */ + !ReulstSet rs = null; - {{{ }}}''/* !ResultSet object to hold the result of query */''[[BR]] - {{{ }}}''!ReulstSet rs = null;'' + /* execute the hql and put the results in the ResultSet object*/ + rs = hql.executeQuery("query"); - {{{ }}}''/* execute the hql and put the results in the !ResultSet object*/''[[BR]] - {{{ }}}''rs = stmt.executeQuery("query");'' + while(rs.next()) + { + // Iterate through the ResultSet + // and return the actual row/column/timestamp attribute names and cell value - {{{ }}}''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 row = rs.getRowName(); - {{{ }}}''Text column = rs.getColumnName();''[[BR]] + Text column = rs.getColumnName(); - {{{ }}}''long timestamp = rs.getTimeStamp(); /* or rs.getDate(); */''[[BR]] + long timestamp = rs.getTimeStamp(); /* or rs.getDate(); */ - {{{ }}}''!DataType value = rs.getValue("datatype");''[[BR]] + DataType value = rs.getValue("datatype"); - {{{ }}}''}'' - + } + }}} == 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 > alter table tbl_name parallel(map 4 reduce 1); - {{{ }}}''hql > select count(*) from tbl_name;''[[BR]] + hql > select count(*) from tbl_name; - {{{ }}}''hql > alter table tbl_name noparallel;''[[BR]] + hql > alter table tbl_name noparallel; + }}} === Parallel Data Loading === + HQL Loader utility loads data into Hbase tables from external files. If you have a large amount of data to load, HQL Loader's parallel support can dramatically reduce the elapsed time needed to perform that load. - 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]] + hql > load data file 'hdfs://hbase/big.dat' - {{{ }}}''--> into table tbl_name''[[BR]] + --> into table tbl_name - {{{ }}}''--> fields terminated by '\t' ''[[BR]] + --> fields terminated by '\t' - {{{ }}}''--> lines terminated by '\n' ''[[BR]] + --> lines terminated by '\n' - {{{ }}}''--> (column1[, column2, ...]);''[[BR]] + --> (column1[, column2, ...]); + }}}