-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluations.go
43 lines (38 loc) · 931 Bytes
/
evaluations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package evaluation
import (
"errors"
model "github.com/uber/jaeger/model/json"
"upper.io/db.v3"
)
type Evaluations []Evaluation
func (es Evaluations) GetSpansFromPerformanceCollection(perfCol *PerformanceCollection) (Spans, error) {
spans := []model.Span{}
for _, e := range es {
foundPerfs, err := perfCol.Find(db.Cond{"_id": e.PerformanceID})
if err != nil {
return nil, err
}
if len(foundPerfs) != 1 {
return nil, errors.New("expecting one performance output")
}
perf := foundPerfs[0]
perfSpans, err := perf.Spans()
if err != nil {
return nil, err
}
spans = append(spans, perfSpans...)
}
return spans, nil
}
func (es Evaluations) GroupByBatchSize() map[int]Evaluations {
ret := make(map[int]Evaluations)
for _, e := range es {
_, ok := ret[e.BatchSize]
if !ok {
ret[e.BatchSize] = Evaluations{e}
} else {
ret[e.BatchSize] = append(ret[e.BatchSize], e)
}
}
return ret
}