已知 MapReduce 程序代码块为: public static class UserMapper extends Mapper<LongWritable, Text, Text, Text> {     public void map(LongWritable key, Text value, Context context) {         try {             String line = value.toString();             String[] words = line.split(“,”);             String userName = words[0];             String friendName = words[1];             context.write(new Text(userName), new Text(friendName));             context.write(new Text(friendName), new Text(userName));         } catch (Exception e) {             e.printStackTrace();         }     } } public static class UserReducer extends Reducer<Text, Text, Text, Text> {     List<String> userList = new LinkedList<String>();     Map<String, Integer> userFriends = new HashMap<String, Integer>();     public void reduce(Text key, Iterable<Text> values, Context context) {         try {             String userName = key.toString();             if(!userList.contains(userName)){                 userList.add(userName);             }             List<String> friendsList = new ArrayList<String>();             for (Text value : values) {                 String friendName=value.toString();                 if(!friendsList.contains(friendName)){                     friendsList.add(friendName);                 }             }             userFriends.put(userName,friendsList.size());         } catch (Exception e) {             e.printStackTrace();         }     }     protected void cleanup(Context context) {         try {             int userCout = userList.size();             Iterator<Map.Entry<String, Integer>> itr=userFriends.entrySet().iterator();             while (itr.hasNext()){                 Map.Entry<String, Integer> word=itr.next();                 String key=word.getKey();                 int value=word.getValue();                 DecimalFormat df=new DecimalFormat(“0.00”);                 context.write(new Text(key), new Text(df.format((float)value/userCout)));             }         } catch (Exception e) {             e.printStackTrace();         }     } } 内容如下的文件经过该程序处理后的输出结果为() 张三,赵八 李四,陈七 王五,陈七 钱六,张三 陈七,钱六 赵八,李四

区块链毕设网qklbishe.com为您提供问题的解答

已知 MapReduce 程序代码块为:
public static class UserMapper extends Mapper<LongWritable, Text, Text, Text> {      public void map(LongWritable key, Text value, Context context) {         try {             String line = value.toString();             String[] words = line.split(",");             String userName = words[0];             String friendName = words[1];             context.write(new Text(userName), new Text(friendName));             context.write(new Text(friendName), new Text(userName));         } catch (Exception e) {             e.printStackTrace();         }     } }  public static class UserReducer extends Reducer<Text, Text, Text, Text> {     List<String> userList = new LinkedList<String>();     Map<String, Integer> userFriends = new HashMap<String, Integer>();      public void reduce(Text key, Iterable<Text> values, Context context) {         try {             String userName = key.toString();             if(!userList.contains(userName)){                 userList.add(userName);             }              List<String> friendsList = new ArrayList<String>();             for (Text value : values) {                 String friendName=value.toString();                 if(!friendsList.contains(friendName)){                     friendsList.add(friendName);                 }             }             userFriends.put(userName,friendsList.size());         } catch (Exception e) {             e.printStackTrace();         }     }      protected void cleanup(Context context) {         try {             int userCout = userList.size();             Iterator<Map.Entry<String, Integer>> itr=userFriends.entrySet().iterator();             while (itr.hasNext()){                 Map.Entry<String, Integer> word=itr.next();                 String key=word.getKey();                 int value=word.getValue();                 DecimalFormat df=new DecimalFormat("0.00");                 context.write(new Text(key), new Text(df.format((float)value/userCout)));             }          } catch (Exception e) {             e.printStackTrace();         }      } }

内容如下的文件经过该程序处理后的输出结果为()

张三,赵八 李四,陈七 王五,陈七 钱六,张三 陈七,钱六 赵八,李四

我怎么感觉应该是李四而不是赵四
09:13

以上就是关于问题已知 MapReduce 程序代码块为: public static class UserMapper extends Mapper<LongWritable, Text, Text, Text> {     public void map(LongWritable key, Text value, Context context) {         try {             String line = value.toString();             String[] words = line.split(“,”);             String userName = words[0];             String friendName = words[1];             context.write(new Text(userName), new Text(friendName));             context.write(new Text(friendName), new Text(userName));         } catch (Exception e) {             e.printStackTrace();         }     } } public static class UserReducer extends Reducer<Text, Text, Text, Text> {     List<String> userList = new LinkedList<String>();     Map<String, Integer> userFriends = new HashMap<String, Integer>();     public void reduce(Text key, Iterable<Text> values, Context context) {         try {             String userName = key.toString();             if(!userList.contains(userName)){                 userList.add(userName);             }             List<String> friendsList = new ArrayList<String>();             for (Text value : values) {                 String friendName=value.toString();                 if(!friendsList.contains(friendName)){                     friendsList.add(friendName);                 }             }             userFriends.put(userName,friendsList.size());         } catch (Exception e) {             e.printStackTrace();         }     }     protected void cleanup(Context context) {         try {             int userCout = userList.size();             Iterator<Map.Entry<String, Integer>> itr=userFriends.entrySet().iterator();             while (itr.hasNext()){                 Map.Entry<String, Integer> word=itr.next();                 String key=word.getKey();                 int value=word.getValue();                 DecimalFormat df=new DecimalFormat(“0.00”);                 context.write(new Text(key), new Text(df.format((float)value/userCout)));             }         } catch (Exception e) {             e.printStackTrace();         }     } } 内容如下的文件经过该程序处理后的输出结果为() 张三,赵八 李四,陈七 王五,陈七 钱六,张三 陈七,钱六 赵八,李四的答案

欢迎关注区块链毕设网-
web3一级市场套利打新赚钱空投教程

区块链NFT链游项目方科学家脚本开发培训

从业7年-专注一级市场


微信:btc9767
TELEGRAM :https://t.me/btcok9

具体资料介绍

web3的一级市场千万收益的逻辑


进群点我



qklbishe.com区块链毕设代做网专注|以太坊fabric-计算机|java|毕业设计|代做平台-javagopython毕设 » 已知 MapReduce 程序代码块为: public static class UserMapper extends Mapper<LongWritable, Text, Text, Text> {     public void map(LongWritable key, Text value, Context context) {         try {             String line = value.toString();             String[] words = line.split(“,”);             String userName = words[0];             String friendName = words[1];             context.write(new Text(userName), new Text(friendName));             context.write(new Text(friendName), new Text(userName));         } catch (Exception e) {             e.printStackTrace();         }     } } public static class UserReducer extends Reducer<Text, Text, Text, Text> {     List<String> userList = new LinkedList<String>();     Map<String, Integer> userFriends = new HashMap<String, Integer>();     public void reduce(Text key, Iterable<Text> values, Context context) {         try {             String userName = key.toString();             if(!userList.contains(userName)){                 userList.add(userName);             }             List<String> friendsList = new ArrayList<String>();             for (Text value : values) {                 String friendName=value.toString();                 if(!friendsList.contains(friendName)){                     friendsList.add(friendName);                 }             }             userFriends.put(userName,friendsList.size());         } catch (Exception e) {             e.printStackTrace();         }     }     protected void cleanup(Context context) {         try {             int userCout = userList.size();             Iterator<Map.Entry<String, Integer>> itr=userFriends.entrySet().iterator();             while (itr.hasNext()){                 Map.Entry<String, Integer> word=itr.next();                 String key=word.getKey();                 int value=word.getValue();                 DecimalFormat df=new DecimalFormat(“0.00”);                 context.write(new Text(key), new Text(df.format((float)value/userCout)));             }         } catch (Exception e) {             e.printStackTrace();         }     } } 内容如下的文件经过该程序处理后的输出结果为() 张三,赵八 李四,陈七 王五,陈七 钱六,张三 陈七,钱六 赵八,李四