-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pdata] Migrate immutable primitive slices to mutable wrappers #5971
Conversation
We need a rebase on this. |
e475d18
to
7220a79
Compare
Codecov ReportBase: 91.98% // Head: 91.99% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #5971 +/- ##
==========================================
+ Coverage 91.98% 91.99% +0.01%
==========================================
Files 213 213
Lines 13320 13358 +38
==========================================
+ Hits 12252 12289 +37
Misses 850 850
- Partials 218 219 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
3b978e2
to
92458f8
Compare
4aedd34
to
30c0388
Compare
ec1a2de
to
43b105a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it.
Change API for primitive slice wrappers to allow changing items as it appeared to be expensive to update that data as immutable wrappers: it requires making two copies to update a slice
43b105a
to
99b9d97
Compare
} | ||
|
||
// FromRaw copies raw []${itemType} into the slice ${structName}. | ||
func (ms ${structName}) FromRaw(val []${itemType}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bogdandrutu do you think we should return ms here?
Otherwise current inline usages of pcommon.NewImmutable...Slice()
becomes pretty clunky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for me, I'm not sure about that. I don't like returning it and I don't like how it complicates the usages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me apply current state of this PR on contrib, and we'll see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks pretty good open-telemetry/opentelemetry-collector-contrib#14016 I believe we should keep current version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things to do in a followup PR:
- Copying can be done in-place to save allocations.
- No way of increasing the capacity or length. We can discuss about that API.
- Add CopyTo/MoveTo and remove the copy logic from the parent's CopyTo.
Sounds good. I'll follow up on those |
This PR changes API for primitive slice wrappers to allow changing items directly since it appeared to be expensive to update that data as immutable wrappers: it required making two copies to update a slice.
This is a solution alternative to #5947
Update #5859
The wrappers for primitive slices doesn't represent atomic objects, they are treated the same way as other "complex" collection wrapper e.g.
pcommon.Slice
orpcommon.Map