mr

package
v0.0.0-...-a70543b Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapTask    taskType = "MAP"
	ReduceTask          = "REDUCE"
	ExitTask            = "EXIT"
)
View Source
const (
	TO_BE_PROCESSED = iota
	PROCESSING
	PROCESSED
)

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 ByKey

type ByKey []KeyValue

Sort implementation for sorting by key

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 KeyValue

type KeyValue struct {
	Key   string
	Value string
}

Map functions return a slice of KeyValue.

type MRTaskArgs

type MRTaskArgs struct{}

Add your RPC definitions here.

type MRTaskReply

type MRTaskReply struct {
	MapTaskID    int
	ReduceTaskID int
	NReduce      int
	NMapTasks    int
	File         string
	TaskType     taskType
}

type MRTaskUpdate

type MRTaskUpdate struct {
	MapTaskID    int
	ReduceTaskID int
	Success      bool
	TaskType     taskType
}

type Master

type Master struct {
	MapTasks       map[int]Task
	ReduceTasks    map[int]Task
	NMapTasks      int
	NReduce        int
	HasFinishedJob bool
	Mu             sync.Mutex // the master has a Mutex instance because we want one mutex to share amongst workers, and not a different instance each time a function is called
}

func MakeMaster

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

create a Master. Type: constructor 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) RequestTask

func (m *Master) RequestTask(args *MRTaskArgs, reply *MRTaskReply) (err error)

func (*Master) UpdateMapTask

func (m *Master) UpdateMapTask(args *MRTaskUpdate, reply *MRTaskUpdate) error

func (*Master) UpdateReduceTask

func (m *Master) UpdateReduceTask(args *MRTaskUpdate, reply *MRTaskUpdate) error

type Task

type Task struct {
	ID    int
	File  string
	State int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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