Skip to content

Commit

Permalink
more comprehensive batchedLoader.Next handling
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Feb 12, 2024
1 parent 33efa25 commit b33d971
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/bloomcompactor/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func newBatchedLoader(ctx context.Context, work []chunkWork, batchSize int, metr

func (b *batchedLoader) Next() bool {
if len(b.batch) > 0 {
return b.prepNext()
return b.prepNext(false)
}

if len(b.work) == 0 {
Expand All @@ -310,11 +310,22 @@ func (b *batchedLoader) Next() bool {
b.work = b.work[1:]
}

if len(toFetch) == 0 {
return false
}

b.batch, b.err = next.fetcher.FetchChunks(b.ctx, toFetch)
return b.prepNext()
if b.err != nil {
return false
}

return b.prepNext(true)
}

func (b *batchedLoader) prepNext() bool {
func (b *batchedLoader) prepNext(checkLen bool) bool {
if checkLen && len(b.batch) == 0 {
return false
}
b.cur, b.err = b.format(b.batch[0])
b.batch = b.batch[1:]
return b.err == nil
Expand Down

0 comments on commit b33d971

Please sign in to comment.