4
4
"context"
5
5
"fmt"
6
6
"io"
7
- "time"
8
7
9
8
"github.com/go-kit/log"
10
9
"github.com/go-kit/log/level"
@@ -45,7 +44,7 @@ type SimpleBloomGenerator struct {
45
44
userID string
46
45
store v1.Iterator [* v1.Series ]
47
46
chunkLoader ChunkLoader
48
- blocksIter v1.ResettableIterator [* v1.SeriesWithBloom ]
47
+ blocksIter v1.ResettableIterator [* v1.SeriesWithBlooms ]
49
48
50
49
// options to build blocks with
51
50
opts v1.BlockOptions
@@ -68,7 +67,7 @@ func NewSimpleBloomGenerator(
68
67
opts v1.BlockOptions ,
69
68
store v1.Iterator [* v1.Series ],
70
69
chunkLoader ChunkLoader ,
71
- blocksIter v1.ResettableIterator [* v1.SeriesWithBloom ],
70
+ blocksIter v1.ResettableIterator [* v1.SeriesWithBlooms ],
72
71
readWriterFn func () (v1.BlockWriter , v1.BlockReader ),
73
72
reporter func (model.Fingerprint ),
74
73
metrics * Metrics ,
@@ -98,44 +97,30 @@ func NewSimpleBloomGenerator(
98
97
}
99
98
}
100
99
101
- func (s * SimpleBloomGenerator ) populator (ctx context.Context ) func (series * v1.Series , bloom * v1.Bloom ) (int , bool , error ) {
102
- return func (series * v1.Series , bloom * v1.Bloom ) (int , bool , error ) {
103
- start := time .Now ()
100
+ func (s * SimpleBloomGenerator ) populator (ctx context.Context ) v1.BloomPopulatorFunc {
101
+ return func (
102
+ series * v1.Series ,
103
+ srcBlooms v1.SizedIterator [* v1.Bloom ],
104
+ toAdd v1.ChunkRefs ,
105
+ ch chan * v1.BloomCreation ,
106
+ ) {
104
107
level .Debug (s .logger ).Log (
105
108
"msg" , "populating bloom filter" ,
106
109
"stage" , "before" ,
107
110
"fp" , series .Fingerprint ,
108
111
"chunks" , len (series .Chunks ),
109
112
)
110
- chunkItersWithFP , err := s .chunkLoader .Load (ctx , s .userID , series )
111
- if err != nil {
112
- return 0 , false , errors .Wrapf (err , "failed to load chunks for series: %+v" , series )
113
- }
114
-
115
- bytesAdded , skip , err := s .tokenizer .Populate (
116
- & v1.SeriesWithBloom {
117
- Series : series ,
118
- Bloom : bloom ,
119
- },
120
- chunkItersWithFP .itr ,
121
- )
113
+ chunkItersWithFP := s .chunkLoader .Load (ctx , s .userID , & v1.Series {
114
+ Fingerprint : series .Fingerprint ,
115
+ Chunks : toAdd ,
116
+ })
122
117
123
- level .Debug (s .logger ).Log (
124
- "msg" , "populating bloom filter" ,
125
- "stage" , "after" ,
126
- "fp" , series .Fingerprint ,
127
- "chunks" , len (series .Chunks ),
128
- "series_bytes" , bytesAdded ,
129
- "duration" , time .Since (start ),
130
- "err" , err ,
131
- )
118
+ s .tokenizer .Populate (srcBlooms , chunkItersWithFP .itr , ch )
132
119
133
120
if s .reporter != nil {
134
121
s .reporter (series .Fingerprint )
135
122
}
136
- return bytesAdded , skip , err
137
123
}
138
-
139
124
}
140
125
141
126
func (s * SimpleBloomGenerator ) Generate (ctx context.Context ) * LazyBlockBuilderIterator {
@@ -179,10 +164,10 @@ type LazyBlockBuilderIterator struct {
179
164
ctx context.Context
180
165
opts v1.BlockOptions
181
166
metrics * Metrics
182
- populate func ( * v1.Series , * v1. Bloom ) ( int , bool , error )
167
+ populate v1.BloomPopulatorFunc
183
168
readWriterFn func () (v1.BlockWriter , v1.BlockReader )
184
169
series v1.PeekingIterator [* v1.Series ]
185
- blocks v1.ResettableIterator [* v1.SeriesWithBloom ]
170
+ blocks v1.ResettableIterator [* v1.SeriesWithBlooms ]
186
171
187
172
bytesAdded int
188
173
curr * v1.Block
@@ -193,10 +178,10 @@ func NewLazyBlockBuilderIterator(
193
178
ctx context.Context ,
194
179
opts v1.BlockOptions ,
195
180
metrics * Metrics ,
196
- populate func ( * v1.Series , * v1. Bloom ) ( int , bool , error ) ,
181
+ populate v1.BloomPopulatorFunc ,
197
182
readWriterFn func () (v1.BlockWriter , v1.BlockReader ),
198
183
series v1.PeekingIterator [* v1.Series ],
199
- blocks v1.ResettableIterator [* v1.SeriesWithBloom ],
184
+ blocks v1.ResettableIterator [* v1.SeriesWithBlooms ],
200
185
) * LazyBlockBuilderIterator {
201
186
return & LazyBlockBuilderIterator {
202
187
ctx : ctx ,
@@ -270,7 +255,7 @@ type ChunkItersByFingerprint struct {
270
255
271
256
// ChunkLoader loads chunks from a store
272
257
type ChunkLoader interface {
273
- Load (ctx context.Context , userID string , series * v1.Series ) ( * ChunkItersByFingerprint , error )
258
+ Load (ctx context.Context , userID string , series * v1.Series ) * ChunkItersByFingerprint
274
259
}
275
260
276
261
// StoreChunkLoader loads chunks from a store
@@ -286,7 +271,7 @@ func NewStoreChunkLoader(fetcherProvider stores.ChunkFetcherProvider, metrics *M
286
271
}
287
272
}
288
273
289
- func (s * StoreChunkLoader ) Load (ctx context.Context , userID string , series * v1.Series ) ( * ChunkItersByFingerprint , error ) {
274
+ func (s * StoreChunkLoader ) Load (ctx context.Context , userID string , series * v1.Series ) * ChunkItersByFingerprint {
290
275
// NB(owen-d): This is probably unnecessary as we should only have one fetcher
291
276
// because we'll only be working on a single index period at a time, but this should protect
292
277
// us in the case of refactoring/changing this and likely isn't a perf bottleneck.
@@ -317,5 +302,5 @@ func (s *StoreChunkLoader) Load(ctx context.Context, userID string, series *v1.S
317
302
return & ChunkItersByFingerprint {
318
303
fp : series .Fingerprint ,
319
304
itr : newBatchedChunkLoader (ctx , fetchers , inputs , s .metrics , batchedLoaderDefaultBatchSize ),
320
- }, nil
305
+ }
321
306
}
0 commit comments