From 4ba813475b3e722e2d78c0a485bd15bbb0727fce Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Thu, 8 Jul 2021 00:16:18 +0200 Subject: reduce: separate batch calls --- skate/zipkey/batch.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'skate/zipkey') diff --git a/skate/zipkey/batch.go b/skate/zipkey/batch.go index ebbd081..85d1d35 100644 --- a/skate/zipkey/batch.go +++ b/skate/zipkey/batch.go @@ -19,9 +19,14 @@ type Batcher struct { // NewBatcher set ups a new Batcher. func NewBatcher(gf groupFunc) *Batcher { + return NewBatcherSize(gf, 1000) +} + +// NewBatcherSize initializes a batcher with a given size. +func NewBatcherSize(gf groupFunc, size int) *Batcher { batcher := Batcher{ gf: gf, - Size: 1000, + Size: size, NumWorkers: runtime.NumCPU(), queue: make(chan []*Group), } @@ -46,7 +51,7 @@ func (b *Batcher) Close() error { } // GroupFunc implement the groupFunc type. Not thread safe. Panics if called -// after Close has been called. +// after Close. func (b *Batcher) GroupFunc(g *Group) error { if b.closing { panic("cannot call GroupFunc after Close") -- cgit v1.2.3