mr

package
v0.0.0-...-b57df3e Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnAllocated = iota
	Allocated
	Finished
)

file status

View Source
const (
	MsgForStartTask = iota
	MsgForFinishMap
	MsgForFinishReduce
)

MessageType

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

Map functions return a slice of KeyValue.

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 KeyValue

type KeyValue struct {
	Key   string
	Value string
}

type Master

type Master struct {
	BeginningFile       []string
	MapTaskNum          int
	BeginningFileStatus map[string]int
	MapFinished         bool

	NReduce         int
	InterFile       [][]string
	InterFileStatus map[int]int
	ReduceFinished  bool

	RWLock *sync.RWMutex
}

Master...

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

func (*Master) HandleCallForInterFile

func (m *Master) HandleCallForInterFile(args *MyIntermediateFile, reply *MyReply) error

func (*Master) HandleCallForTask

func (m *Master) HandleCallForTask(args *MyArgs, reply *MyReply) error

RPC handler...

type MyArgs

type MyArgs struct {
	MachineName string
	MessageType int
	FileName    string
}

type MyIntermediateFile

type MyIntermediateFile struct {
	MachineName string
	Index       int
	FileName    string
}

send intermediate files' filename to master

type MyReply

type MyReply struct {
	Filename           string // get a filename
	MapNumAllocated    int
	NReduce            int
	ReduceNumAllocated int
	TaskType           string
	ReduceFileList     []string // File list about
}

func CallForTask

func CallForTask(MessageType int, fileName string) MyReply

Jump to

Keyboard shortcuts

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