This is the implementation of 6.824 Lab1 MapReduce

Part 1: Map/Reduce and output What you have to do is to finish the two function doMap() and doReduce() Each call to doMap() reads the appropriate file, calls the map function on that file’s contents, and writes the resulting key/value pairs to nReduce intermediate files. doMap() hashes each key to pick the intermediate file and thus the reduce task that will process the key. There will be nMap x nReduce files after all map tasks are done....

January 19, 2018 · 12 min · 2441 words · Me

Docker introduction

Docker introduction different with virtual machine CONTAINERS Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), and start almost instantly. VIRTUAL MACHINES Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers....

4 min · 788 words · Me

Go 的定时器的使用

time.Newtimer 函数 初始化一个到期时间据此时的间隔为 3 小时 30 分的定时器 t := time.Newtimer(3time.Hour + 30time.Minute) 注意,这里的变量 t 是 * time.NewTimer 类型的,这个指针类型的方法集合包含两个方法 Rest 用于重置定时器 该方法返回一个 bool 类型的值 Stop 用来停止定时器 该方法返回一个 bool 类型的值,如果返回 false,说明该定时器在之前已经到期或者已经被停止了, 反之返回 true。 通过定时器的字段 C, 我们可以及时得知定时器到期的这个事件来临,C 是一个 chan time.Time 类型的缓冲通道 ,一旦触及到期时间,定时器就会向自己的 C 字段发送一个 time.Time 类型的元素值 package main import ( "fmt" "time" ) func main(){ // 初始化定时器 t := time.NewTimer(2 * time.Second) // 当前时间 now := time.Now() fmt.Printf("Now time : %v.\n", now) expire := <- t....

3 min · 530 words · Me