@@ -144,14 +144,12 @@ func (bq *BlockQuerier) Seek(fp model.Fingerprint) error {
144
144
func (bq * BlockQuerier ) Next () bool {
145
145
for bq .series .Next () {
146
146
series := bq .series .At ()
147
- bq .blooms .Seek (series .Offset )
147
+ if skip := bq .blooms .LoadOffset (series .Offset ); skip {
148
+ // can't seek to the desired bloom, likely because the page was too large to load
149
+ // so we skip this series and move on to the next
150
+ continue
151
+ }
148
152
if ! bq .blooms .Next () {
149
- // skip blocks that are too large
150
- if errors .Is (bq .blooms .Err (), ErrPageTooLarge ) {
151
- // fmt.Printf("skipping bloom page: %s (%d)\n", series.Fingerprint, series.Chunks.Len())
152
- bq .blooms .err = nil
153
- continue
154
- }
155
153
return false
156
154
}
157
155
bloom := bq .blooms .At ()
@@ -175,70 +173,3 @@ func (bq *BlockQuerier) Err() error {
175
173
176
174
return bq .blooms .Err ()
177
175
}
178
-
179
- // CheckChunksForSeries checks if the given chunks pass a set of searches in the given bloom block.
180
- // It returns the list of chunks which will need to be downloaded for a query based on the initial list
181
- // passed as the `chks` argument. Chunks will be removed from the result set if they are indexed in the bloom
182
- // and fail to pass all the searches.
183
- func (bq * BlockQuerier ) CheckChunksForSeries (fp model.Fingerprint , chks ChunkRefs , searches [][]byte ) (ChunkRefs , error ) {
184
- schema , err := bq .Schema ()
185
- if err != nil {
186
- return chks , fmt .Errorf ("getting schema: %w" , err )
187
- }
188
-
189
- if err := bq .Seek (fp ); err != nil {
190
- return chks , errors .Wrapf (err , "seeking to series for fp: %v" , fp )
191
- }
192
-
193
- if ! bq .series .Next () {
194
- return chks , nil
195
- }
196
-
197
- series := bq .series .At ()
198
- if series .Fingerprint != fp {
199
- return chks , nil
200
- }
201
-
202
- bq .blooms .Seek (series .Offset )
203
- if ! bq .blooms .Next () {
204
- return chks , fmt .Errorf ("seeking to bloom for fp: %v" , fp )
205
- }
206
-
207
- bloom := bq .blooms .At ()
208
-
209
- // First, see if the search passes the series level bloom before checking for chunks individually
210
- for _ , search := range searches {
211
- if ! bloom .Test (search ) {
212
- // the entire series bloom didn't pass one of the searches,
213
- // so we can skip checking chunks individually.
214
- // We still return all chunks that are not included in the bloom
215
- // as they may still have the data
216
- return chks .Unless (series .Chunks ), nil
217
- }
218
- }
219
-
220
- // TODO(salvacorts): pool tokenBuf
221
- var tokenBuf []byte
222
- var prefixLen int
223
-
224
- // Check chunks individually now
225
- mustCheck , inBlooms := chks .Compare (series .Chunks , true )
226
-
227
- outer:
228
- for _ , chk := range inBlooms {
229
- // Get buf to concatenate the chunk and search token
230
- tokenBuf , prefixLen = prefixedToken (schema .NGramLen (), chk , tokenBuf )
231
- for _ , search := range searches {
232
- tokenBuf = append (tokenBuf [:prefixLen ], search ... )
233
-
234
- if ! bloom .Test (tokenBuf ) {
235
- // chunk didn't pass the search, continue to the next chunk
236
- continue outer
237
- }
238
- }
239
- // chunk passed all searches, add to the list of chunks to download
240
- mustCheck = append (mustCheck , chk )
241
-
242
- }
243
- return mustCheck , nil
244
- }
0 commit comments