mr

package
v0.0.0-...-40d0814 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapPhase = iota
	ReducePhase
)

Variables

This section is empty.

Functions

func CallExample

func CallExample()

example function to show how to make an RPC call to the master.

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

func FinishJob

func FinishJob(job Job)

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

for sorting by key.

func (ByKey) Len

func (a ByKey) Len() int

for sorting by key.

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 FinishReply

type FinishReply struct {
	Succeed bool
}

type Job

type Job struct {
	Type        JobType
	MapFileName string
	// Result string
	Index   int
	NReduce int
	NMap    int
}

func TakeJob

func TakeJob() Job

TakeJob takes a job from master, it could be map or reduce job.

type JobDoneReply

type JobDoneReply struct {
}

type JobType

type JobType int
const (
	ShutdownJob JobType = iota
	MapJob
	ReduceJob
)

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

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 NewMaster

func NewMaster(files []string, maxJobNum int, to int64, nreduce int) *Master

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

func (m *Master) Finish(job Job, reply *FinishReply) error

func (*Master) TakeJob

func (m *Master) TakeJob(args *TakeJobArgs, job *Job) error

func (*Master) WaitAll

func (m *Master) WaitAll()

WaitAll only for testing

type MasterPhase

type MasterPhase int

type TakeJobArgs

type TakeJobArgs struct {
}

type WorkerJob

type WorkerJob struct {
	Type JobType
	Name string
}

Jump to

Keyboard shortcuts

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