diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-07-13 18:01:26 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-07-13 18:01:26 +0200 |
commit | 9137aa22a5240bc1d9d0b5583be384bc716060aa (patch) | |
tree | 39c656435385a0a3109bdc6540b918d5dc8a04ab /skate | |
parent | e98ccb9c906230edcd5673acefba21b6eda80080 (diff) | |
download | refcat-9137aa22a5240bc1d9d0b5583be384bc716060aa.tar.gz refcat-9137aa22a5240bc1d9d0b5583be384bc716060aa.zip |
reduce: small tweaks
Diffstat (limited to 'skate')
-rw-r--r-- | skate/reduce.go | 7 | ||||
-rw-r--r-- | skate/zipkey/batch.go | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/skate/reduce.go b/skate/reduce.go index e362ca4..9986152 100644 --- a/skate/reduce.go +++ b/skate/reduce.go @@ -432,10 +432,11 @@ func ZippyBrefAugment(bref, raw io.Reader, w io.Writer) error { batcher = zipkey.NewBatcher(grouper) ) defer batcher.Close() + defer func() { + log.Println(stats) + }() zipper := zipkey.New(bref, raw, keyer, batcher.GroupFunc) - err := zipper.Run() - log.Println(stats) - return err + return zipper.Run() } // removeSelfLinks removes self-referential links. TODO: Those should be caught diff --git a/skate/zipkey/batch.go b/skate/zipkey/batch.go index f8b945c..6ab7eee 100644 --- a/skate/zipkey/batch.go +++ b/skate/zipkey/batch.go @@ -55,7 +55,7 @@ func (b *Batcher) Close() error { return b.err } -// GroupFunc is a drop for a groupFunc. Use this function, where you used +// GroupFunc is a drop-in for a groupFunc. Use this function, where you used // grouper before. Not thread safe. Panics if called after Close. func (b *Batcher) GroupFunc(g *Group) error { if b.closing { @@ -63,7 +63,7 @@ func (b *Batcher) GroupFunc(g *Group) error { } b.batch = append(b.batch, g) // A few groups have an extended size, e.g. thousands of members. We short - // curcuit on those. + // curcuit on those to save memory. oversized := len(g.G0) > maxGroupSize || len(g.G1) > maxGroupSize if len(b.batch) == b.Size || oversized { g := make([]*Group, len(b.batch)) @@ -71,7 +71,7 @@ func (b *Batcher) GroupFunc(g *Group) error { b.queue <- g b.batch = nil } - return nil + return b.err } // worker will wind down after any error has been encountered. Multiple threads |