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

Function aggregateGenericAttributes

cmd/tempo-cli/cmd-analyse-block.go:668–761  ·  view source on GitHub ↗
(pf *parquet.File, definitionLevel int, keyPath string, valuePath string, intPath string, isArrayPath string)

Source from the content-addressed store, hash-verified

666}
667
668func aggregateGenericAttributes(pf *parquet.File, definitionLevel int, keyPath string, valuePath string, intPath string, isArrayPath string) (attributeSummary, error) {
669 makeIter := makeIterFunc(context.Background(), pf)
670
671 required := []parquetquery.Iterator{
672 makeIter(keyPath, parquetquery.NewSkipNilsPredicate(), "key"),
673 }
674 optional := []parquetquery.Iterator{
675 makeIter(valuePath, parquetquery.NewSkipNilsPredicate(), "value"),
676 makeIter(intPath, parquetquery.NewSkipNilsPredicate(), "int"),
677 }
678 if isArrayPath != "" {
679 optional = append(optional, makeIter(isArrayPath, parquetquery.NewSkipNilsPredicate(), "isArray"))
680 }
681
682 attrIter, err := parquetquery.NewLeftJoinIterator(definitionLevel, required, optional, &attrStatsCollector{})
683 if err != nil {
684 return attributeSummary{}, err
685 }
686 defer attrIter.Close()
687
688 var (
689 attributes = make(map[string]*stringAttributeSummary, 1000)
690 stringArrayAttributes = make(map[string]*stringAttributeSummary, 1000)
691 integerAttributes = make(map[string]*integerAttributeSummary, 1000)
692 integerArrayAttributes = make(map[string]*integerAttributeSummary, 1000)
693 )
694
695 getString := func(name string, from map[string]*stringAttributeSummary) *stringAttributeSummary {
696 v, ok := from[name]
697 if !ok {
698 v = &stringAttributeSummary{
699 name: name,
700 cardinality: make(cardinality),
701 }
702 from[name] = v
703 }
704 return v
705 }
706
707 getInt := func(name string, from map[string]*integerAttributeSummary) *integerAttributeSummary {
708 v, ok := from[name]
709 if !ok {
710 v = &integerAttributeSummary{
711 name: name,
712 }
713 from[name] = v
714 }
715 return v
716 }
717
718 for res, err := attrIter.Next(); res != nil; res, err = attrIter.Next() {
719 if err != nil {
720 return attributeSummary{}, err
721 }
722
723 for _, e := range res.OtherEntries {
724 stats, ok := e.Value.(*attrStats)
725 if !ok {

Callers 1

aggregateScopeFunction · 0.85

Calls 7

CloseMethod · 0.95
NextMethod · 0.95
NewSkipNilsPredicateFunction · 0.92
NewLeftJoinIteratorFunction · 0.92
putStatsFunction · 0.85
makeIterFuncFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected