第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

求大神詳解,不太懂

求大神詳解,不太懂

Youruncle 2016-12-22 19:43:18
package com.zkpk.us;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.Path;import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.LongWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Job;import org.apache.hadoop.mapreduce.Mapper;import org.apache.hadoop.mapreduce.Reducer;import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;class UserMapper extends Mapper<LongWritable, Text, Text, IntWritable> { protected void map( LongWritable key, Text value, org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws java.io.IOException, InterruptedException { IntWritable one = new IntWritable(1); String[] columns = value.toString().split("\t"); if (columns != null && columns.length == 6) { Text uid = new Text(columns[1]); context.write(uid, one); } };}class UserReducer extends Reducer<Text, IntWritable, Text, IntWritable> { protected void reduce( Text key, java.lang.Iterable<IntWritable> values, org.apache.hadoop.mapreduce.Reducer<Text, IntWritable, Text, IntWritable>.Context context) throws java.io.IOException, InterruptedException { int sum = 0; for(IntWritable value : values){ sum += value.get(); } context.write(key, new IntWritable(sum)); };}public class UserCount { /** * @param args */ public static void main(String[] args)throws Exception { Configuration conf = new Configuration(); Job job = new Job(conf, "UserUid"); job.setJarByClass(UserCount.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); job.setMapperClass(UserMapper.class); job.setReducerClass(UserReducer.class); FileInputFormat.addInputPath(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); job.waitForCompletion(true); }}
查看完整描述

3 回答

?
gyf451

TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個(gè)贊

這是hadoop的wordCount程序啊,對(duì)input文件下的文檔單詞分類計(jì)數(shù),你在hadoop output 文件夾下可以看到,每個(gè)單詞出現(xiàn)的頻數(shù)

查看完整回答
反對(duì) 回復(fù) 2017-01-09
?
趙強(qiáng)老師

TA貢獻(xiàn)10條經(jīng)驗(yàn) 獲得超14個(gè)贊

這是MapReduce程序,是Hadoop處理數(shù)據(jù)的核心。程序有三部分組成:

第一部分:Map。表示將數(shù)據(jù)進(jìn)行分詞處理,分隔符是制表鍵

第二部分:Reduce。將Map的輸出進(jìn)行匯總,得到最后的輸出。

第三部分:主程序。將Map和Reduce組成一個(gè)任務(wù)job,來(lái)執(zhí)行,數(shù)據(jù)的輸入和輸出都來(lái)至于HDFS。

有問(wèn)題,可以再問(wèn)我。呵呵

查看完整回答
反對(duì) 回復(fù) 2016-12-27
?
_白駒過(guò)隙_

TA貢獻(xiàn)37條經(jīng)驗(yàn) 獲得超15個(gè)贊

直接說(shuō) 什么問(wèn)題

? ? 直接貼代碼 ?不想看

查看完整回答
反對(duì) 回復(fù) 2016-12-26
  • 3 回答
  • 0 關(guān)注
  • 1443 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)