| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. |
| 5 |
// To regenerate this file run "make genpdata". |
| 6 |
|
| 7 |
package pprofile |
| 8 |
|
| 9 |
import ( |
| 10 |
"go.opentelemetry.io/collector/pdata/internal" |
| 11 |
"go.opentelemetry.io/collector/pdata/pcommon" |
| 12 |
) |
| 13 |
|
| 14 |
// KeyValueAndUnit represents a custom 'dictionary native' |
| 15 |
// style of encoding attributes which is more convenient |
| 16 |
// for profiles than opentelemetry.proto.common.v1.KeyValue. |
| 17 |
// |
| 18 |
// This is a reference type, if passed by value and callee modifies it the |
| 19 |
// caller will see the modification. |
| 20 |
// |
| 21 |
// Must use NewKeyValueAndUnit function to create new instances. |
| 22 |
// Important: zero-initialized instance is not valid for use. |
| 23 |
type KeyValueAndUnit struct { |
| 24 |
orig *internal.KeyValueAndUnit |
| 25 |
state *internal.State |
| 26 |
} |
| 27 |
|
| 28 |
func newKeyValueAndUnit(orig *internal.KeyValueAndUnit, state *internal.State) KeyValueAndUnit { |
| 29 |
return KeyValueAndUnit{orig: orig, state: state} |
| 30 |
} |
| 31 |
|
| 32 |
// NewKeyValueAndUnit creates a new empty KeyValueAndUnit. |
| 33 |
// |
| 34 |
// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, |
| 35 |
// OR directly access the member if this is embedded in another struct. |
| 36 |
func NewKeyValueAndUnit() KeyValueAndUnit { |
| 37 |
return newKeyValueAndUnit(internal.NewKeyValueAndUnit(), internal.NewState()) |
| 38 |
} |
| 39 |
|
| 40 |
// MoveTo moves all properties from the current struct overriding the destination and |
| 41 |
// resetting the current instance to its zero value |
| 42 |
func (ms KeyValueAndUnit) MoveTo(dest KeyValueAndUnit) { |
| 43 |
ms.state.AssertMutable() |
| 44 |
dest.state.AssertMutable() |
| 45 |
// If they point to the same data, they are the same, nothing to do. |
| 46 |
if ms.orig == dest.orig { |
| 47 |
return |
| 48 |
} |
| 49 |
internal.DeleteKeyValueAndUnit(dest.orig, false) |
| 50 |
*dest.orig, *ms.orig = *ms.orig, *dest.orig |
| 51 |
} |
| 52 |
|
| 53 |
// KeyStrindex returns the keystrindex associated with this KeyValueAndUnit. |
| 54 |
func (ms KeyValueAndUnit) KeyStrindex() int32 { |
| 55 |
return ms.orig.KeyStrindex |
| 56 |
} |
| 57 |
|
| 58 |
// SetKeyStrindex replaces the keystrindex associated with this KeyValueAndUnit. |
| 59 |
func (ms KeyValueAndUnit) SetKeyStrindex(v int32) { |
| 60 |
ms.state.AssertMutable() |
| 61 |
ms.orig.KeyStrindex = v |
| 62 |
} |
| 63 |
|
| 64 |
// Value returns the value associated with this KeyValueAndUnit. |
| 65 |
func (ms KeyValueAndUnit) Value() pcommon.Value { |
| 66 |
return pcommon.Value(internal.NewValueWrapper(&ms.orig.Value, ms.state)) |
| 67 |
} |
| 68 |
|
| 69 |
// UnitStrindex returns the unitstrindex associated with this KeyValueAndUnit. |
| 70 |
func (ms KeyValueAndUnit) UnitStrindex() int32 { |
| 71 |
return ms.orig.UnitStrindex |
| 72 |
} |
| 73 |
|
| 74 |
// SetUnitStrindex replaces the unitstrindex associated with this KeyValueAndUnit. |
| 75 |
func (ms KeyValueAndUnit) SetUnitStrindex(v int32) { |
| 76 |
ms.state.AssertMutable() |
| 77 |
ms.orig.UnitStrindex = v |
| 78 |
} |
| 79 |
|
| 80 |
// CopyTo copies all properties from the current struct overriding the destination. |
| 81 |
func (ms KeyValueAndUnit) CopyTo(dest KeyValueAndUnit) { |
| 82 |
dest.state.AssertMutable() |
| 83 |
internal.CopyKeyValueAndUnit(dest.orig, ms.orig) |
| 84 |
} |