kevwan / mapreduce Goto Github PK
View Code? Open in Web Editor NEWA in-process MapReduce library to help you optimizing service response time or concurrent task processing.
Home Page: https://go-zero.dev
License: MIT License
A in-process MapReduce library to help you optimizing service response time or concurrent task processing.
Home Page: https://go-zero.dev
License: MIT License
嵌套的MapReduce
的reducer
中如果不调用writer.Write
方法,会产生一个ErrReduceNoOutput
错误,Finish 中 worker 返回异常会直接结束 Finish 调用,但是Finish
中调用的MapReduceVoid
会吞掉ErrReduceNoOutput
错误返回一个 nil,从最后结果看是没有异常的成功调用,实际其他的 worker
都还在异步运行
例如下面这样的调用:
func main(){
err := mapreduce.Finish(func() error {
return worker1()
}, func() error {
val, err := mapreduce.MapReduce(func(source chan<- interface{}) {
for i := 0;i<10;i++{
source <- i
}
}, func(item interface{}, writer mapreduce.Writer, cancel func(error)) {
i := item.(int)
writer.Write(i * i)
}, func(pipe <-chan interface{}, writer mapreduce.Writer, cancel func(error)) {
var cnt int
for i := range pipe{
cnt += i.(int)
}
// 这里不调用Write 会导致当前这个 worker 任务返回一个异常
// writer.Write(cnt)
})
// 收到一个异常 `ErrReduceNoOutput`
if err != nil {
return err
}
fmt.Println("result:", val)
})
// 这里的 err 是 nil
if err != nil {
fmt.Println(err)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.