diff --git a/.chloggen/rmsort.yaml b/.chloggen/rmsort.yaml new file mode 100755 index 00000000000..cbb0b85d45d --- /dev/null +++ b/.chloggen/rmsort.yaml @@ -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] diff --git a/pdata/pcommon/common.go b/pdata/pcommon/common.go index b67340403aa..19d83b721ba 100644 --- a/pdata/pcommon/common.go +++ b/pdata/pcommon/common.go @@ -22,7 +22,6 @@ import ( "encoding/json" "fmt" "math" - "sort" "strconv" "go.uber.org/multierr" @@ -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, diff --git a/pdata/pcommon/common_test.go b/pdata/pcommon/common_test.go index f6b6fdcf1e7..7dcbe5196cb 100644 --- a/pdata/pcommon/common_test.go +++ b/pdata/pcommon/common_test.go @@ -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) { @@ -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) {