mr

package
v0.0.0-...-d610aed Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintLog

func PrintLog(msg string)

func PrintLog2

func PrintLog2(msg string)

func Worker

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

main/mrworker.go calls this function.

Types

type ByKey

type ByKey []KeyValue

func (ByKey) Len

func (a ByKey) Len() int

func (ByKey) Less

func (a ByKey) Less(i, j int) bool

func (ByKey) Swap

func (a ByKey) Swap(i, j int)

type ExampleArgs

type ExampleArgs struct {
	X int
}

type ExampleReply

type ExampleReply struct {
	Y 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. main/mrmaster.go calls this function. nReduce is the number of reduce tasks to use.

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) Example

func (m *Master) Example(args *ExampleArgs, reply *ExampleReply) error

an example RPC handler.

the RPC argument and reply types are defined in rpc.go.

func (*Master) NextSerial

func (m *Master) NextSerial() int

func (*Master) WorkerFinish

func (m *Master) WorkerFinish(args *WorkerReportArgs, reply *WorkerReportReply) error

func (*Master) WorkerRegister

func (m *Master) WorkerRegister(args *WorkerAskArgs, reply *WorkerAskReply) error

type SerialLog

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

type WorkerAskArgs

type WorkerAskArgs struct {
	Name string
}

Add your RPC definitions here. # Worker ask for task

type WorkerAskReply

type WorkerAskReply struct {
	TaskType  string   // map | reduce | wait
	FilePaths []string // map: [from_file_path]
	// reduce: [mapped_files, ...]
	ReducerNo int
	MapperNo  int

	TotReduce int
	Serial    int
}

func CallRegister

func CallRegister() (WorkerAskReply, bool)

call register

type WorkerReportArgs

type WorkerReportArgs struct {
	Success  bool
	TaskType string
	Serial   int

	FilePaths []string
	// mapper
	MapperNo int
	// reducer
	ReducerNo int
}

Worker finish work

type WorkerReportReply

type WorkerReportReply struct {
}

func CallResult

func CallResult(args WorkerReportArgs) (WorkerReportReply, bool)

call result

Jump to

Keyboard shortcuts

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