mr

package
v0.0.0-...-c0e27fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Worker

func Worker(mapf func(string, string) []KeyValue, reducef func(string, []string) string)

main/mrworker.go calls this function.

Types

type KVArray

type KVArray []KeyValue

func (KVArray) Len

func (kv KVArray) Len() int

for sorting by KVArray

func (KVArray) Less

func (kv KVArray) Less(i, j int) bool

func (KVArray) Swap

func (kv KVArray) Swap(i, j int)

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

Map functions return a slice of KeyValue.

type Master

type Master struct {
	// contains filtered or unexported fields
}

func MakeMaster

func MakeMaster(files []string, nReduce int) *Master

create a Master and called by main/mrmaster.go

func (*Master) AssignMapTask

func (m *Master) AssignMapTask(args *RequestArgs, reply *ReplyArgs) error

assign map task to worker

func (*Master) AssignReduceTask

func (m *Master) AssignReduceTask(args *RequestArgs, reply *ReplyArgs) error

assign reduce task toi worker

func (*Master) Done

func (m *Master) Done() bool

main/mrmaster.go calls Done() periodically to find out if the entire job has finished.

func (*Master) ReceiveMapFinish

func (m *Master) ReceiveMapFinish(args *RequestArgs, reply *ReplyArgs) error

recevie map task finish from worker

func (*Master) ReceiveReduceFinish

func (m *Master) ReceiveReduceFinish(args *RequestArgs, reply *ReplyArgs) error

recevie reduce task finish from worker

type ReplyArgs

type ReplyArgs struct {
	// for map and reduce
	TaskNo int
	Done   bool

	// only for map task
	NumReduce int
	File      string

	// only for map task
	NumMap int
}

type RequestArgs

type RequestArgs struct {
	TaskNo int // task number of map and reduce
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL