LAB1 partV
partV


bash ./test-ii.sh 直接测试程序结果。
ii.go
package main import (
"os"
"strings"
"unicode"
"strconv"
)
import "fmt"
import "mapreduce" // The mapping function is called once for each piece of the input.
// In this framework, the key is the name of the file that is being processed,
// and the value is the file's contents. The return value should be a slice of
// key/value pairs, each represented by a mapreduce.KeyValue.
func mapF(document string, value string) (res []mapreduce.KeyValue) {
// Your code here (Part V).
f := func(c rune) bool {
return !unicode.IsLetter(c)
}
rst := make([]mapreduce.KeyValue, ) keys := strings.FieldsFunc(value, f)
for _, key := range keys {
kv := mapreduce.KeyValue{ Key: key, Value:document}
rst = append(rst, kv)
}
return rst
} // The reduce function is called once for each key generated by Map, with a
// list of that key's string value (merged across all inputs). The return value
// should be a single output value for that key.
func reduceF(key string, values []string) string {
// Your code here (Part V).
vm := make(map[string]string)
var rst []string
for _, value := range values {
if _, ok := vm[value]; !ok {
rst = append(rst, value)
vm[value] = value
}
} vl := strings.Join(rst, ",")
return strconv.Itoa(len(rst)) + " " + vl
} // Can be run in 3 ways:
// 1) Sequential (e.g., go run wc.go master sequential x1.txt .. xN.txt)
// 2) Master (e.g., go run wc.go master localhost:7777 x1.txt .. xN.txt)
// 3) Worker (e.g., go run wc.go worker localhost:7777 localhost:7778 &)
func main() {
if len(os.Args) < {
fmt.Printf("%s: see usage comments in file\n", os.Args[])
} else if os.Args[] == "master" {
var mr *mapreduce.Master
if os.Args[] == "sequential" {
mr = mapreduce.Sequential("iiseq", os.Args[:], , mapF, reduceF)
} else {
mr = mapreduce.Distributed("iiseq", os.Args[:], , os.Args[])
}
mr.Wait()
} else {
mapreduce.RunWorker(os.Args[], os.Args[], mapF, reduceF, , nil)
}
}
上面LAB1 五部分一起测试。
LABI 完成。
LAB1 partV的更多相关文章
- 6.828 lab1 bootload
MIT6.828 lab1地址:http://pdos.csail.mit.edu/6.828/2014/labs/lab1/ 第一个练习,主要是让我们熟悉汇编,嗯,没什么好说的. Part 1: P ...
- Machine Learning #Lab1# Linear Regression
Machine Learning Lab1 打算把Andrew Ng教授的#Machine Learning#相关的6个实验一一实现了贴出来- 预计时间长度战线会拉的比較长(毕竟JOS的7级浮屠还没搞 ...
- ucore lab1 bootloader学习笔记
---恢复内容开始--- 开机流程回忆 以Intel 80386为例,计算机加电后,CPU从物理地址0xFFFFFFF0(由初始化的CS:EIP确定,此时CS和IP的值分别是0xF000和0xFFF0 ...
- 6.824 LAB1 环境搭建
MIT 6.824 LAB1 环境搭建 vmware 虚拟机 linux ubuntu server 安装 go 官方安装步骤: 下载此压缩包并提取到 /usr/local 目录,在 /usr/l ...
- 软件测试:lab1.Junit and Eclemma
软件测试:lab1.Junit and Eclemma Task: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma wi ...
- MIT 6.824 lab1:mapreduce
这是 MIT 6.824 课程 lab1 的学习总结,记录我在学习过程中的收获和踩的坑. 我的实验环境是 windows 10,所以对lab的code 做了一些环境上的修改,如果你仅仅对code 感兴 ...
- 清华大学OS操作系统实验lab1练习知识点汇总
lab1知识点汇总 还是有很多问题,但是我觉得我需要在查看更多资料后回来再理解,学这个也学了一周了,看了大量的资料...还是它们自己的80386手册和lab的指导手册觉得最准确,现在我就把这部分知识做 ...
- JOS lab1 part2 分析
lab1的Exercise 2就是让我们熟悉gdb的si操作,并知道BIOS的几条指令在做什么就够了,所以我们也会尽可能的去分析每一行代码. 首先进入到6.8282/lab这个目录下,输入指令make ...
- MIT 操作系统实验 MIT JOS lab1
JOS lab1 首先向MIT还有K&R致敬! 没有非常好的开源环境我不可能拿到这么好的东西. 向每个与我一起交流讨论的programmer致谢!没有道友一起死磕.我也可能会中途放弃. 跟丫死 ...
随机推荐
- stand up
#version_s#1.7#version_e# #update_s#https://files.cnblogs.com/files/dyh221/update.zip#update_e#
- 大数字加法(hduoj)
Problem Description I have a very simple problem for you. Given two integers A and B, your job is to ...
- Java学习笔记(7)
File类用于处理文件和目录 isDirectory()用于检查当前对象是否目录,isFile()用于检查当前对象是否文件 构造File对象时,传入的路径不一定要求存在,要通过exists()方法判断 ...
- Linux 驱动——Button8(输入子系统)
输入子系统由驱动层.输入子系统核心.事件处理层三部分组成.一个输入事件,如鼠标移动.键盘按下等通过Driver->Inputcore->Event handler->userspac ...
- SpringBoot四种读取properties文件的方式
环境:IDEA jdk1.8 SpringBoot2.1.4 例,如下默认application.properties文件 一.使用`@ConfigurationProperties`注解将配置文 ...
- Struts2 action 跳转到web-inf下,
初学,这个问题困扰了1天.刚开始以为代码或者是配置文件哪里写错了,仔细检查了好几遍确定代码没有错,实在没办法了,准备发帖求助.就在我截图的时候,突然发现我的@Action中有点别扭,即使他没有报错. ...
- There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 异常
今天在使用mybatis时,出现了一个问题:There is no getter for property named 'user' in 'class com.jyr.wh.domain.User, ...
- jsonModel使用
流弊的JSON数据模型框架 https://github.com/jsonmodel/jsonmodel 版本 1.3.0 如果你喜欢JSONModel,并且使用了它,请你: star一下 给我一些反 ...
- 大学生对vivo手机的看法
- 代码中设置color的selector
//应该用getColorStateList这种方式 xml中设置时直接color引用就可以了 textView.setTextColor(getResources().getColorStateLi ...