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 05:10:24 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

------------------------------------------------------------------------------
  !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, ...]);
+ }}}
  

Mime
View raw message