zeroshade commented on code in PR #810:
URL: https://github.com/apache/iceberg-go/pull/810#discussion_r3001987031
##########
table/internal/utils.go:
##########
@@ -547,7 +552,14 @@ func MapExec[T, S any](nWorkers int, slice iter.Seq[T], fn
func(T) (S, error)) i
go func() {
defer close(out)
for v := range slice {
- ch <- v
+ select {
+ case ch <- v:
+ case <-ctx.Done():
+ close(ch)
+ err = g.Wait()
Review Comment:
should we just add these as part of the top defer? i.e.
```go
defer func() {
close(ch)
close(out)
err = g.Wait()
}()
```
##########
table/internal/utils.go:
##########
@@ -525,7 +526,7 @@ func MapExec[T, S any](nWorkers int, slice iter.Seq[T], fn
func(T) (S, error)) i
nWorkers = runtime.GOMAXPROCS(0)
}
- var g errgroup.Group
+ g, ctx := errgroup.WithContext(context.Background())
Review Comment:
instead of using `context.Background()` should `MapExec` itself take a
context?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]