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

Function generateCombinedIndex

cmd/tempo-cli/cmd-gen-attrindex.go:239–342  ·  view source on GitHub ↗
(stats *fileStats)

Source from the content-addressed store, hash-verified

237}
238
239func generateCombinedIndex(stats *fileStats) []indexedAttrCombined {
240 var (
241 index = make([]indexedAttrCombined, 0, len(stats.Attributes))
242 keyCode int64
243 )
244
245 for _, attr := range stats.Attributes {
246 keyCode++
247
248 a := indexedAttrCombined{
249 Key: attr.Key,
250 KeyCode: keyCode,
251 ScopeMask: attr.ScopeMask,
252 }
253
254 if len(attr.ValuesString) > 0 {
255 a.ValuesString = make([]indexedValCombined[string], 0, len(attr.ValuesString))
256
257 for _, v := range attr.ValuesString {
258 a.ValuesString = append(a.ValuesString, indexedValCombined[string]{
259 Value: v.Value,
260 RowNumbers: v.RowNumbers,
261 })
262 }
263
264 sort.Slice(a.ValuesString, func(i, j int) bool {
265 return cmpSlice(a.ValuesString[i].Value, a.ValuesString[j].Value) < 0
266 })
267
268 var valueCode int64
269 for i := range a.ValuesString {
270 valueCode++
271 a.ValuesString[i].ValueCode = valueCode
272 }
273 }
274
275 if len(attr.ValuesInt) > 0 {
276 a.ValuesInt = make([]indexedValCombined[int64], 0, len(attr.ValuesInt))
277
278 for _, v := range attr.ValuesInt {
279 a.ValuesInt = append(a.ValuesInt, indexedValCombined[int64]{
280 Value: v.Value,
281 RowNumbers: v.RowNumbers,
282 })
283 }
284
285 sort.Slice(a.ValuesInt, func(i, j int) bool {
286 return cmpSlice(a.ValuesInt[i].Value, a.ValuesInt[j].Value) < 0
287 })
288
289 var valueCode int64
290 for i := range a.ValuesInt {
291 valueCode++
292 a.ValuesInt[i].ValueCode = valueCode
293 }
294 }
295
296 if len(attr.ValuesFloat) > 0 {

Callers 1

RunMethod · 0.85

Calls 2

cmpSliceFunction · 0.85
cmpSliceBoolFunction · 0.85

Tested by

no test coverage detected