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

Method KeepGroup

tempodb/encoding/vparquet5/block_traceql.go:3655–3713  ·  view source on GitHub ↗
(res *parquetquery.IteratorResult)

Source from the content-addressed store, hash-verified

3653}
3654
3655func (c *attributeCollector) KeepGroup(res *parquetquery.IteratorResult) bool {
3656 var key string
3657 var val traceql.Static
3658
3659 // Reset buffers to reuse them without reallocating
3660 c.strBuffer = c.strBuffer[:0]
3661 c.intBuffer = c.intBuffer[:0]
3662 c.floatBuffer = c.floatBuffer[:0]
3663 c.boolBuffer = c.boolBuffer[:0]
3664
3665 for _, e := range res.Entries {
3666 // Ignore nulls, this leaves val as the remaining found value,
3667 // or nil if the key was found but no matching values
3668 if e.Value.Kind() < 0 {
3669 continue
3670 }
3671 switch e.Key {
3672 case "key":
3673 key = unsafeToString(e.Value.Bytes())
3674
3675 case "string":
3676 c.strBuffer = append(c.strBuffer, unsafeToString(e.Value.Bytes()))
3677 case "int":
3678 c.intBuffer = append(c.intBuffer, int(e.Value.Int64()))
3679 case "float":
3680 c.floatBuffer = append(c.floatBuffer, e.Value.Double())
3681 case "bool":
3682 c.boolBuffer = append(c.boolBuffer, e.Value.Boolean())
3683 }
3684 }
3685
3686 // TODO: maybe pull IsArray here, and decide that to see if we have an array or not and make this go faster
3687 switch {
3688 // keep len == 1 cases first so we short-circuit early for non-array case
3689 case len(c.strBuffer) == 1:
3690 val = traceql.NewStaticString(c.strBuffer[0])
3691 case len(c.intBuffer) == 1:
3692 val = traceql.NewStaticInt(c.intBuffer[0])
3693 case len(c.floatBuffer) == 1:
3694 val = traceql.NewStaticFloat(c.floatBuffer[0])
3695 case len(c.boolBuffer) == 1:
3696 val = traceql.NewStaticBool(c.boolBuffer[0])
3697 case len(c.strBuffer) > 1:
3698 val = traceql.NewStaticStringArray(util.Clone(c.strBuffer))
3699 case len(c.intBuffer) > 1:
3700 val = traceql.NewStaticIntArray(util.Clone(c.intBuffer))
3701 case len(c.floatBuffer) > 1:
3702 val = traceql.NewStaticFloatArray(util.Clone(c.floatBuffer))
3703 case len(c.boolBuffer) > 1:
3704 val = traceql.NewStaticBooleanArray(util.Clone(c.boolBuffer))
3705 }
3706
3707 // reset the slices
3708 res.Entries = res.Entries[:0]
3709 res.OtherEntries = res.OtherEntries[:0]
3710 res.AppendOtherValue(key, val)
3711
3712 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