Local Counters and a Final Reduction
Independent counters let workers accumulate part of a result without updating one shared cell on every item.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace three partitions
Worker totals of 3, 8, and 2 combine to 13. The join needs one total from each worker. Local map and reduce explains when such contributions summarize the intended data.
Check empty work
A worker with no items can supply zero for a count. Another operation may need an explicitly absent result. See identity elements.[1]
Count in private state and then combine once
Workers examine separate input chunks and find two, five and zero matching entries. Each can update its own count without a shared increment per record. Combining the counts gives seven, provided each chunk was processed exactly once. See a reduction tree.
Worker A: 2 matches
Worker B: 5 matches
Worker C: 0 matches
Final sum 7
Check loss and duplication at the partition boundary
A worker error can leave a missing chunk, and a repeated result can count it twice. Track chunk IDs or reliable task completion. Test an empty chunk and a chunk that is retried.