Skip to content

Commit 9a7335f

Browse files
committed
locations are only ever on Profiles. Remove interface
1 parent fdaff28 commit 9a7335f

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

pdata/pprofile/locations.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ import (
77
"errors"
88
"fmt"
99
"math"
10-
11-
"go.opentelemetry.io/collector/pdata/pcommon"
1210
)
1311

14-
type locatable interface {
15-
LocationIndices() pcommon.Int32Slice
16-
}
17-
18-
// FromLocationIndices builds a slice containing all the locations of a record.
19-
// The record can be any struct that implements a `LocationIndices` method.
20-
// Updates made to the returned map will not be applied back to the record.
21-
func FromLocationIndices(table LocationSlice, record locatable) LocationSlice {
12+
// FromLocationIndices builds a slice containing all the locations of a Profile.
13+
// Updates made to the returned map will not be applied back to the Profile.
14+
func FromLocationIndices(table LocationSlice, record Profile) LocationSlice {
2215
m := NewLocationSlice()
2316
m.EnsureCapacity(record.LocationIndices().Len())
2417

@@ -32,12 +25,11 @@ func FromLocationIndices(table LocationSlice, record locatable) LocationSlice {
3225

3326
var errTooManyLocationTableEntries = errors.New("too many entries in LocationTable")
3427

35-
// PutLocation updates a LocationTable and a record's LocationIndices to
28+
// PutLocation updates a LocationTable and a Profile's LocationIndices to
3629
// add or update a location.
37-
// The record can be any struct that implements a `LocationIndices` method.
38-
func PutLocation(table LocationSlice, record locatable, loc Location) error {
39-
for i, locIdx := range record.LocationIndices().All() {
40-
idx := int(locIdx)
30+
func PutLocation(table LocationSlice, record Profile, loc Location) error {
31+
for i := range record.LocationIndices().All() {
32+
idx := int(record.LocationIndices().At(i))
4133
if idx < 0 || idx >= table.Len() {
4234
return fmt.Errorf("index value %d out of range in LocationIndices[%d]", idx, i)
4335
}

pdata/pprofile/locations_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func BenchmarkPutLocation(b *testing.B) {
110110
name string
111111
location Location
112112

113-
runBefore func(*testing.B, LocationSlice, locatable)
113+
runBefore func(*testing.B, LocationSlice, Profile)
114114
}{
115115
{
116116
name: "with a new location",
@@ -124,7 +124,7 @@ func BenchmarkPutLocation(b *testing.B) {
124124
return l
125125
}(),
126126

127-
runBefore: func(_ *testing.B, table LocationSlice, _ locatable) {
127+
runBefore: func(_ *testing.B, table LocationSlice, _ Profile) {
128128
l := table.AppendEmpty()
129129
l.SetAddress(1)
130130
},
@@ -133,7 +133,7 @@ func BenchmarkPutLocation(b *testing.B) {
133133
name: "with a duplicate location",
134134
location: NewLocation(),
135135

136-
runBefore: func(_ *testing.B, table LocationSlice, obj locatable) {
136+
runBefore: func(_ *testing.B, table LocationSlice, obj Profile) {
137137
require.NoError(b, PutLocation(table, obj, NewLocation()))
138138
},
139139
},
@@ -145,7 +145,7 @@ func BenchmarkPutLocation(b *testing.B) {
145145
return l
146146
}(),
147147

148-
runBefore: func(_ *testing.B, table LocationSlice, _ locatable) {
148+
runBefore: func(_ *testing.B, table LocationSlice, _ Profile) {
149149
for i := range 100 {
150150
l := table.AppendEmpty()
151151
l.SetAddress(uint64(i)) //nolint:gosec // overflow checked

0 commit comments

Comments
 (0)