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

Method KeepGroup

tempodb/encoding/vparquet4/block_traceql.go:3564–3622  ·  view source on GitHub ↗
(res *parquetquery.IteratorResult)

Source from the content-addressed store, hash-verified

3562}
3563
3564func (c *attributeCollector) KeepGroup(res *parquetquery.IteratorResult) bool {
3565 var key string
3566 var val traceql.Static
3567
3568 // Reset buffers to reuse them without reallocating
3569 c.strBuffer = c.strBuffer[:0]
3570 c.intBuffer = c.intBuffer[:0]
3571 c.floatBuffer = c.floatBuffer[:0]
3572 c.boolBuffer = c.boolBuffer[:0]
3573
3574 for _, e := range res.Entries {
3575 // Ignore nulls, this leaves val as the remaining found value,
3576 // or nil if the key was found but no matching values
3577 if e.Value.Kind() < 0 {
3578 continue
3579 }
3580 switch e.Key {
3581 case "key":
3582 key = unsafeToString(e.Value.Bytes())
3583
3584 case "string":
3585 c.strBuffer = append(c.strBuffer, unsafeToString(e.Value.Bytes()))
3586 case "int":
3587 c.intBuffer = append(c.intBuffer, int(e.Value.Int64()))
3588 case "float":
3589 c.floatBuffer = append(c.floatBuffer, e.Value.Double())
3590 case "bool":
3591 c.boolBuffer = append(c.boolBuffer, e.Value.Boolean())
3592 }
3593 }
3594
3595 // TODO: maybe pull IsArray here, and decide that to see if we have an array or not and make this go faster
3596 switch {
3597 // keep len == 1 cases first so we short-circuit early for non-array case
3598 case len(c.strBuffer) == 1:
3599 val = traceql.NewStaticString(c.strBuffer[0])
3600 case len(c.intBuffer) == 1:
3601 val = traceql.NewStaticInt(c.intBuffer[0])
3602 case len(c.floatBuffer) == 1:
3603 val = traceql.NewStaticFloat(c.floatBuffer[0])
3604 case len(c.boolBuffer) == 1:
3605 val = traceql.NewStaticBool(c.boolBuffer[0])
3606 case len(c.strBuffer) > 1:
3607 val = traceql.NewStaticStringArray(util.Clone(c.strBuffer))
3608 case len(c.intBuffer) > 1:
3609 val = traceql.NewStaticIntArray(util.Clone(c.intBuffer))
3610 case len(c.floatBuffer) > 1:
3611 val = traceql.NewStaticFloatArray(util.Clone(c.floatBuffer))
3612 case len(c.boolBuffer) > 1:
3613 val = traceql.NewStaticBooleanArray(util.Clone(c.boolBuffer))
3614 }
3615
3616 // reset the slices
3617 res.Entries = res.Entries[:0]
3618 res.OtherEntries = res.OtherEntries[:0]
3619 res.AppendOtherValue(key, val)
3620
3621 return true

Callers

nothing calls this directly

Calls 13

NewStaticStringFunction · 0.92
NewStaticIntFunction · 0.92
NewStaticFloatFunction · 0.92
NewStaticBoolFunction · 0.92
NewStaticStringArrayFunction · 0.92
CloneFunction · 0.92
NewStaticIntArrayFunction · 0.92
NewStaticFloatArrayFunction · 0.92
NewStaticBooleanArrayFunction · 0.92
KindMethod · 0.80
BytesMethod · 0.80
AppendOtherValueMethod · 0.80

Tested by

no test coverage detected