浏览代码

core/mr:a little optimization for collector initialization in ForEach function (#1937)

Co-authored-by: notrynosuccess <daihongshan@gmail.com>
NoTryNoSuccess 2 年之前
父节点
当前提交
fb519fa547
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      core/mr/mapreduce.go

+ 2 - 2
core/mr/mapreduce.go

@@ -102,12 +102,12 @@ func ForEach(generate GenerateFunc, mapper ForEachFunc, opts ...Option) {
 	options := buildOptions(opts...)
 	panicChan := &onceChan{channel: make(chan interface{})}
 	source := buildSource(generate, panicChan)
-	collector := make(chan interface{}, options.workers)
+	collector := make(chan interface{})
 	done := make(chan lang.PlaceholderType)
 
 	go executeMappers(mapperContext{
 		ctx: options.ctx,
-		mapper: func(item interface{}, writer Writer) {
+		mapper: func(item interface{}, _ Writer) {
 			mapper(item)
 		},
 		source:    source,