MCPcopy
hub / github.com/grafana/tempo / CreateBlockBoundaries

Function CreateBlockBoundaries

pkg/blockboundary/blockboundary.go:9–40  ·  view source on GitHub ↗

CreateBlockBoundaries splits the range of blockIDs into queryShards parts

(queryShards int)

Source from the content-addressed store, hash-verified

7
8// CreateBlockBoundaries splits the range of blockIDs into queryShards parts
9func CreateBlockBoundaries(queryShards int) [][]byte {
10 if queryShards == 0 {
11 return nil
12 }
13
14 // create sharded queries
15 blockBoundaries := make([][]byte, queryShards+1)
16 for i := 0; i < queryShards+1; i++ {
17 blockBoundaries[i] = make([]byte, 16)
18 }
19
20 // bucketSz is the min size for the bucket
21 bucketSz := (math.MaxUint64 / uint64(queryShards))
22 // numLarger is the number of buckets that have to be bumped by 1
23 numLarger := (math.MaxUint64 % uint64(queryShards))
24 boundary := uint64(0)
25 for i := 0; i < queryShards; i++ {
26 binary.BigEndian.PutUint64(blockBoundaries[i][:8], boundary)
27 binary.BigEndian.PutUint64(blockBoundaries[i][8:], 0)
28
29 boundary += bucketSz
30 if numLarger != 0 {
31 numLarger--
32 boundary++
33 }
34 }
35
36 binary.BigEndian.PutUint64(blockBoundaries[queryShards][:8], math.MaxUint64)
37 binary.BigEndian.PutUint64(blockBoundaries[queryShards][8:], math.MaxUint64)
38
39 return blockBoundaries
40}

Callers 7

ListBlocksMethod · 0.92
ListBlocksMethod · 0.92
TestPollerOwnershipFunction · 0.92
newAsyncTraceIDSharderFunction · 0.92
TestBuildShardedRequestsFunction · 0.92

Calls

no outgoing calls

Tested by 4

TestPollerOwnershipFunction · 0.74
TestBuildShardedRequestsFunction · 0.74