Skip to content

Commit

Permalink
fix var name
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <benye@amazon.com>
  • Loading branch information
yeya24 committed Apr 24, 2024
1 parent 6e3f61f commit a53396a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/store/lazy_postings.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ func optimizePostingsFetchByDownloadedBytes(r *bucketIndexReader, postingGroups
return nil, false, errors.Wrapf(err, "postings offsets for %s", pg.name)
}

for _, r := range rngs {
if r == indexheader.NotFoundRange {
for _, rng := range rngs {
if rng == indexheader.NotFoundRange {
continue
}
if r.End <= r.Start {
if rng.End <= rng.Start {
level.Error(r.block.logger).Log("msg", "invalid index range, fallback to non lazy posting optimization")
return postingGroups, false, nil
}
// Each range starts from the #entries field which is 4 bytes.
// Need to subtract it when calculating number of postings.
// https://github.com/prometheus/prometheus/blob/v2.46.0/tsdb/docs/format/index.md.
pg.cardinality += (r.End - r.Start - 4) / 4
pg.cardinality += (rng.End - rng.Start - 4) / 4
}
// If the posting group adds keys, 0 cardinality means the posting doesn't exist.
// If the posting group removes keys, no posting ranges found is fine as it is a noop.
Expand Down

0 comments on commit a53396a

Please sign in to comment.