mr

package
v0.0.0-...-61a12ff Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TaskCompleted

func TaskCompleted(task *Task)

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 KeyValue

type KeyValue struct {
	Key   string
	Value string
}

Map functions return a slice of KeyValue.

type Master

type Master struct {
	TaskQueue     chan *Task          // 等待执行的task
	TaskMeta      map[int]*MasterTask // 当前所有task的信息
	MasterPhase   State               // Master的阶段
	NReduce       int
	InputFiles    []string
	Intermediates [][]string // Map任务产生的R个中间文件的信息
}

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

func (m *Master) AssignTask(args *ExampleArgs, reply *Task) error

master等待worker调用

func (*Master) Done

func (m *Master) Done() bool

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

func (*Master) TaskCompleted

func (m *Master) TaskCompleted(task *Task, reply *ExampleReply) error

type MasterTask

type MasterTask struct {
	TaskStatus    MasterTaskStatus
	StartTime     time.Time
	TaskReference *Task
}

type MasterTaskStatus

type MasterTaskStatus int
const (
	Idle MasterTaskStatus = iota
	InProgress
	Completed
)

type State

type State int
const (
	Map State = iota
	Reduce
	Exit
	Wait
)

type Task

type Task struct {
	Input         string
	TaskState     State
	NReducer      int
	TaskNumber    int
	Intermediates []string
	Output        string
}

Jump to

Keyboard shortcuts

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