Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Jan 31, 2024
1 parent 6c989a6 commit 6911f8c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
15 changes: 11 additions & 4 deletions pkg/bloomcompactor/v2controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func (s *SimpleBloomController) do(ctx context.Context) error {
return nil
}

work := blockPlansForGaps(tsdbsWithGaps, metas)
work, err := blockPlansForGaps(tsdbsWithGaps, metas)
if err != nil {
level.Error(s.logger).Log("msg", "failed to create plan", "err", err)
return errors.Wrap(err, "failed to create plan")
}

// 5. Generate Blooms
// Now that we have the gaps, we will generate a bloom block for each gap.
Expand Down Expand Up @@ -194,7 +198,7 @@ type blockPlan struct {
// blockPlansForGaps groups tsdb gaps we wish to fill with overlapping but out of date blocks.
// This allows us to expedite bloom generation by using existing blocks to fill in the gaps
// since many will contain the same chunks.
func blockPlansForGaps(tsdbs []tsdbGaps, metas []Meta) []blockPlan {
func blockPlansForGaps(tsdbs []tsdbGaps, metas []Meta) ([]blockPlan, error) {
plans := make([]blockPlan, 0, len(tsdbs))

for _, idx := range tsdbs {
Expand Down Expand Up @@ -248,7 +252,10 @@ func blockPlansForGaps(tsdbs []tsdbGaps, metas []Meta) []blockPlan {
peekingBlocks,
)

deduped := v1.Collect[BlockRef](itr)
deduped, err := v1.Collect[BlockRef](itr)
if err != nil {
return nil, errors.Wrap(err, "failed to dedupe blocks")
}
planGap.blocks = deduped

plan.gaps = append(plan.gaps, planGap)
Expand All @@ -257,7 +264,7 @@ func blockPlansForGaps(tsdbs []tsdbGaps, metas []Meta) []blockPlan {
plans = append(plans, plan)
}

return plans
return plans, nil
}

// Used to signal the gaps that need to be populated for a tsdb
Expand Down
7 changes: 6 additions & 1 deletion pkg/bloomcompactor/v2controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func Test_blockPlansForGaps(t *testing.T) {
ownershipRange v1.FingerprintBounds
tsdbs []tsdb.Identifier
metas []Meta
err bool
exp []blockPlan
}{
{
Expand Down Expand Up @@ -403,7 +404,11 @@ func Test_blockPlansForGaps(t *testing.T) {
gaps, err := gapsBetweenTSDBsAndMetas(tc.ownershipRange, tc.tsdbs, tc.metas)
require.NoError(t, err)

plans := blockPlansForGaps(gaps, tc.metas)
plans, err := blockPlansForGaps(gaps, tc.metas)
if tc.err {
require.Error(t, err)
return
}
require.Equal(t, tc.exp, plans)

})
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/bloom/v1/dedupe.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ func (it *DedupeIter[A, B]) At() B {

// Collect collects an interator into a slice. It uses
// CollectInto with a new slice
func Collect[T any](itr Iterator[T]) []T {
func Collect[T any](itr Iterator[T]) ([]T, error) {
return CollectInto(itr, nil)
}

// CollectInto collects the elements of an iterator into a provided slice
// which is returned
func CollectInto[T any](itr Iterator[T], into []T) []T {
func CollectInto[T any](itr Iterator[T], into []T) ([]T, error) {
into = into[:0]

for itr.Next() {
into = append(into, itr.At())
}
return into
return into, itr.Err()
}

0 comments on commit 6911f8c

Please sign in to comment.