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

Function TestShardedBloomFalsePositive

tempodb/encoding/common/bloom_test.go:70–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestShardedBloomFalsePositive(t *testing.T) {
71 tests := []struct {
72 name string
73 bloomFP float64
74 shardSize uint
75 estimatedObjects uint
76 }{
77 {
78 name: "regular",
79 bloomFP: 0.05,
80 shardSize: 250 * 1024,
81 estimatedObjects: 10_000_000,
82 },
83 {
84 name: "large estimated objects",
85 bloomFP: 0.01,
86 shardSize: 100,
87 estimatedObjects: 10000,
88 },
89 {
90 name: "large shard size",
91 bloomFP: 0.01,
92 shardSize: 100000,
93 estimatedObjects: 10,
94 },
95 }
96
97 for _, tt := range tests {
98 tt := tt // capture range variable, needed for running test cases in parallel
99 t.Run(tt.name, func(t *testing.T) {
100 t.Parallel()
101
102 b := NewBloom(tt.bloomFP, tt.shardSize, tt.estimatedObjects)
103
104 // get byte representation
105 bloomBytes, err := b.Marshal()
106 assert.NoError(t, err)
107
108 // parse byte representation into bloom.Bloomfilter
109 var filters []*bloom.BloomFilter
110 for i := 0; i < b.GetShardCount(); i++ {
111 filters = append(filters, &bloom.BloomFilter{})
112 }
113
114 for i, singleBloom := range bloomBytes {
115 _, err = filters[i].ReadFrom(bytes.NewReader(singleBloom))
116 assert.NoError(t, err)
117 assert.LessOrEqual(t, bloom.EstimateFalsePositiveRate(filters[i].Cap(), filters[i].K(), tt.estimatedObjects/uint(b.GetShardCount())), tt.bloomFP)
118 }
119 })
120 }
121}
122
123func TestBloomShardCount(t *testing.T) {
124 tests := []struct {

Callers

nothing calls this directly

Calls 4

NewBloomFunction · 0.85
GetShardCountMethod · 0.80
MarshalMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected