github.com/grafana/pyroscope@v1.18.0/pkg/phlaredb/tsdb/index/fingerprint_test.go (about)

     1  package index
     2  
     3  import (
     4  	"fmt"
     5  	"math"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_FingerprintOffsetRange(t *testing.T) {
    12  	offsets := FingerprintOffsets{
    13  		{1, 1},       // 00 prefix
    14  		{2, 1 << 62}, // 01 prefix
    15  		{3, 1 << 63}, // 10 prefix
    16  		{4, 3 << 62}, // 11 prefix
    17  	}
    18  
    19  	for _, tc := range []struct {
    20  		shard    ShardAnnotation
    21  		min, max uint64
    22  	}{
    23  		{
    24  			shard: NewShard(0, 2),
    25  			min:   0,
    26  			max:   3,
    27  		},
    28  		{
    29  			shard: NewShard(1, 2),
    30  			min:   2,
    31  			max:   math.MaxUint64,
    32  		},
    33  		{
    34  			shard: NewShard(1, 4),
    35  			min:   1,
    36  			max:   3,
    37  		},
    38  	} {
    39  		t.Run(fmt.Sprint(tc.shard, tc.min, tc.max), func(t *testing.T) {
    40  			left, right := offsets.Range(tc.shard)
    41  			require.Equal(t, tc.min, left)
    42  			require.Equal(t, tc.max, right)
    43  		})
    44  	}
    45  
    46  }