Aggregate merges the locations in the profile into equivalence classes preserving the request attributes. It also updates the samples to point to the merged locations.
(inlineFrame, function, filename, linenumber, columnnumber, address bool)
| 441 | // classes preserving the request attributes. It also updates the |
| 442 | // samples to point to the merged locations. |
| 443 | func (p *Profile) Aggregate(inlineFrame, function, filename, linenumber, columnnumber, address bool) error { |
| 444 | for _, m := range p.Mapping { |
| 445 | m.HasInlineFrames = m.HasInlineFrames && inlineFrame |
| 446 | m.HasFunctions = m.HasFunctions && function |
| 447 | m.HasFilenames = m.HasFilenames && filename |
| 448 | m.HasLineNumbers = m.HasLineNumbers && linenumber |
| 449 | } |
| 450 | |
| 451 | // Aggregate functions |
| 452 | if !function || !filename { |
| 453 | for _, f := range p.Function { |
| 454 | if !function { |
| 455 | f.Name = "" |
| 456 | f.SystemName = "" |
| 457 | } |
| 458 | if !filename { |
| 459 | f.Filename = "" |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | // Aggregate locations |
| 465 | if !inlineFrame || !address || !linenumber || !columnnumber { |
| 466 | for _, l := range p.Location { |
| 467 | if !inlineFrame && len(l.Line) > 1 { |
| 468 | l.Line = l.Line[len(l.Line)-1:] |
| 469 | } |
| 470 | if !linenumber { |
| 471 | for i := range l.Line { |
| 472 | l.Line[i].Line = 0 |
| 473 | l.Line[i].Column = 0 |
| 474 | } |
| 475 | } |
| 476 | if !columnnumber { |
| 477 | for i := range l.Line { |
| 478 | l.Line[i].Column = 0 |
| 479 | } |
| 480 | } |
| 481 | if !address { |
| 482 | l.Address = 0 |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | return p.CheckValid() |
| 488 | } |
| 489 | |
| 490 | // NumLabelUnits returns a map of numeric label keys to the units |
| 491 | // associated with those keys and a map of those keys to any units |