Skip to content

Commit

Permalink
Remove deprecated pcommon.Map.Sort
Browse files Browse the repository at this point in the history
Fixes #6688

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Jan 25, 2023
1 parent b03b046 commit 83112be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
11 changes: 11 additions & 0 deletions .chloggen/rmsort.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: pcommon

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated Map.Sort

# One or more tracking issues or pull requests related to the change
issues: [6688]
20 changes: 0 additions & 20 deletions pdata/pcommon/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"encoding/json"
"fmt"
"math"
"sort"
"strconv"

"go.uber.org/multierr"
Expand Down Expand Up @@ -652,25 +651,6 @@ func (m Map) PutEmptySlice(k string) Slice {
return Slice(internal.NewSlice(&vl.ArrayValue.Values))
}

// Sort sorts the entries in the Map so two instances can be compared.
//
// Deprecated: [1.0.0-rc4] This method will be removed as it leaks the underlying implementation.
// Please use one of the following alternatives depending on your use case:
// - Map.AsRaw() if you need to compare two maps in tests.
// - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest module if you use Sort()
// to prepare other pdata objects for comparison.
// - github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil module if you use Sort()
// to create Map identifiers.
//
// If your use case is not covered by the above alternatives, please comment on the issue
// https://github.com/open-telemetry/opentelemetry-collector/issues/6688.
func (m Map) Sort() {
// Intention is to move the nil values at the end.
sort.SliceStable(*m.getOrig(), func(i, j int) bool {
return (*m.getOrig())[i].Key < (*m.getOrig())[j].Key
})
}

// Len returns the length of this map.
//
// Because the Map is represented internally by a slice of pointers, and the data are comping from the wire,
Expand Down
9 changes: 0 additions & 9 deletions pdata/pcommon/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ func TestMap(t *testing.T) {
removeMap := NewMap()
assert.False(t, removeMap.Remove("k"))
assert.EqualValues(t, NewMap(), removeMap)

// Test Sort
sortMap := NewMap()
sortMap.Sort()
assert.EqualValues(t, NewMap(), sortMap)
}

func TestMapPutEmpty(t *testing.T) {
Expand Down Expand Up @@ -413,10 +408,6 @@ func TestMapWithEmpty(t *testing.T) {

_, exist = sm.Get("test_key3")
assert.False(t, exist)

// Test Sort
sm.Sort()
assert.EqualValues(t, newMap(&origWithNil), sm)
}

func TestMapIterationNil(t *testing.T) {
Expand Down

0 comments on commit 83112be

Please sign in to comment.