github.com/grafana/pyroscope@v1.18.0/pkg/phlaredb/tsdb/index/fingerprint.go (about) 1 package index 2 3 import ( 4 "math" 5 "sort" 6 ) 7 8 // (SeriesRef, Fingerprint) tuples 9 type FingerprintOffsets [][2]uint64 10 11 func (xs FingerprintOffsets) Range(shard ShardAnnotation) (minOffset, maxOffset uint64) { 12 from, through := shard.Bounds() 13 14 lower := sort.Search(len(xs), func(i int) bool { 15 return xs[i][1] >= uint64(from) 16 }) 17 18 if lower < len(xs) && lower > 0 { 19 // If lower is the first series offset 20 // to exist in this shard, we must also check 21 // any offsets since the previous sample as well 22 minOffset = xs[lower-1][0] 23 } 24 25 upper := sort.Search(len(xs), func(i int) bool { 26 return xs[i][1] >= uint64(through) 27 }) 28 29 // If there are no sampled fingerprints greater than this shard, 30 // we must check to the end of TSDB series offsets. 31 if upper == len(xs) { 32 maxOffset = math.MaxUint64 33 } else { 34 maxOffset = xs[upper][0] 35 } 36 37 return 38 }