准备好实验数据
hadoop@hadoop:~$ gunzip access.tsv.gz
hadoop@hadoop:~$ mv access.tsv ~/hypertable/0.9.2.5/examples/hql_tutorial/
hadoop@hadoop:~$ cd ~/hypertable/0.9.2.5/examples/hql_tutorial/
hadoop@hadoop:~/hypertable/0.9.2.5/examples/hql_tutorial$
hadoop@hadoop:~/hypertable/0.9.2.5/examples/hql_tutorial$ more access.tsv
# rowkey date refer-url http-co<wbr>de<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.mercurynews.com/venues 2008-01-25 15:19:32 events.mercurynews.com/search 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> www.zvents.com/events/auto_complete_for_artist_name 2008-01-25 15:19:32 www.zvents.co<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> m/indio-ca/events/show/81296496-coachella 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> calendar.denverpost.com/search 2008-01-25 15:19:32 calendar.denverpost.com/search 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> www.zvents.com/search 2008-01-25 15:19:32 www.zvents.com/search 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.newsherald.com/events/show/81138187 2008-01-25 15:19:34 events.newsherald.com<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> /venues 301<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> www.zvents.com/search 2008-01-25 15:19:35 www.zvents.com/search 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.ocregister.com/search 2008-01-25 15:19:36 events.ocregister.com/ 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.mercurynews.com/search 2008-01-25 15:19:37 events.mercurynews.com/search 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.idahostatesman.com/search 2008-01-25 15:19:38 events.idahostatesman.com/sea<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> rch 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> www.zvents.com/welcome/set_location 2008-01-25 15:19:38 www.zvents.com/movies/show/86<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 86-27-dresses 302</wbr>
hadoop@hadoop:~/hypertable/0.9.2.5/log$ hypertable
Welcome to the hypertable command interpreter.
For information about Hypertable, visithttp://www.hypertable.org/
Type ‘help’ for a list of commands, or ‘help shell’ for a
list of shell meta commands.
hypertable> help
CREATE TABLE ……. Creates a table
DELETE …………. Deletes all or part of a row from a table
DESCRIBE TABLE ….. Displays a table’s schema
DROP TABLE ……… Removes a table
ALTER TABLE …….. Add/remove column family from existing table
INSERT …………. Inserts da<wbr>ta into a table<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> LOAD DA<wbr>TA INFILE … Loads da<wbr>ta from a TSV input file into a table<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> SELECT …………. Selects (and display) cells from a table<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> SHOW CREATE TABLE .. Displays CREATE TABLE command used to create table<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> SHOW TABLES …….. Displays the list of tables<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> SHUTDOWN ……….. Shuts servers down gracefully</wbr></wbr></wbr>
Statements must be terminated with ‘;’. For more information on
a specific statement, type ‘help <statement>’, where <statement> is from
the preceeding list.
hypertable> help shell
Interpreter Meta Commands
————————-
? (\?) Synonym for `help’.
clear (\c) Clear command.
exit (\q) Exit program. Same as quit.
print (\p) Print current command.
quit (\q) Quit program.
source <f> (.) Execute commands in file <f>.
system (\!) Execute a system shell command.
hypertable>
hypertable> create table Pages ( date, “refer-url”, “http-co<wbr>de”);</wbr>
Elapsed time: 0.15 s
hypertable> show create table Pages;
CREATE TABLE Pages (
date,
‘refer-url’,
‘http-co<wbr>de’,<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> ACCESS GROUP default (date, ‘refer-url’, ‘http-co<wbr>de’)<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> )</wbr></wbr>
Elapsed time: 0.01 s
hypertable> describe table Pages;
<Schema generation=”1″>
<AccessGroup name=”default”>
<ColumnFamily id=”1″>
<Generation>1</Generation>
<Name>date</Name>
<deleted>false</deleted>
</ColumnFamily>
<ColumnFamily id=”2″>
<Generation>1</Generation>
<Name>refer-url</Name>
<deleted>false</deleted>
</ColumnFamily>
<ColumnFamily id=”3″>
<Generation>1</Generation>
<Name>http-co<wbr>de</Name><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <deleted>false</deleted><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </ColumnFamily><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </AccessGroup><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </Schema></wbr>
Elapsed time: 0.00 s
hypertable>
hypertable> load da<wbr>ta infile ROW_KEY_COLUMN=rowkey “examples/hql_tutorial/access.tsv” into table Pages;</wbr>
Loading 10,872,957 bytes of input da<wbr>ta…</wbr>
0% 10 20 30 40 50 60 70 80 90 100%
|—-|—-|—-|—-|—-|—-|—-|—-|—-|—-|
***************************************************
Load complete.
Elapsed time: 4.41 s
Avg value size: 18.68 bytes
Avg key size: 48.70 bytes
Throughput: 4583496.26 bytes/s (2465499.65 bytes/s)
Total cells: 300000
Throughput: 68026.56 cells/s
Resends: 0
hypertable>
hypertable> load da<wbr>ta infile ROW_KEY_COLUMN=rowkey “examples/hql_tutorial/access.tsv” into file “test.tsv”;</wbr>
Loading 10,872,957 bytes of input da<wbr>ta…</wbr>
0% 10 20 30 40 50 60 70 80 90 100%
|—-|—-|—-|—-|—-|—-|—-|—-|—-|—-|
***************************************************
Load complete.
Elapsed time: 1.61 s
Avg value size: 18.68 bytes
Avg key size: 48.70 bytes
Throughput: 12586755.81 bytes/s (6770517.59 bytes/s)
Total cells: 300000
Throughput: 186807.99 cells/s
hypertable> quit
hadoop@hadoop:~/hypertable/0.9.2.5$ head -10 test.tsv
rowkey columnkey value
0×9db0140 date 2008-01-25 15:19:32
0×9db0140 refer-url events.mercurynews.com/search
0×9db0140 http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 0×9db0170 date 2008-01-25 15:19:32<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 0×9db0170 refer-url www.zvents.com/indio-ca/events/show/81296496-coachella<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 0×9db0170 http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 0×9db0170 date 2008-01-25 15:19:32<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 0×9db0170 refer-url calendar.denverpost.com/search<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 0×9db0170 http-co<wbr>de 200</wbr></wbr></wbr>
hypertable> select ‘http-co<wbr>de’ from Pages where ROW=’events.getoutaz.com/scottsdale-az/venues/show/455885-scorch-bar’;<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.getoutaz.com/scottsdale-az/venues/show/455885-scorch-bar http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.getoutaz.com/scottsdale-az/venues/show/455885-scorch-bar http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.getoutaz.com/scottsdale-az/venues/show/455885-scorch-bar http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> events.getoutaz.com/scottsdale-az/venues/show/455885-scorch-bar http-co<wbr>de 200</wbr></wbr></wbr></wbr></wbr>
Elapsed time: 0.01 s
Avg value size: 3.00 bytes
Avg key size: 64.00 bytes
Throughput: 51937.98 bytes/s
Total cells: 4
Throughput: 775.19 cells/s
hypertable> select “refer-url” from Pages where ROW = “www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin” DISPLAY_TIMESTAMPS;
2009-08-18 14:03:49.166173771 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin refer-url www.google.com/search
2009-08-18 14:03:49.035165894 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin refer-url www.google.com/search
2009-08-18 14:03:48.606115876 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin refer-url www.zvents.com/search
2009-08-18 14:03:47.197737860 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin refer-url www.google.com/search
2009-08-18 14:03:47.197737857 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin refer-url www.google.com/search
2009-08-18 14:03:46.955504821 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin refer-url www.google.com/search
Elapsed time: 0.01 s
Avg value size: 21.00 bytes
Avg key size: 66.00 bytes
Throughput: 63821.98 bytes/s
Total cells: 6
Throughput: 733.59 cells/s
hypertable> select “http-co<wbr>de” from Pages where ROW = “www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin” DISPLAY_TIMESTAMPS;<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:49.166173772 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:49.035165895 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:48.606115877 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:47.197737861 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:47.197737858 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:46.955504822 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200</wbr></wbr></wbr></wbr></wbr></wbr></wbr>
Elapsed time: 0.00 s
Avg value size: 3.00 bytes
Avg key size: 66.00 bytes
Throughput: 127032.83 bytes/s
Total cells: 6
Throughput: 1841.06 cells/s
hypertable> select “http-co<wbr>de” from Pages where ROW = “www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin” AND TIMESTAMP >= ‘2008-02-02 00:00:00′ DISPLAY_TIMESTAMPS;<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:49.166173772 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:49.035165895 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:48.606115877 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:47.197737861 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:47.197737858 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> 2009-08-18 14:03:46.955504822 www.zvents.com/san-francisco-ca/events/show/80283482-steve-martin http-co<wbr>de 200</wbr></wbr></wbr></wbr></wbr></wbr></wbr>
Elapsed time: 0.01 s
Avg value size: 3.00 bytes
Avg key size: 66.00 bytes
Throughput: 68238.01 bytes/s
Total cells: 6
Throughput: 988.96 cells/s
hypertable> insert into Pages values (’2006-01-01 23:59:59′, “www.hypertable.org”, “refer-url”, “www.zvents.com”);
Elapsed time: 0.02 s
Avg value size: 14.00 bytes
Total cells: 1
Throughput: 53.94 cells/s
Resends: 0
hypertable> select * from Pages where ROW = “www.hypertable.org” DISPLAY_TIMESTAMPS;
2006-01-01 23:59:59.000000000 www.hypertable.org refer-url www.zvents.com
Elapsed time: 0.01 s
Avg value size: 14.00 bytes
Avg key size: 19.00 bytes
Throughput: 5936.32 bytes/s
Total cells: 1
Throughput: 179.89 cells/s
hypertable> delete * from Pages where ROW = “www.hypertable.org”;
Elapsed time: 0.01 s
Resends: 0
hypertable> select * from Pages where ROW = “www.hypertable.org”;
Elapsed time: 0.01 s
hypertable> insert into Pages values (’2037-01-01 23:59:59′, “www.hypertable.org”, “refer-url”, “www.zvents.com”);
Elapsed time: 0.02 s
Avg value size: 14.00 bytes
Total cells: 1
Throughput: 57.94 cells/s
Resends: 0
hypertable> delete * from Pages where ROW = “www.hypertable.org”;
Elapsed time: 0.01 s
Resends: 0
hypertable> select * from Pages where ROW = “www.hypertable.org” DISPLAY_TIMESTAMPS;
2037-01-01 23:59:59.000000000 www.hypertable.org refer-url www.zvents.com
Elapsed time: 0.00 s
Avg value size: 14.00 bytes
Avg key size: 19.00 bytes
Throughput: 2750000.00 bytes/s
Total cells: 1
Throughput: 83333.33 cells/s
hypertable> SHOW CREATE TABLE Pages;
CREATE TABLE Pages (
date,
‘refer-url’,
‘http-co<wbr>de’,<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> ACCESS GROUP default (date, ‘refer-url’, ‘http-co<wbr>de’)<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> )</wbr></wbr>
Elapsed time: 0.02 s
hypertable> ALTER TABLE Pages ADD(’load-time’, ‘error-message’, ACCESS GROUP stats(’load-time’)) DROP (’http-co<wbr>de’);</wbr>
Elapsed time: 0.04 s
hypertable> SHOW CREATE TABLE Pages;
CREATE TABLE Pages (
date,
‘refer-url’,
‘error-message’,
‘load-time’,
ACCESS GROUP default (date, ‘refer-url’, ‘http-co<wbr>de’, ‘error-message’),<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> ACCESS GROUP stats (’load-time’)<br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> )</wbr>
Elapsed time: 0.00 s
hypertable> describe table Pages;
<Schema generation=”2″>
<AccessGroup name=”default”>
<ColumnFamily id=”1″>
<Generation>1</Generation>
<Name>date</Name>
<deleted>false</deleted>
</ColumnFamily>
<ColumnFamily id=”2″>
<Generation>1</Generation>
<Name>refer-url</Name>
<deleted>false</deleted>
</ColumnFamily>
<ColumnFamily id=”3″>
<Generation>1</Generation>
<Name>http-co<wbr>de</Name><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <deleted>true</deleted><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </ColumnFamily><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <ColumnFamily id=”5″><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <Generation>2</Generation><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <Name>error-message</Name><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <deleted>false</deleted><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </ColumnFamily><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </AccessGroup><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <AccessGroup name=”stats”><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <ColumnFamily id=”4″><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <Generation>2</Generation><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <Name>load-time</Name><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> <deleted>false</deleted><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </ColumnFamily><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </AccessGroup><br style="padding-bottom:0px; margin:0px; padding-left:0px; padding-right:0px; padding-top:0px"> </Schema></wbr>
Elapsed time: 0.01 s
hypertable>
hypertable> show tables;
METADATA
Pages
Elapsed time: 0.01 s
hypertable> drop table Pages;
Elapsed time: 1.05 s
hypertable> show tables;
METADATA
Elapsed time: 0.00 s
hadoop@hadoop:~/hypertable/0.9.2.5$ hypertable
Welcome to the hypertable command interpreter.
For information about Hypertable, visithttp://www.hypertable.org/
Type ‘help’ for a list of commands, or ‘help shell’ for a
list of shell meta commands.
hypertable> source ./examples/hql_tutorial/Pages-create.hql;
Elapsed time: 1.11 s
Loading 10,872,957 bytes of input da<wbr>ta…</wbr>
0% 10 20 30 40 50 60 70 80 90 100%
|—-|—-|—-|—-|—-|—-|—-|—-|—-|—-|
***************************************************
Load complete.
Elapsed time: 3.65 s
Avg value size: 18.68 bytes
Avg key size: 48.70 bytes
Throughput: 5533544.02 bytes/s (2976538.01 bytes/s)
Total cells: 300000
Throughput: 82126.82 cells/s
Resends: 0
hypertable> drop table Pages;
Elapsed time: 0.05 s
hypertable> quit
hadoop@hadoop:~/hypertable/0.9.2.5$ hypertable –batch < examples/hql_tutorial/Pages-create.hql
hadoop@hadoop:~/hypertable/0.9.2.5$ hypertable
Welcome to the hypertable command interpreter.
For information about Hypertable, visithttp://www.hypertable.org/
Type ‘help’ for a list of commands, or ‘help shell’ for a
list of shell meta commands.
hypertable> show tables;
METADATA
Pages
Elapsed time: 0.01 s
hypertable>
更多的hql语法可以参考:http://www.hypertable.org/hql/index.html
其他更多功能体验待续。