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

Method collectAttributeStats

cmd/tempo-cli/cmd-gen-attrindex.go:95–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93}
94
95func (cmd *attrIndexCmd) collectAttributeStats() (*fileStats, error) {
96 stats := fileStats{
97 Attributes: make(map[string]attributeInfo, 200),
98 }
99
100 in, pf, err := openParquetFile(cmd.In)
101 if err != nil {
102 return nil, err
103 }
104 defer in.Close()
105
106 reader := parquet.NewGenericReader[vp4.Trace](pf)
107 defer reader.Close()
108
109 var (
110 traceBuffer = make([]vp4.Trace, 1024)
111 readCount int
112 )
113
114 for {
115 readCount, err = reader.Read(traceBuffer)
116 if err != nil {
117 if !errors.Is(err, io.EOF) {
118 return nil, err
119 }
120 break
121 }
122
123 if readCount > 0 {
124 cmd.collectAttributeStatsForTraces(&stats, traceBuffer[:readCount])
125 }
126 }
127 if readCount > 0 {
128 cmd.collectAttributeStatsForTraces(&stats, traceBuffer[:readCount])
129 }
130
131 return &stats, nil
132}
133
134func (cmd *attrIndexCmd) collectAttributeStatsForTraces(stats *fileStats, traces []vp4.Trace) {
135 row := pq.EmptyRowNumber()

Callers 1

RunMethod · 0.95

Calls 4

openParquetFileFunction · 0.85
CloseMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected