diff --git a/.chloggen/pprofile-slice-ptrs.yaml b/.chloggen/pprofile-slice-ptrs.yaml new file mode 100644 index 00000000000..5c4fcb8eb94 --- /dev/null +++ b/.chloggen/pprofile-slice-ptrs.yaml @@ -0,0 +1,20 @@ +# Use this changelog template to create an entry for release notes. + +# 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: pdata/pprofile + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Replace slices of values to slices of pointers for the `Mapping`, `Location`, `Line`, `Function`, `AttributeUnit`, `Link`, `Value`, `Sample` and `Labels` attributes. + +# One or more tracking issues or pull requests related to the change +issues: [11339] + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] diff --git a/pdata/internal/cmd/pdatagen/internal/pprofile_package.go b/pdata/internal/cmd/pdatagen/internal/pprofile_package.go index 875410c9e51..2e740137749 100644 --- a/pdata/internal/cmd/pdatagen/internal/pprofile_package.go +++ b/pdata/internal/cmd/pdatagen/internal/pprofile_package.go @@ -230,7 +230,7 @@ var profile = &messageValueStruct{ }, } -var valueTypeSlice = &sliceOfValues{ +var valueTypeSlice = &sliceOfPtrs{ structName: "ValueTypeSlice", element: valueType, } @@ -261,7 +261,7 @@ var valueType = &messageValueStruct{ }, } -var sampleSlice = &sliceOfValues{ +var sampleSlice = &sliceOfPtrs{ structName: "SampleSlice", element: sample, } @@ -318,7 +318,7 @@ var sample = &messageValueStruct{ }, } -var labelSlice = &sliceOfValues{ +var labelSlice = &sliceOfPtrs{ structName: "LabelSlice", element: label, } @@ -355,7 +355,7 @@ var label = &messageValueStruct{ }, } -var mappingSlice = &sliceOfValues{ +var mappingSlice = &sliceOfPtrs{ structName: "MappingSlice", element: mapping, } @@ -441,7 +441,7 @@ var mapping = &messageValueStruct{ }, } -var locationSlice = &sliceOfValues{ +var locationSlice = &sliceOfPtrs{ structName: "LocationSlice", element: location, } @@ -492,7 +492,7 @@ var location = &messageValueStruct{ }, } -var lineSlice = &sliceOfValues{ +var lineSlice = &sliceOfPtrs{ structName: "LineSlice", element: line, } @@ -523,7 +523,7 @@ var line = &messageValueStruct{ }, } -var functionSlice = &sliceOfValues{ +var functionSlice = &sliceOfPtrs{ structName: "FunctionSlice", element: function, } @@ -567,7 +567,7 @@ var function = &messageValueStruct{ }, } -var attributeUnitSlice = &sliceOfValues{ +var attributeUnitSlice = &sliceOfPtrs{ structName: "AttributeUnitSlice", element: attributeUnit, } @@ -592,7 +592,7 @@ var attributeUnit = &messageValueStruct{ }, } -var linkSlice = &sliceOfValues{ +var linkSlice = &sliceOfPtrs{ structName: "LinkSlice", element: link, } diff --git a/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go b/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go index 64c91b3221e..7b90b35373f 100644 --- a/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go +++ b/pdata/internal/data/protogen/profiles/v1experimental/pprofextended.pb.go @@ -157,24 +157,24 @@ type Profile struct { // If one of the values represents the number of events represented // by the sample, by convention it should be at index 0 and use // sample_type.unit == "count". - SampleType []ValueType `protobuf:"bytes,1,rep,name=sample_type,json=sampleType,proto3" json:"sample_type"` + SampleType []*ValueType `protobuf:"bytes,1,rep,name=sample_type,json=sampleType,proto3" json:"sample_type,omitempty"` // The set of samples recorded in this profile. - Sample []Sample `protobuf:"bytes,2,rep,name=sample,proto3" json:"sample"` + Sample []*Sample `protobuf:"bytes,2,rep,name=sample,proto3" json:"sample,omitempty"` // Mapping from address ranges to the image/binary/library mapped // into that address range. mapping[0] will be the main binary. - Mapping []Mapping `protobuf:"bytes,3,rep,name=mapping,proto3" json:"mapping"` + Mapping []*Mapping `protobuf:"bytes,3,rep,name=mapping,proto3" json:"mapping,omitempty"` // Locations referenced by samples via location_indices. - Location []Location `protobuf:"bytes,4,rep,name=location,proto3" json:"location"` + Location []*Location `protobuf:"bytes,4,rep,name=location,proto3" json:"location,omitempty"` // Array of locations referenced by samples. LocationIndices []int64 `protobuf:"varint,15,rep,packed,name=location_indices,json=locationIndices,proto3" json:"location_indices,omitempty"` // Functions referenced by locations. - Function []Function `protobuf:"bytes,5,rep,name=function,proto3" json:"function"` + Function []*Function `protobuf:"bytes,5,rep,name=function,proto3" json:"function,omitempty"` // Lookup table for attributes. AttributeTable []v1.KeyValue `protobuf:"bytes,16,rep,name=attribute_table,json=attributeTable,proto3" json:"attribute_table"` // Represents a mapping between Attribute Keys and Units. - AttributeUnits []AttributeUnit `protobuf:"bytes,17,rep,name=attribute_units,json=attributeUnits,proto3" json:"attribute_units"` + AttributeUnits []*AttributeUnit `protobuf:"bytes,17,rep,name=attribute_units,json=attributeUnits,proto3" json:"attribute_units,omitempty"` // Lookup table for links. - LinkTable []Link `protobuf:"bytes,18,rep,name=link_table,json=linkTable,proto3" json:"link_table"` + LinkTable []*Link `protobuf:"bytes,18,rep,name=link_table,json=linkTable,proto3" json:"link_table,omitempty"` // A common table for strings referenced by various messages. // string_table[0] must always be "". StringTable []string `protobuf:"bytes,6,rep,name=string_table,json=stringTable,proto3" json:"string_table,omitempty"` @@ -237,28 +237,28 @@ func (m *Profile) XXX_DiscardUnknown() { var xxx_messageInfo_Profile proto.InternalMessageInfo -func (m *Profile) GetSampleType() []ValueType { +func (m *Profile) GetSampleType() []*ValueType { if m != nil { return m.SampleType } return nil } -func (m *Profile) GetSample() []Sample { +func (m *Profile) GetSample() []*Sample { if m != nil { return m.Sample } return nil } -func (m *Profile) GetMapping() []Mapping { +func (m *Profile) GetMapping() []*Mapping { if m != nil { return m.Mapping } return nil } -func (m *Profile) GetLocation() []Location { +func (m *Profile) GetLocation() []*Location { if m != nil { return m.Location } @@ -272,7 +272,7 @@ func (m *Profile) GetLocationIndices() []int64 { return nil } -func (m *Profile) GetFunction() []Function { +func (m *Profile) GetFunction() []*Function { if m != nil { return m.Function } @@ -286,14 +286,14 @@ func (m *Profile) GetAttributeTable() []v1.KeyValue { return nil } -func (m *Profile) GetAttributeUnits() []AttributeUnit { +func (m *Profile) GetAttributeUnits() []*AttributeUnit { if m != nil { return m.AttributeUnits } return nil } -func (m *Profile) GetLinkTable() []Link { +func (m *Profile) GetLinkTable() []*Link { if m != nil { return m.LinkTable } @@ -554,7 +554,7 @@ type Sample struct { // discouraged case is having a string label and a numeric label of the same // name on a sample. Again, possible to express, but should not be used. // [deprecated, superseded by attributes] - Label []Label `protobuf:"bytes,3,rep,name=label,proto3" json:"label"` + Label []*Label `protobuf:"bytes,3,rep,name=label,proto3" json:"label,omitempty"` // References to attributes in Profile.attribute_table. [optional] Attributes []uint64 `protobuf:"varint,10,rep,packed,name=attributes,proto3" json:"attributes,omitempty"` // Reference to link in Profile.link_table. [optional] @@ -632,7 +632,7 @@ func (m *Sample) GetValue() []int64 { return nil } -func (m *Sample) GetLabel() []Label { +func (m *Sample) GetLabel() []*Label { if m != nil { return m.Label } @@ -907,7 +907,7 @@ type Location struct { // E.g., if memcpy() is inlined into printf: // line[0].function_name == "memcpy" // line[1].function_name == "printf" - Line []Line `protobuf:"bytes,4,rep,name=line,proto3" json:"line"` + Line []*Line `protobuf:"bytes,4,rep,name=line,proto3" json:"line,omitempty"` // Provides an indication that multiple symbols map to this location's // address, for example due to identical code folding by the linker. In that // case the line information above represents one of the multiple @@ -974,7 +974,7 @@ func (m *Location) GetAddress() uint64 { return 0 } -func (m *Location) GetLine() []Line { +func (m *Location) GetLine() []*Line { if m != nil { return m.Line } @@ -1170,100 +1170,100 @@ func init() { } var fileDescriptor_05f9ce3fdbeb046f = []byte{ - // 1483 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcd, 0x4f, 0x1b, 0x47, - 0x1b, 0xc7, 0x1f, 0xf8, 0xe3, 0x31,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0x1c, 0x70, 0x26, 0xae, 0x5d, 0x25, 0xc1, 0x98, 0x1c, 0x02, 0x78, 0x8c, 0x9f, 0x69, 0xef, - 0x09, 0xde, 0xb2, 0x3e, 0x5e, 0x84, 0x18, 0x3f, 0xd3, 0xe2, 0x45, 0x29, 0xa5, 0x9e, 0x70, 0x17, - 0xa6, 0x62, 0x11, 0x31, 0xde, 0xd5, 0xca, 0xb9, 0xa5, 0xcc, 0x4a, 0xd1, 0x2a, 0x29, 0x4c, 0x51, - 0x16, 0xa1, 0xe4, 0x46, 0x41, 0x68, 0x9f, 0x44, 0x8e, 0x4f, 0x63, 0x23, 0xbf, 0x94, 0x5a, 0xc9, - 0x58, 0x20, 0xa1, 0x6d, 0x44, 0x24, 0xe1, 0x8c, 0xd2, 0x01, 0xa1, 0xa0, 0x08, 0x12, 0xd2, 0x84, - 0x3b, 0x00, 0x82, 0xf9, 0xd4, 0xe6, 0x0e, 0x0f, 0x62, 0xa3, 0x88, 0xfb, 0x45, 0x89, 0xb4, 0x24, - 0x40, 0xde, 0x83, 0x69, 0xb7, 0x17, 0xa9, 0x14, 0x51, 0x14, 0x40, 0x4a, 0x39, 0x41, 0x15, 0xed, - 0x39, 0x94, 0xe4, 0x73, 0x02, 0x57, 0x95, 0x6a, 0x69, 0x29, 0xf5, 0xef, 0x4b, 0x55, 0x09, 0x62, - 0xa9, 0xce, 0x43, 0x4e, 0x59, 0xc6, 0x14, 0xde, 0xae, 0x2d, 0x62, 0x40, 0x5e, 0x26, 0x04, 0xe5, - 0xc2, 0x28, 0x63, 0xde, 0x26, 0x26, 0xa9, 0xc1, 0x2d, 0x97, 0x9e, 0x38, 0x3d, 0x4f, 0xd8, 0xa3, - 0x3d, 0x64, 0x1a, 0x8f, 0xcf, 0xea, 0xad, 0xfd, 0x41, 0x33, 0xa8, 0x3e, 0x81, 0xf2, 0xa5, 0x50, - 0x93, 0x65, 0x28, 0x0f, 0xf3, 0xe7, 0x8c, 0xf6, 0x8d, 0x14, 0x1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xfc, 0x27, 0x01, 0x62, 0x3b, 0x16, 0x4e, 0x24, 0x34, 0x5b, 0x16, 0x51, 0xd6, 0xba, 0x35, 0xd8, - 0xdc, 0x97, 0x7b, 0xea, 0xcc, 0x48, 0xc3, 0x8c, 0x6d, 0x8f, 0xf2, 0xae, 0x38, 0xc5, 0x92, 0xca, - 0x0e, 0x1b, 0x66, 0xdc, 0x44, 0x58, 0x26, 0x60, 0x2c, 0x9c, 0xce, 0x59, 0x92, 0x02, 0x5a, 0x5c, - 0x16, 0x58, 0xd9, 0x9a, 0x1d, 0x6e, 0x99, 0xae, 0x92, 0x9e, 0x83, 0xc9, 0x73, 0xf9, 0xcd, 0x71, - 0x18, 0x65, 0x2c, 0x65, 0x90, 0x16, 0x4c, 0x7a, 0xce, 0x31, 0xf5, 0xf4, 0x38, 0xd9, 0x18, 0xaf, - 0xab, 0xc8, 0x93, 0xba, 0x9a, 0x94, 0x0c, 0x59, 0x00, 0x18, 0x24, 0xb0, 0x2c, 0x65, 0xf9, 0x5d, - 0x46, 0x10, 0x19, 0x58, 0xd9, 0x7f, 0xb0, 0xcc, 0xb2, 0x16, 0xae, 0xc9, 0x87, 0x30, 0x27, 0xfb, - 0x41, 0x2c, 0x1c, 0x3f, 0x8c, 0x65, 0x2b, 0xbd, 0xc0, 0x4e, 0x80, 0x15, 0x97, 0xb5, 0xc8, 0x70, - 0xef, 0x80, 0xb3, 0x0b, 0xd9, 0x0e, 0xaa, 0xdf, 0xc0, 0x24, 0xde, 0x4d, 0x2a, 0x90, 0x19, 0x96, - 0x8e, 0x5c, 0x4a, 0x24, 0x16, 0x91, 0x4e, 0x1c, 0xb9, 0x94, 0x08, 0xef, 0xf9, 0x98, 0x23, 0x19, - 0x4b, 0x2e, 0xc9, 0xff, 0xa0, 0xc0, 0x7b, 0x3e, 0x36, 0x6d, 0x23, 0x8b, 0x70, 0x9e, 0xf7, 0x7c, - 0x59, 0x95, 0xd5, 0xdf, 0x32, 0x90, 0xd7, 0x53, 0x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, 0xf1, 0xb8, 0xde, 0x36, 0x77, 0x5b, 0x76, 0xbb, 0xf1, - 0x74, 0x6f, 0xd7, 0xaa, 0x37, 0xcd, 0xf6, 0x91, 0x7d, 0xd0, 0xda, 0xdf, 0x6b, 0x3c, 0x32, 0xb7, - 0xcd, 0xc6, 0x56, 0x65, 0x82, 0xdc, 0x85, 0x3b, 0xef, 0x22, 0x6e, 0x35, 0x9a, 0xed, 0x7a, 0x25, - 0x45, 0xde, 0x87, 0xea, 0xbb, 0x28, 0x8f, 0x0e, 0x9e, 0x1e, 0x34, 0xeb, 0x6d, 0xf3, 0xb0, 0x51, - 0x49, 0xaf, 0x7e, 0x0e, 0xa5, 0x91, 0xba, 0x22, 0xb7, 0x60, 0x66, 0xf3, 0xc0, 0x6c, 0x6e, 0xd9, - 0xe6, 0x96, 0xdd, 0x34, 0x5b, 0x3b, 0x0d, 0xab, 0x32, 0x41, 0x0c, 0x98, 0x1b, 0x80, 0x9b, 0x66, - 0xab, 0x6e, 0x1d, 0xd9, 0x4f, 0xea, 0xfb, 0x4f, 0x2a, 0xa9, 0xcd, 0x9f, 0x52, 0x2f, 0xdf, 0x2c, - 0xa4, 0x5e, 0xbd, 0x59, 0x48, 0xfd, 0xf9, 0x66, 0x21, 0xf5, 0xe3, 0xdb, 0x85, 0x89, 0x57, 0x6f, - 0x17, 0x26, 0x7e, 0x7f, 0xbb, 0x30, 0xf1, 0xad, 0x35, 0xf6, 0x24, 0x56, 0xff, 0x1b, 0x75, 0x29, - 0x7f, 0xd7, 0xbf, 0x68, 0x3f, 0xa7, 0xef, 0xef, 0x86, 0x94, 0xb7, 0x07, 0x8a, 0x7b, 0x98, 0xbe, - 0x7b, 0x49, 0xfa, 0x1e, 0xae, 0x37, 0x46, 0xd8, 0xc7, 0x39, 0xd4, 0x7b, 0xf0, 0x77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xef, 0x03, 0x47, 0x6d, 0x06, 0x0e, 0x00, 0x00, + // 1480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4f, 0x4f, 0x23, 0x47, + 0x16, 0xa7, 0xb1, 0xf1, 0x9f, 0x67, 0x0c, 0xa6, 0x86, 0x65, 0x7b, 0x67, 0x35, 0xc0, 0x18, 0xed, + 0x0e, 0xcb, 0x48, 0x66, 0x61, 0x76, 0xa3, 0x49, 0x14, 0x29, 0x31, 0x83, 0x19, 0x5a, 0x78, 0x0c, + 0x29, 0x0c, 0x09, 0xd1, 0x44, 0xad, 0xc6, 0x5d, 0x98, 0x16, 0xdd, 0xd5, 0xad, 0xee, 0x32, 0xc2, + 0x52, 0x8e, 0x39, 0x45, 0x39, 0xe4, 0x9c, 0x8f, 0x90, 0x5b, 0x3e, 0x41, 0xae, 0x23, 0xe5, 0x32, + 0x97, 0x48, 0x51, 0x0e, 0xa3, 0x68, 0xe6, 0x6b, 0xe4, 0x10, 0xd5, 0xab, 0x6a, 0xdb, 0x30, 0xcc, + 0xc1, 0x73, 0x41, 0xf5, 0x7e, 0xf5, 0xea, 0x57, 0xaf, 0xfa, 0xbd, 0xdf, 0x7b, 0x06, 0x3e, 0x09, + 0x23, 0xc6, 0x05, 0xf3, 0x59, 0xc0, 0x44, 0xdc, 0x5f, 0x8f, 0xe2, 0x50, 0x84, 0xf2, 0xef, 0x99, + 0xe7, 0xb3, 0x64, 0xfd, 0x72, 0x83, 0x5d, 0x45, 0x2c, 0xf6, 0x02, 0xc6, 0x85, 0xe3, 0xaf, 0x47, + 0x72, 0x83, 0x5d, 0x09, 0xc6, 0x5d, 0xe6, 0xd6, 0xd0, 0x97, 0x3c, 0xbc, 0x46, 0xa0, 0xc0, 0x5a, + 0x4a, 0x50, 0xbb, 0x4e, 0x70, 0x77, 0xbe, 0x1b, 0x76, 0x43, 0x75, 0x87, 0x5c, 0x29, 0xef, 0xbb, + 0x6b, 0xb7, 0xc5, 0xd0, 0x09, 0x83, 0x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, 0x96, 0xb6, 0x24, + 0x21, 0x9d, 0x51, 0xde, 0x1e, 0xf7, 0x44, 0x62, 0xce, 0x21, 0xef, 0x47, 0x63, 0x45, 0x5c, 0x4f, + 0x39, 0x8e, 0xb8, 0x27, 0x46, 0x2e, 0x91, 0x66, 0x42, 0x0e, 0x00, 0x7c, 0x8f, 0x5f, 0xe8, 0xb8, + 0x09, 0xf2, 0x6f, 0x8c, 0x97, 0x0f, 0x8f, 0x5f, 0xd0, 0xa2, 0x24, 0x51, 0x61, 0xdf, 0x87, 0xe9, + 0x44, 0xc4, 0x1e, 0xef, 0x6a, 0xce, 0xdc, 0x72, 0x66, 0xb5, 0x48, 0x4b, 0x0a, 0x53, 0x2e, 0x4b, + 0x50, 0x72, 0xe3, 0x30, 0xb2, 0xcf, 0x62, 0x27, 0x60, 0x89, 0x99, 0x5f, 0x36, 0x56, 0x33, 0x14, + 0x24, 0xb4, 0x83, 0x88, 0x74, 0xb8, 0x60, 0x6c, 0xe0, 0x50, 0x50, 0x0e, 0x12, 0xd2, 0x0e, 0xf7, + 0x00, 0x84, 0x17, 0x30, 0x9b, 0x3b, 0x3c, 0x4c, 0xcc, 0x22, 0xee, 0x17, 0x25, 0xd2, 0x92, 0x00, + 0xf9, 0x17, 0xcc, 0xb8, 0xbd, 0x58, 0x15, 0x84, 0x72, 0x01, 0x74, 0x29, 0xa7, 0xa8, 0x72, 0xfb, + 0x0a, 0x4a, 0xf2, 0x21, 0xa1, 0xab, 0x04, 0x58, 0x5a, 0x36, 0xde, 0x5f, 0x80, 0x3a, 0x89, 0xa0, + 0x08, 0x51, 0x86, 0x0b, 0x90, 0x53, 0x96, 0x39, 0x8d, 0xb7, 0x6b, 0x8b, 0x98, 0x90, 0x97, 0x45, + 0xc0, 0xb8, 0x30, 0xcb, 0x58, 0xa5, 0xa9, 0x49, 0x6a, 0x70, 0xc7, 0x65, 0x67, 0x4e, 0xcf, 0x17, + 0xf6, 0x68, 0x67, 0x98, 0xc1, 0xe3, 0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 0x9b, 0x0c, 0xe4, 0x54, 0x3a, + 0x65, 0xc9, 0x8e, 0xf6, 0x30, 0x76, 0x85, 0xf3, 0x20, 0x4b, 0xcb, 0x23, 0x1d, 0x8c, 0x5d, 0x91, + 0x4d, 0xf8, 0x5b, 0x0a, 0x24, 0x76, 0x22, 0x9c, 0x58, 0x68, 0x6f, 0x29, 0xa2, 0x2c, 0xbd, 0x33, + 0xd8, 0x3c, 0x94, 0x7b, 0xea, 0xcc, 0x48, 0x7b, 0x4c, 0x6c, 0x9f, 0xf1, 0xae, 0x38, 0x47, 0x49, + 0x65, 0x87, 0xed, 0x31, 0x69, 0x22, 0x2c, 0x0b, 0x30, 0x11, 0x4e, 0xe7, 0x22, 0x2d, 0x01, 0x4d, + 0x2e, 0x05, 0x56, 0xa6, 0x73, 0xc3, 0x2d, 0xcb, 0x55, 0xd4, 0xf3, 0x30, 0x75, 0x29, 0xbf, 0x39, + 0x0e, 0x9a, 0x0c, 0x55, 0x06, 0xd9, 0x85, 0x29, 0xdf, 0x39, 0x65, 0xbe, 0x1e, 0x18, 0x9b, 0xe3, + 0xf5, 0x13, 0x79, 0x92, 0x2a, 0x02, 0xb2, 0x08, 0x30, 0x28, 0x5d, 0x29, 0x62, 0xf9, 0x45, 0x46, + 0x10, 0x99, 0x52, 0xd9, 0x79, 0x50, 0x60, 0x59, 0x8a, 0x6b, 0xf2, 0x5f, 0x98, 0x97, 0x9d, 0x20, + 0x11, 0x4e, 0x10, 0x25, 0xb2, 0x71, 0x5e, 0x61, 0x0f, 0x40, 0xad, 0x65, 0x29, 0x19, 0xee, 0x1d, + 0x71, 0xef, 0x4a, 0x36, 0x82, 0xea, 0x17, 0x30, 0x85, 0xb7, 0x92, 0x0a, 0x64, 0x86, 0xa2, 0x91, + 0x4b, 0x89, 0x24, 0x22, 0xd6, 0x25, 0x23, 0x97, 0x12, 0xe1, 0xbd, 0x00, 0xab, 0x23, 0x43, 0xe5, + 0x92, 0xfc, 0x03, 0x0a, 0xbc,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0x21, 0xdf, 0xa3, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x92, 0x79, 0x01, 0x14, 0xd0, 0x0d, 0x00, 0x00, } func (m *Profile) Marshal() (dAtA []byte, err error) { @@ -2490,7 +2490,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SampleType = append(m.SampleType, ValueType{}) + m.SampleType = append(m.SampleType, &ValueType{}) if err := m.SampleType[len(m.SampleType)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2524,7 +2524,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sample = append(m.Sample, Sample{}) + m.Sample = append(m.Sample, &Sample{}) if err := m.Sample[len(m.Sample)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2558,7 +2558,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Mapping = append(m.Mapping, Mapping{}) + m.Mapping = append(m.Mapping, &Mapping{}) if err := m.Mapping[len(m.Mapping)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2592,7 +2592,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Location = append(m.Location, Location{}) + m.Location = append(m.Location, &Location{}) if err := m.Location[len(m.Location)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2626,7 +2626,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Function = append(m.Function, Function{}) + m.Function = append(m.Function, &Function{}) if err := m.Function[len(m.Function)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3025,7 +3025,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AttributeUnits = append(m.AttributeUnits, AttributeUnit{}) + m.AttributeUnits = append(m.AttributeUnits, &AttributeUnit{}) if err := m.AttributeUnits[len(m.AttributeUnits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3059,7 +3059,7 @@ func (m *Profile) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LinkTable = append(m.LinkTable, Link{}) + m.LinkTable = append(m.LinkTable, &Link{}) if err := m.LinkTable[len(m.LinkTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3606,7 +3606,7 @@ func (m *Sample) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Label = append(m.Label, Label{}) + m.Label = append(m.Label, &Label{}) if err := m.Label[len(m.Label)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4440,7 +4440,7 @@ func (m *Location) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Line = append(m.Line, Line{}) + m.Line = append(m.Line, &Line{}) if err := m.Line[len(m.Line)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/pdata/pprofile/generated_attributeunitslice.go b/pdata/pprofile/generated_attributeunitslice.go index 95274cfe446..eaf8baf57ed 100644 --- a/pdata/pprofile/generated_attributeunitslice.go +++ b/pdata/pprofile/generated_attributeunitslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewAttributeUnitSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type AttributeUnitSlice struct { - orig *[]otlpprofiles.AttributeUnit + orig *[]*otlpprofiles.AttributeUnit state *internal.State } -func newAttributeUnitSlice(orig *[]otlpprofiles.AttributeUnit, state *internal.State) AttributeUnitSlice { +func newAttributeUnitSlice(orig *[]*otlpprofiles.AttributeUnit, state *internal.State) AttributeUnitSlice { return AttributeUnitSlice{orig: orig, state: state} } // NewAttributeUnitSlice creates a AttributeUnitSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewAttributeUnitSlice() AttributeUnitSlice { - orig := []otlpprofiles.AttributeUnit(nil) + orig := []*otlpprofiles.AttributeUnit(nil) state := internal.StateMutable return newAttributeUnitSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es AttributeUnitSlice) Len() int { // ... // Do something with the element // } func (es AttributeUnitSlice) At(i int) AttributeUnit { - return newAttributeUnit(&(*es.orig)[i], es.state) + return newAttributeUnit((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es AttributeUnitSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.AttributeUnit, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.AttributeUnit, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es AttributeUnitSlice) EnsureCapacity(newCap int) { // It returns the newly added AttributeUnit. func (es AttributeUnitSlice) AppendEmpty() AttributeUnit { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.AttributeUnit{}) + *es.orig = append(*es.orig, &otlpprofiles.AttributeUnit{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es AttributeUnitSlice) CopyTo(dest AttributeUnitSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.AttributeUnit, srcLen) + for i := range *es.orig { + newAttributeUnit((*es.orig)[i], es.state).CopyTo(newAttributeUnit((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.AttributeUnit, srcLen) + wrappers := make([]*otlpprofiles.AttributeUnit, srcLen) for i := range *es.orig { - newAttributeUnit(&(*es.orig)[i], es.state).CopyTo(newAttributeUnit(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newAttributeUnit((*es.orig)[i], es.state).CopyTo(newAttributeUnit(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the AttributeUnit elements within AttributeUnitSlice given the +// provided less function so that two instances of AttributeUnitSlice +// can be compared. +func (es AttributeUnitSlice) Sort(less func(a, b AttributeUnit) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_attributeunitslice_test.go b/pdata/pprofile/generated_attributeunitslice_test.go index 0dd3420015a..6fa007bca75 100644 --- a/pdata/pprofile/generated_attributeunitslice_test.go +++ b/pdata/pprofile/generated_attributeunitslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestAttributeUnitSlice(t *testing.T) { es := NewAttributeUnitSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newAttributeUnitSlice(&[]otlpprofiles.AttributeUnit{}, &state) + es = newAttributeUnitSlice(&[]*otlpprofiles.AttributeUnit{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewAttributeUnit() @@ -35,7 +36,7 @@ func TestAttributeUnitSlice(t *testing.T) { func TestAttributeUnitSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newAttributeUnitSlice(&[]otlpprofiles.AttributeUnit{}, &sharedState) + es := newAttributeUnitSlice(&[]*otlpprofiles.AttributeUnit{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestAttributeUnitSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestAttributeUnitSlice_Sort(t *testing.T) { + es := generateTestAttributeUnitSlice() + es.Sort(func(a, b AttributeUnit) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b AttributeUnit) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestAttributeUnitSlice() AttributeUnitSlice { es := NewAttributeUnitSlice() fillTestAttributeUnitSlice(es) @@ -129,9 +146,9 @@ func generateTestAttributeUnitSlice() AttributeUnitSlice { } func fillTestAttributeUnitSlice(es AttributeUnitSlice) { - *es.orig = make([]otlpprofiles.AttributeUnit, 7) + *es.orig = make([]*otlpprofiles.AttributeUnit, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.AttributeUnit{} - fillTestAttributeUnit(newAttributeUnit(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.AttributeUnit{} + fillTestAttributeUnit(newAttributeUnit((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_functionslice.go b/pdata/pprofile/generated_functionslice.go index 171ba345b01..9c295899efd 100644 --- a/pdata/pprofile/generated_functionslice.go +++ b/pdata/pprofile/generated_functionslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewFunctionSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type FunctionSlice struct { - orig *[]otlpprofiles.Function + orig *[]*otlpprofiles.Function state *internal.State } -func newFunctionSlice(orig *[]otlpprofiles.Function, state *internal.State) FunctionSlice { +func newFunctionSlice(orig *[]*otlpprofiles.Function, state *internal.State) FunctionSlice { return FunctionSlice{orig: orig, state: state} } // NewFunctionSlice creates a FunctionSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewFunctionSlice() FunctionSlice { - orig := []otlpprofiles.Function(nil) + orig := []*otlpprofiles.Function(nil) state := internal.StateMutable return newFunctionSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es FunctionSlice) Len() int { // ... // Do something with the element // } func (es FunctionSlice) At(i int) Function { - return newFunction(&(*es.orig)[i], es.state) + return newFunction((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es FunctionSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Function, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Function, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es FunctionSlice) EnsureCapacity(newCap int) { // It returns the newly added Function. func (es FunctionSlice) AppendEmpty() Function { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Function{}) + *es.orig = append(*es.orig, &otlpprofiles.Function{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es FunctionSlice) CopyTo(dest FunctionSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Function, srcLen) + for i := range *es.orig { + newFunction((*es.orig)[i], es.state).CopyTo(newFunction((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Function, srcLen) + wrappers := make([]*otlpprofiles.Function, srcLen) for i := range *es.orig { - newFunction(&(*es.orig)[i], es.state).CopyTo(newFunction(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newFunction((*es.orig)[i], es.state).CopyTo(newFunction(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Function elements within FunctionSlice given the +// provided less function so that two instances of FunctionSlice +// can be compared. +func (es FunctionSlice) Sort(less func(a, b Function) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_functionslice_test.go b/pdata/pprofile/generated_functionslice_test.go index c4311bf52d9..e83a4d9a530 100644 --- a/pdata/pprofile/generated_functionslice_test.go +++ b/pdata/pprofile/generated_functionslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestFunctionSlice(t *testing.T) { es := NewFunctionSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newFunctionSlice(&[]otlpprofiles.Function{}, &state) + es = newFunctionSlice(&[]*otlpprofiles.Function{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewFunction() @@ -35,7 +36,7 @@ func TestFunctionSlice(t *testing.T) { func TestFunctionSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newFunctionSlice(&[]otlpprofiles.Function{}, &sharedState) + es := newFunctionSlice(&[]*otlpprofiles.Function{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestFunctionSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestFunctionSlice_Sort(t *testing.T) { + es := generateTestFunctionSlice() + es.Sort(func(a, b Function) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Function) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestFunctionSlice() FunctionSlice { es := NewFunctionSlice() fillTestFunctionSlice(es) @@ -129,9 +146,9 @@ func generateTestFunctionSlice() FunctionSlice { } func fillTestFunctionSlice(es FunctionSlice) { - *es.orig = make([]otlpprofiles.Function, 7) + *es.orig = make([]*otlpprofiles.Function, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Function{} - fillTestFunction(newFunction(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Function{} + fillTestFunction(newFunction((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_labelslice.go b/pdata/pprofile/generated_labelslice.go index 5f865bfcbae..0296d634da0 100644 --- a/pdata/pprofile/generated_labelslice.go +++ b/pdata/pprofile/generated_labelslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLabelSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LabelSlice struct { - orig *[]otlpprofiles.Label + orig *[]*otlpprofiles.Label state *internal.State } -func newLabelSlice(orig *[]otlpprofiles.Label, state *internal.State) LabelSlice { +func newLabelSlice(orig *[]*otlpprofiles.Label, state *internal.State) LabelSlice { return LabelSlice{orig: orig, state: state} } // NewLabelSlice creates a LabelSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLabelSlice() LabelSlice { - orig := []otlpprofiles.Label(nil) + orig := []*otlpprofiles.Label(nil) state := internal.StateMutable return newLabelSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LabelSlice) Len() int { // ... // Do something with the element // } func (es LabelSlice) At(i int) Label { - return newLabel(&(*es.orig)[i], es.state) + return newLabel((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LabelSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Label, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Label, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LabelSlice) EnsureCapacity(newCap int) { // It returns the newly added Label. func (es LabelSlice) AppendEmpty() Label { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Label{}) + *es.orig = append(*es.orig, &otlpprofiles.Label{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LabelSlice) CopyTo(dest LabelSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Label, srcLen) + for i := range *es.orig { + newLabel((*es.orig)[i], es.state).CopyTo(newLabel((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Label, srcLen) + wrappers := make([]*otlpprofiles.Label, srcLen) for i := range *es.orig { - newLabel(&(*es.orig)[i], es.state).CopyTo(newLabel(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLabel((*es.orig)[i], es.state).CopyTo(newLabel(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Label elements within LabelSlice given the +// provided less function so that two instances of LabelSlice +// can be compared. +func (es LabelSlice) Sort(less func(a, b Label) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_labelslice_test.go b/pdata/pprofile/generated_labelslice_test.go index c399046f92e..4ae3f7a6cbd 100644 --- a/pdata/pprofile/generated_labelslice_test.go +++ b/pdata/pprofile/generated_labelslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLabelSlice(t *testing.T) { es := NewLabelSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLabelSlice(&[]otlpprofiles.Label{}, &state) + es = newLabelSlice(&[]*otlpprofiles.Label{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLabel() @@ -35,7 +36,7 @@ func TestLabelSlice(t *testing.T) { func TestLabelSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLabelSlice(&[]otlpprofiles.Label{}, &sharedState) + es := newLabelSlice(&[]*otlpprofiles.Label{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLabelSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLabelSlice_Sort(t *testing.T) { + es := generateTestLabelSlice() + es.Sort(func(a, b Label) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Label) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLabelSlice() LabelSlice { es := NewLabelSlice() fillTestLabelSlice(es) @@ -129,9 +146,9 @@ func generateTestLabelSlice() LabelSlice { } func fillTestLabelSlice(es LabelSlice) { - *es.orig = make([]otlpprofiles.Label, 7) + *es.orig = make([]*otlpprofiles.Label, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Label{} - fillTestLabel(newLabel(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Label{} + fillTestLabel(newLabel((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_lineslice.go b/pdata/pprofile/generated_lineslice.go index b354560d090..3f8daed79e9 100644 --- a/pdata/pprofile/generated_lineslice.go +++ b/pdata/pprofile/generated_lineslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLineSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LineSlice struct { - orig *[]otlpprofiles.Line + orig *[]*otlpprofiles.Line state *internal.State } -func newLineSlice(orig *[]otlpprofiles.Line, state *internal.State) LineSlice { +func newLineSlice(orig *[]*otlpprofiles.Line, state *internal.State) LineSlice { return LineSlice{orig: orig, state: state} } // NewLineSlice creates a LineSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLineSlice() LineSlice { - orig := []otlpprofiles.Line(nil) + orig := []*otlpprofiles.Line(nil) state := internal.StateMutable return newLineSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LineSlice) Len() int { // ... // Do something with the element // } func (es LineSlice) At(i int) Line { - return newLine(&(*es.orig)[i], es.state) + return newLine((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LineSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Line, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Line, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LineSlice) EnsureCapacity(newCap int) { // It returns the newly added Line. func (es LineSlice) AppendEmpty() Line { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Line{}) + *es.orig = append(*es.orig, &otlpprofiles.Line{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LineSlice) CopyTo(dest LineSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Line, srcLen) + for i := range *es.orig { + newLine((*es.orig)[i], es.state).CopyTo(newLine((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Line, srcLen) + wrappers := make([]*otlpprofiles.Line, srcLen) for i := range *es.orig { - newLine(&(*es.orig)[i], es.state).CopyTo(newLine(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLine((*es.orig)[i], es.state).CopyTo(newLine(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Line elements within LineSlice given the +// provided less function so that two instances of LineSlice +// can be compared. +func (es LineSlice) Sort(less func(a, b Line) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_lineslice_test.go b/pdata/pprofile/generated_lineslice_test.go index 1f5a69ca3f4..fd53c0237a0 100644 --- a/pdata/pprofile/generated_lineslice_test.go +++ b/pdata/pprofile/generated_lineslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLineSlice(t *testing.T) { es := NewLineSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLineSlice(&[]otlpprofiles.Line{}, &state) + es = newLineSlice(&[]*otlpprofiles.Line{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLine() @@ -35,7 +36,7 @@ func TestLineSlice(t *testing.T) { func TestLineSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLineSlice(&[]otlpprofiles.Line{}, &sharedState) + es := newLineSlice(&[]*otlpprofiles.Line{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLineSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLineSlice_Sort(t *testing.T) { + es := generateTestLineSlice() + es.Sort(func(a, b Line) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Line) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLineSlice() LineSlice { es := NewLineSlice() fillTestLineSlice(es) @@ -129,9 +146,9 @@ func generateTestLineSlice() LineSlice { } func fillTestLineSlice(es LineSlice) { - *es.orig = make([]otlpprofiles.Line, 7) + *es.orig = make([]*otlpprofiles.Line, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Line{} - fillTestLine(newLine(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Line{} + fillTestLine(newLine((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_linkslice.go b/pdata/pprofile/generated_linkslice.go index 3ae925ac09c..dca0febad1b 100644 --- a/pdata/pprofile/generated_linkslice.go +++ b/pdata/pprofile/generated_linkslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLinkSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LinkSlice struct { - orig *[]otlpprofiles.Link + orig *[]*otlpprofiles.Link state *internal.State } -func newLinkSlice(orig *[]otlpprofiles.Link, state *internal.State) LinkSlice { +func newLinkSlice(orig *[]*otlpprofiles.Link, state *internal.State) LinkSlice { return LinkSlice{orig: orig, state: state} } // NewLinkSlice creates a LinkSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLinkSlice() LinkSlice { - orig := []otlpprofiles.Link(nil) + orig := []*otlpprofiles.Link(nil) state := internal.StateMutable return newLinkSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LinkSlice) Len() int { // ... // Do something with the element // } func (es LinkSlice) At(i int) Link { - return newLink(&(*es.orig)[i], es.state) + return newLink((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LinkSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Link, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Link, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LinkSlice) EnsureCapacity(newCap int) { // It returns the newly added Link. func (es LinkSlice) AppendEmpty() Link { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Link{}) + *es.orig = append(*es.orig, &otlpprofiles.Link{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LinkSlice) CopyTo(dest LinkSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Link, srcLen) + for i := range *es.orig { + newLink((*es.orig)[i], es.state).CopyTo(newLink((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Link, srcLen) + wrappers := make([]*otlpprofiles.Link, srcLen) for i := range *es.orig { - newLink(&(*es.orig)[i], es.state).CopyTo(newLink(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLink((*es.orig)[i], es.state).CopyTo(newLink(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Link elements within LinkSlice given the +// provided less function so that two instances of LinkSlice +// can be compared. +func (es LinkSlice) Sort(less func(a, b Link) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_linkslice_test.go b/pdata/pprofile/generated_linkslice_test.go index 5d22fcd69ca..bec39e870c8 100644 --- a/pdata/pprofile/generated_linkslice_test.go +++ b/pdata/pprofile/generated_linkslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLinkSlice(t *testing.T) { es := NewLinkSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLinkSlice(&[]otlpprofiles.Link{}, &state) + es = newLinkSlice(&[]*otlpprofiles.Link{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLink() @@ -35,7 +36,7 @@ func TestLinkSlice(t *testing.T) { func TestLinkSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLinkSlice(&[]otlpprofiles.Link{}, &sharedState) + es := newLinkSlice(&[]*otlpprofiles.Link{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLinkSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLinkSlice_Sort(t *testing.T) { + es := generateTestLinkSlice() + es.Sort(func(a, b Link) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Link) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLinkSlice() LinkSlice { es := NewLinkSlice() fillTestLinkSlice(es) @@ -129,9 +146,9 @@ func generateTestLinkSlice() LinkSlice { } func fillTestLinkSlice(es LinkSlice) { - *es.orig = make([]otlpprofiles.Link, 7) + *es.orig = make([]*otlpprofiles.Link, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Link{} - fillTestLink(newLink(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Link{} + fillTestLink(newLink((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_locationslice.go b/pdata/pprofile/generated_locationslice.go index e5751c4dcb6..4848a46d925 100644 --- a/pdata/pprofile/generated_locationslice.go +++ b/pdata/pprofile/generated_locationslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewLocationSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LocationSlice struct { - orig *[]otlpprofiles.Location + orig *[]*otlpprofiles.Location state *internal.State } -func newLocationSlice(orig *[]otlpprofiles.Location, state *internal.State) LocationSlice { +func newLocationSlice(orig *[]*otlpprofiles.Location, state *internal.State) LocationSlice { return LocationSlice{orig: orig, state: state} } // NewLocationSlice creates a LocationSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLocationSlice() LocationSlice { - orig := []otlpprofiles.Location(nil) + orig := []*otlpprofiles.Location(nil) state := internal.StateMutable return newLocationSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es LocationSlice) Len() int { // ... // Do something with the element // } func (es LocationSlice) At(i int) Location { - return newLocation(&(*es.orig)[i], es.state) + return newLocation((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es LocationSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Location, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Location, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es LocationSlice) EnsureCapacity(newCap int) { // It returns the newly added Location. func (es LocationSlice) AppendEmpty() Location { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Location{}) + *es.orig = append(*es.orig, &otlpprofiles.Location{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es LocationSlice) CopyTo(dest LocationSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Location, srcLen) + for i := range *es.orig { + newLocation((*es.orig)[i], es.state).CopyTo(newLocation((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Location, srcLen) + wrappers := make([]*otlpprofiles.Location, srcLen) for i := range *es.orig { - newLocation(&(*es.orig)[i], es.state).CopyTo(newLocation(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newLocation((*es.orig)[i], es.state).CopyTo(newLocation(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Location elements within LocationSlice given the +// provided less function so that two instances of LocationSlice +// can be compared. +func (es LocationSlice) Sort(less func(a, b Location) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_locationslice_test.go b/pdata/pprofile/generated_locationslice_test.go index 06d6946279f..e654bb88a1d 100644 --- a/pdata/pprofile/generated_locationslice_test.go +++ b/pdata/pprofile/generated_locationslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestLocationSlice(t *testing.T) { es := NewLocationSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newLocationSlice(&[]otlpprofiles.Location{}, &state) + es = newLocationSlice(&[]*otlpprofiles.Location{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewLocation() @@ -35,7 +36,7 @@ func TestLocationSlice(t *testing.T) { func TestLocationSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newLocationSlice(&[]otlpprofiles.Location{}, &sharedState) + es := newLocationSlice(&[]*otlpprofiles.Location{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestLocationSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestLocationSlice_Sort(t *testing.T) { + es := generateTestLocationSlice() + es.Sort(func(a, b Location) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Location) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestLocationSlice() LocationSlice { es := NewLocationSlice() fillTestLocationSlice(es) @@ -129,9 +146,9 @@ func generateTestLocationSlice() LocationSlice { } func fillTestLocationSlice(es LocationSlice) { - *es.orig = make([]otlpprofiles.Location, 7) + *es.orig = make([]*otlpprofiles.Location, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Location{} - fillTestLocation(newLocation(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Location{} + fillTestLocation(newLocation((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_mappingslice.go b/pdata/pprofile/generated_mappingslice.go index cf0f1361483..140d76f4854 100644 --- a/pdata/pprofile/generated_mappingslice.go +++ b/pdata/pprofile/generated_mappingslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewMappingSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type MappingSlice struct { - orig *[]otlpprofiles.Mapping + orig *[]*otlpprofiles.Mapping state *internal.State } -func newMappingSlice(orig *[]otlpprofiles.Mapping, state *internal.State) MappingSlice { +func newMappingSlice(orig *[]*otlpprofiles.Mapping, state *internal.State) MappingSlice { return MappingSlice{orig: orig, state: state} } // NewMappingSlice creates a MappingSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewMappingSlice() MappingSlice { - orig := []otlpprofiles.Mapping(nil) + orig := []*otlpprofiles.Mapping(nil) state := internal.StateMutable return newMappingSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es MappingSlice) Len() int { // ... // Do something with the element // } func (es MappingSlice) At(i int) Mapping { - return newMapping(&(*es.orig)[i], es.state) + return newMapping((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es MappingSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Mapping, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Mapping, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es MappingSlice) EnsureCapacity(newCap int) { // It returns the newly added Mapping. func (es MappingSlice) AppendEmpty() Mapping { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Mapping{}) + *es.orig = append(*es.orig, &otlpprofiles.Mapping{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es MappingSlice) CopyTo(dest MappingSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Mapping, srcLen) + for i := range *es.orig { + newMapping((*es.orig)[i], es.state).CopyTo(newMapping((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Mapping, srcLen) + wrappers := make([]*otlpprofiles.Mapping, srcLen) for i := range *es.orig { - newMapping(&(*es.orig)[i], es.state).CopyTo(newMapping(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newMapping((*es.orig)[i], es.state).CopyTo(newMapping(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Mapping elements within MappingSlice given the +// provided less function so that two instances of MappingSlice +// can be compared. +func (es MappingSlice) Sort(less func(a, b Mapping) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_mappingslice_test.go b/pdata/pprofile/generated_mappingslice_test.go index b25cb952ce1..a1c46aa0b9b 100644 --- a/pdata/pprofile/generated_mappingslice_test.go +++ b/pdata/pprofile/generated_mappingslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestMappingSlice(t *testing.T) { es := NewMappingSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newMappingSlice(&[]otlpprofiles.Mapping{}, &state) + es = newMappingSlice(&[]*otlpprofiles.Mapping{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewMapping() @@ -35,7 +36,7 @@ func TestMappingSlice(t *testing.T) { func TestMappingSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newMappingSlice(&[]otlpprofiles.Mapping{}, &sharedState) + es := newMappingSlice(&[]*otlpprofiles.Mapping{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestMappingSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestMappingSlice_Sort(t *testing.T) { + es := generateTestMappingSlice() + es.Sort(func(a, b Mapping) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Mapping) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestMappingSlice() MappingSlice { es := NewMappingSlice() fillTestMappingSlice(es) @@ -129,9 +146,9 @@ func generateTestMappingSlice() MappingSlice { } func fillTestMappingSlice(es MappingSlice) { - *es.orig = make([]otlpprofiles.Mapping, 7) + *es.orig = make([]*otlpprofiles.Mapping, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Mapping{} - fillTestMapping(newMapping(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Mapping{} + fillTestMapping(newMapping((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_sampleslice.go b/pdata/pprofile/generated_sampleslice.go index da2a128cd6f..64065c10757 100644 --- a/pdata/pprofile/generated_sampleslice.go +++ b/pdata/pprofile/generated_sampleslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewSampleSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SampleSlice struct { - orig *[]otlpprofiles.Sample + orig *[]*otlpprofiles.Sample state *internal.State } -func newSampleSlice(orig *[]otlpprofiles.Sample, state *internal.State) SampleSlice { +func newSampleSlice(orig *[]*otlpprofiles.Sample, state *internal.State) SampleSlice { return SampleSlice{orig: orig, state: state} } // NewSampleSlice creates a SampleSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSampleSlice() SampleSlice { - orig := []otlpprofiles.Sample(nil) + orig := []*otlpprofiles.Sample(nil) state := internal.StateMutable return newSampleSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es SampleSlice) Len() int { // ... // Do something with the element // } func (es SampleSlice) At(i int) Sample { - return newSample(&(*es.orig)[i], es.state) + return newSample((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es SampleSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.Sample, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.Sample, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es SampleSlice) EnsureCapacity(newCap int) { // It returns the newly added Sample. func (es SampleSlice) AppendEmpty() Sample { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.Sample{}) + *es.orig = append(*es.orig, &otlpprofiles.Sample{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es SampleSlice) CopyTo(dest SampleSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.Sample, srcLen) + for i := range *es.orig { + newSample((*es.orig)[i], es.state).CopyTo(newSample((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.Sample, srcLen) + wrappers := make([]*otlpprofiles.Sample, srcLen) for i := range *es.orig { - newSample(&(*es.orig)[i], es.state).CopyTo(newSample(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newSample((*es.orig)[i], es.state).CopyTo(newSample(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the Sample elements within SampleSlice given the +// provided less function so that two instances of SampleSlice +// can be compared. +func (es SampleSlice) Sort(less func(a, b Sample) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_sampleslice_test.go b/pdata/pprofile/generated_sampleslice_test.go index 7533e51cc45..9c758e0dc02 100644 --- a/pdata/pprofile/generated_sampleslice_test.go +++ b/pdata/pprofile/generated_sampleslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestSampleSlice(t *testing.T) { es := NewSampleSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newSampleSlice(&[]otlpprofiles.Sample{}, &state) + es = newSampleSlice(&[]*otlpprofiles.Sample{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewSample() @@ -35,7 +36,7 @@ func TestSampleSlice(t *testing.T) { func TestSampleSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newSampleSlice(&[]otlpprofiles.Sample{}, &sharedState) + es := newSampleSlice(&[]*otlpprofiles.Sample{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestSampleSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestSampleSlice_Sort(t *testing.T) { + es := generateTestSampleSlice() + es.Sort(func(a, b Sample) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b Sample) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestSampleSlice() SampleSlice { es := NewSampleSlice() fillTestSampleSlice(es) @@ -129,9 +146,9 @@ func generateTestSampleSlice() SampleSlice { } func fillTestSampleSlice(es SampleSlice) { - *es.orig = make([]otlpprofiles.Sample, 7) + *es.orig = make([]*otlpprofiles.Sample, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.Sample{} - fillTestSample(newSample(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.Sample{} + fillTestSample(newSample((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/generated_valuetypeslice.go b/pdata/pprofile/generated_valuetypeslice.go index 4049bbd2e16..dcbe574a3cc 100644 --- a/pdata/pprofile/generated_valuetypeslice.go +++ b/pdata/pprofile/generated_valuetypeslice.go @@ -7,6 +7,8 @@ package pprofile import ( + "sort" + "go.opentelemetry.io/collector/pdata/internal" otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1experimental" ) @@ -19,18 +21,18 @@ import ( // Must use NewValueTypeSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ValueTypeSlice struct { - orig *[]otlpprofiles.ValueType + orig *[]*otlpprofiles.ValueType state *internal.State } -func newValueTypeSlice(orig *[]otlpprofiles.ValueType, state *internal.State) ValueTypeSlice { +func newValueTypeSlice(orig *[]*otlpprofiles.ValueType, state *internal.State) ValueTypeSlice { return ValueTypeSlice{orig: orig, state: state} } // NewValueTypeSlice creates a ValueTypeSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewValueTypeSlice() ValueTypeSlice { - orig := []otlpprofiles.ValueType(nil) + orig := []*otlpprofiles.ValueType(nil) state := internal.StateMutable return newValueTypeSlice(&orig, &state) } @@ -51,7 +53,7 @@ func (es ValueTypeSlice) Len() int { // ... // Do something with the element // } func (es ValueTypeSlice) At(i int) ValueType { - return newValueType(&(*es.orig)[i], es.state) + return newValueType((*es.orig)[i], es.state) } // EnsureCapacity is an operation that ensures the slice has at least the specified capacity. @@ -73,7 +75,7 @@ func (es ValueTypeSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpprofiles.ValueType, len(*es.orig), newCap) + newOrig := make([]*otlpprofiles.ValueType, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -82,7 +84,7 @@ func (es ValueTypeSlice) EnsureCapacity(newCap int) { // It returns the newly added ValueType. func (es ValueTypeSlice) AppendEmpty() ValueType { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpprofiles.ValueType{}) + *es.orig = append(*es.orig, &otlpprofiles.ValueType{}) return es.At(es.Len() - 1) } @@ -127,10 +129,24 @@ func (es ValueTypeSlice) CopyTo(dest ValueTypeSlice) { destCap := cap(*dest.orig) if srcLen <= destCap { (*dest.orig) = (*dest.orig)[:srcLen:destCap] - } else { - (*dest.orig) = make([]otlpprofiles.ValueType, srcLen) + for i := range *es.orig { + newValueType((*es.orig)[i], es.state).CopyTo(newValueType((*dest.orig)[i], dest.state)) + } + return } + origs := make([]otlpprofiles.ValueType, srcLen) + wrappers := make([]*otlpprofiles.ValueType, srcLen) for i := range *es.orig { - newValueType(&(*es.orig)[i], es.state).CopyTo(newValueType(&(*dest.orig)[i], dest.state)) + wrappers[i] = &origs[i] + newValueType((*es.orig)[i], es.state).CopyTo(newValueType(wrappers[i], dest.state)) } + *dest.orig = wrappers +} + +// Sort sorts the ValueType elements within ValueTypeSlice given the +// provided less function so that two instances of ValueTypeSlice +// can be compared. +func (es ValueTypeSlice) Sort(less func(a, b ValueType) bool) { + es.state.AssertMutable() + sort.SliceStable(*es.orig, func(i, j int) bool { return less(es.At(i), es.At(j)) }) } diff --git a/pdata/pprofile/generated_valuetypeslice_test.go b/pdata/pprofile/generated_valuetypeslice_test.go index ac4ab1d7dab..79b380a8897 100644 --- a/pdata/pprofile/generated_valuetypeslice_test.go +++ b/pdata/pprofile/generated_valuetypeslice_test.go @@ -8,6 +8,7 @@ package pprofile import ( "testing" + "unsafe" "github.com/stretchr/testify/assert" @@ -19,7 +20,7 @@ func TestValueTypeSlice(t *testing.T) { es := NewValueTypeSlice() assert.Equal(t, 0, es.Len()) state := internal.StateMutable - es = newValueTypeSlice(&[]otlpprofiles.ValueType{}, &state) + es = newValueTypeSlice(&[]*otlpprofiles.ValueType{}, &state) assert.Equal(t, 0, es.Len()) emptyVal := NewValueType() @@ -35,7 +36,7 @@ func TestValueTypeSlice(t *testing.T) { func TestValueTypeSliceReadOnly(t *testing.T) { sharedState := internal.StateReadOnly - es := newValueTypeSlice(&[]otlpprofiles.ValueType{}, &sharedState) + es := newValueTypeSlice(&[]*otlpprofiles.ValueType{}, &sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -122,6 +123,22 @@ func TestValueTypeSlice_RemoveIf(t *testing.T) { assert.Equal(t, 5, filtered.Len()) } +func TestValueTypeSlice_Sort(t *testing.T) { + es := generateTestValueTypeSlice() + es.Sort(func(a, b ValueType) bool { + return uintptr(unsafe.Pointer(a.orig)) < uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Less(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } + es.Sort(func(a, b ValueType) bool { + return uintptr(unsafe.Pointer(a.orig)) > uintptr(unsafe.Pointer(b.orig)) + }) + for i := 1; i < es.Len(); i++ { + assert.Greater(t, uintptr(unsafe.Pointer(es.At(i-1).orig)), uintptr(unsafe.Pointer(es.At(i).orig))) + } +} + func generateTestValueTypeSlice() ValueTypeSlice { es := NewValueTypeSlice() fillTestValueTypeSlice(es) @@ -129,9 +146,9 @@ func generateTestValueTypeSlice() ValueTypeSlice { } func fillTestValueTypeSlice(es ValueTypeSlice) { - *es.orig = make([]otlpprofiles.ValueType, 7) + *es.orig = make([]*otlpprofiles.ValueType, 7) for i := 0; i < 7; i++ { - (*es.orig)[i] = otlpprofiles.ValueType{} - fillTestValueType(newValueType(&(*es.orig)[i], es.state)) + (*es.orig)[i] = &otlpprofiles.ValueType{} + fillTestValueType(newValueType((*es.orig)[i], es.state)) } } diff --git a/pdata/pprofile/profiles_test.go b/pdata/pprofile/profiles_test.go index a03398967c3..1ed16739155 100644 --- a/pdata/pprofile/profiles_test.go +++ b/pdata/pprofile/profiles_test.go @@ -71,7 +71,7 @@ func TestSampleCountWithEmpty(t *testing.T) { Profiles: []*otlpprofile.ProfileContainer{ { Profile: otlpprofile.Profile{ - Sample: []otlpprofile.Sample{ + Sample: []*otlpprofile.Sample{ {}, }, }, diff --git a/proto_patch.sed b/proto_patch.sed index 50cb2f862fa..831f9a6bad2 100644 --- a/proto_patch.sed +++ b/proto_patch.sed @@ -61,32 +61,5 @@ s+bytes profile_id = \(.*\);+bytes profile_id = \1\ (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.ProfileID"\ ];+g -s+repeated ValueType \(.*\);+repeated ValueType \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Sample \(.*\);+repeated Sample \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Mapping \(.*\);+repeated Mapping \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Location \(.*\);+repeated Location \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Label \(.*\);+repeated Label \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Function \(.*\);+repeated Function \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated AttributeUnit \(.*\);+repeated AttributeUnit \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Link link_table \(.*\);+repeated Link link_table \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Line \(.*\);+repeated Line \1\ - [ (gogoproto.nullable) = false ];+g - s+ValueType period_type \(.*\);+ValueType period_type \1\ [ (gogoproto.nullable) = false ];+g