65 | | |
66 | | = Practice 2 : Word Count (Advanced) = |
67 | | |
68 | | {{{ |
69 | | $ echo "\." >pattern.txt && echo "\," >>pattern.txt |
70 | | $ hadoop fs -put pattern.txt . |
71 | | $ mkdir -p MyJava2 |
72 | | }}} |
73 | | |
74 | | |
75 | | * 下載 [http://hadoop.nchc.org.tw/WordCount2.java WordCount2.java] 並存到家目錄;[[BR]]Download [http://hadoop.nchc.org.tw/WordCount2.java WordCount2.java] to home directory |
76 | | {{{ |
77 | | ~$ wget http://hadoop.nchc.org.tw/WordCount2.java |
78 | | }}} |
79 | | |
80 | | {{{ |
81 | | $ javac -classpath hadoop-core.jar -d MyJava2 WordCount2.java |
82 | | $ jar -cvf wordcount2.jar -C MyJava2 . |
83 | | $ hadoop jar wordcount2.jar WordCount2 lab8_input lab8_out2 -skip pattern.txt |
84 | | $ hadoop fs -cat lab8_out2/part-00000 |
85 | | }}} |
86 | | |
87 | | * lab8_out2 執行結果[[BR]]You should see results like this: |
88 | | {{{ |
89 | | #!text |
90 | | Cloud 2 |
91 | | Course 2 |
92 | | I 2 |
93 | | NCTU 1 |
94 | | and 1 |
95 | | course 1 |
96 | | enjoy 1 |
97 | | like 2 |
98 | | nctu 1 |
99 | | this 1 |
100 | | we 1 |
101 | | }}} |
102 | | |
103 | | * Let's given case insensitive and ignore pattern for this example |
104 | | {{{ |
105 | | $ hadoop jar wordcount2.jar WordCount2 -Dwordcount.case.sensitive=false lab8_input lab8_out3 -skip pattern.txt |
106 | | $ hadoop fs -cat lab8_out3/part-00000 |
107 | | }}} |
108 | | |
109 | | * lab8_out3 執行結果[[BR]]You should see results like this: |
110 | | {{{ |
111 | | #!text |
112 | | and 1 |
113 | | cloud 2 |
114 | | course 3 |
115 | | enjoy 1 |
116 | | i 2 |
117 | | like 2 |
118 | | nctu 2 |
119 | | this 1 |
120 | | we 1 |
121 | | }}} |