_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › Pig
|
|
[edit]
2 一危 詞伎 HDFS j鍵 #HADOOP 覯所企 一危 れ企 HDFS 襴磯.
wget http://hanb.co.kr/exam/1746/htdg-examples-0.1.1.tar.gz tar htdg-examples-0.1.1.tar.gz mv htdg-examples-0.1.1 samples cd samples hadoop fs -put input input [edit]
3 pig ろ襴渚 ろ螻 れ 貎朱Μ ろ螻 store #vi store_test.pig
--store_test.pig rmf output/1949 rmf output/1950 A = LOAD 'input/ncdc/micro-tab/sample.txt' AS (year:chararray, temperature:int, quality:int); B = FILTER A BY year == '1949'; C = FILTER A BY year == '1950'; STORE B INTO 'output/1949'; STORE C INTO 'output/1950'; cat output/1949/part-m-00000 cat output/1950/part-m-00000ろ襴渚 覈襦 ろ覃 A襦覿 2覯 曙 . pig ろ襴渚碁ゼ ろ.
pig store_test.pig 蠏碁壱語 exec run 碁Μ磯ゼ . exec 覦一 覈願, run 覓語ル(;襦 )襦 ろ (?) 覈. 谿企 れ貎朱Μ 豕(A襯 覯襷 暑讌 覯 暑讌 谿, exec螳 覯襷 曙).
grunt> exec store_test.pig grunt> run store_test.pig [edit]
5 sample data input #wget http://databaser.net/moniwiki/pds/Hive_ec_98_88_ec_a0_9c_ed_8c_8c_ec_9d_bc/data.zip unzip data.zip hadoop fs -mkdir scott hadoop fs -put dept.csv scott hadoop fs -put emp.csv scott hadoop fs -put salgrade.csv scott pig emp = load 'scott/emp.csv' using PigStorage(',') as (empno, ename, job, mgr, hiredate, sal, comm, deptno:int); grouped = group emp by deptno; total = foreach grouped generate group, SUM(emp.sal) as total_sal; --total = foreach grouped generate emp.depno, SUM(emp.sal) as total_sal; dept = load 'scott/dept.csv' using PigStorage(',') as (dname, loc, deptno:int); join_data = join total by group left, dept by deptno; view = foreach join_data generate $0, $3, $1; dump view; emp = load 'scott/emp.csv' using PigStorage(',') as (empno, ename, job, mgr, hiredate, sal, comm, deptno:int); emp = foreach emp generate ename, sal; filtered_set = filter emp by sal >= 2000; sorted_set = order filtered_set by sal desc; top3 = limit sorted_set 3; dump top3;
鏤
|
螳る所 谿 蟇磯 語 . () |