Documentation ¶
Overview ¶
Package cnp includes concurrence and parallel tools
mapreduce core source from go-zero
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCancelWithNil is an error that mapreduce was cancelled with nil. ErrCancelWithNil = errors.New("mapreduce cancelled with nil") // ErrReduceNoOutput is an error that reduce did not output a value. ErrReduceNoOutput = errors.New("reduce not writing value") )
Functions ¶
func MapReduce ¶
func MapReduce(gen GenerateFunc, opts ...Option) *mapReduce
MapReduce runs mapper and reducer, is the entry method of mapreduce
func NotifyDone ¶
func NotifyDone(writer Writer)
NotifyDone notify the process,reduce has done. if you reduce function do not output value ,you must call this method
Types ¶
type GenerateFunc ¶
type GenerateFunc func(source chan<- any)
GenerateFunc is used to let callers send elements into source.
type MapperFunc ¶
MapperFunc is used to do element processing and write the output to writer, use cancel func to cancel the processing.
type Option ¶
type Option func(opts *mapReduceOptions)
Option defines the method to customize the mapreduce.
func WithContext ¶ added in v0.1.0
WithContext customizes a mapreduce processing accepts a given ctx.
func WithWorkers ¶
WithWorkers customizes a mapreduce processing with given workers.
type ReducerFunc ¶
ReducerFunc is used to reduce all the mapping output and write to writer, use cancel func to cancel the processing.