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致谢!没有道友一起死磕.我也可能会中途放弃. 跟丫死 ...
随机推荐
- C#控件之ComboBox控件使用
首先如果要给ComboBox控件输入要显示的内容,方法是点击控件会显示如下图所示: 然后点击”编辑项”,如下所示: 下面在这里输入控件要显示的内容,即可. 如果要让ComboBox控件设置默认显示项, ...
- git特殊命令
1.git追踪远程分支,该命令使用Tab不会自动补全 git branch --set-upstream-to=远程分支名(origin/xxx) 2.从远程分支创建本地新分支 git checkou ...
- 20155208徐子涵 Exp 6 信息搜集与漏洞扫描
20155208徐子涵 Exp 6 信息搜集与漏洞扫描 实验目的 掌握信息搜集的最基础技能与常用工具的使用方法 实验内容 (1)各种搜索技巧的应用 (2)DNS IP注册信息的查询 (3)基本的扫描技 ...
- Mechanism:Limited Direct Execution
虚拟化机制的几大挑战:1.性能.在实现虚拟化的同时不增加系统过多开销.2.控制.高效运行程序的同时对CPU保持控制(对资源的管理). Limited direct execution:直接在CPU中运 ...
- PTA——近似求PI
PTA 7-50 近似求PI 网友代码: include <stdio.h> int main(){ , i, temp=; scanf("%le", &eps ...
- 理解 if __name__ == '__main__'
简单地理解Python中的if __name__ == '__main__' if __name__ == '__main__'的意思是: 当.py文件被直接运行时,if __name__ == '_ ...
- 在ubuntu服务器上安装tomcat 9
前提条件: 确保ubuntu服务器上 已经安装 java 8 或更高版本,安装java8可以参考我的另一篇博文 通过 ppa 在ubuntu server 上安装java 8 java -versio ...
- 网络操作基础(one)
P12 一.什么是网络操作系统?网络操作系统具有哪些基本功能? 二.网络操作系统具有哪些特征? 三.常用的网络操作系统有哪些?它们各具有什么特点? 四.在网络操作系统中主要可提供哪些? ———— —— ...
- Java CAS同步机制 原理详解(为什么并发环境下的COUNT自增操作不安全): Atomic原子类底层用的不是传统意义的锁机制,而是无锁化的CAS机制,通过CAS机制保证多线程修改一个数值的安全性。
精彩理解: https://www.jianshu.com/p/21be831e851e ; https://blog.csdn.net/heyutao007/article/details/19 ...
- 修改应用进程open file值
本文用于记录java应用日志too many open files报错解决方法 操作系统:RHEL5.8 一.修改配置文件 1.vim /etc/security/limits.conf 加上:* s ...