mr

package
v0.0.0-...-e170996 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskMap    = 0
	TaskReduce = 1
	TaskWait   = 2
	TaskEnd    = 3
)

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 CallTaskDone

func CallTaskDone(taskInfo *TaskInfo)

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 MapTaskStat

type MapTaskStat struct {
	TaskStat
}

func (*MapTaskStat) GenerateTaskInfo

func (this *MapTaskStat) GenerateTaskInfo() TaskInfo

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

func (this *Master) AskTask(args *ExampleArgs, reply *TaskInfo) error

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

func (this *Master) TaskDone(args *TaskInfo, reply *ExampleReply) error

type ReduceTaskStat

type ReduceTaskStat struct {
	TaskStat
}

func (*ReduceTaskStat) GenerateTaskInfo

func (this *ReduceTaskStat) GenerateTaskInfo() TaskInfo

type TaskInfo

type TaskInfo struct {
	State int

	FileName  string
	FileIndex int
	PartIndex int

	NReduce int
	NFiles  int
}

func CallAskTask

func CallAskTask() *TaskInfo

type TaskStat

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

func (*TaskStat) GetFileIndex

func (this *TaskStat) GetFileIndex() int

func (*TaskStat) GetPartIndex

func (this *TaskStat) GetPartIndex() int

func (*TaskStat) OutOfTime

func (this *TaskStat) OutOfTime() bool

func (*TaskStat) SetNow

func (this *TaskStat) SetNow()

type TaskStatInterface

type TaskStatInterface interface {
	GenerateTaskInfo() TaskInfo
	OutOfTime() bool
	GetFileIndex() int
	GetPartIndex() int
	SetNow()
}

type TaskStatQueue

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

func (*TaskStatQueue) Lock

func (this *TaskStatQueue) Lock()

func (*TaskStatQueue) MoveAppend

func (this *TaskStatQueue) MoveAppend(rhs []TaskStatInterface)

func (*TaskStatQueue) Pop

func (this *TaskStatQueue) Pop() TaskStatInterface

func (*TaskStatQueue) Push

func (this *TaskStatQueue) Push(taskStat TaskStatInterface)

func (*TaskStatQueue) RemoveTask

func (this *TaskStatQueue) RemoveTask(fileIndex int, partIndex int)

func (*TaskStatQueue) Size

func (this *TaskStatQueue) Size() int

func (*TaskStatQueue) TimeOutQueue

func (this *TaskStatQueue) TimeOutQueue() []TaskStatInterface

func (*TaskStatQueue) Unlock

func (this *TaskStatQueue) Unlock()

type TryMapArgs

type TryMapArgs struct {
}

type TryMapReply

type TryMapReply struct {
	// if should not run map, so should run reduce
	RunMap bool
}

Jump to

Keyboard shortcuts

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