Skip to content
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

Do we need MoveAndAppendTo or can we replaces with simpler MoveTo for consistency? #6155

Closed
bogdandrutu opened this issue Sep 27, 2022 · 14 comments
Assignees

Comments

@bogdandrutu
Copy link
Member

No description provided.

@bogdandrutu bogdandrutu added the area:pdata pdata module related issues label Sep 27, 2022
@dmitryax
Copy link
Member

MoveTo always replaces the destination, but MoveAndAppendTo appends new elements. I think we should have distinctive names for those purposes, maybe not to verbose?

@bogdandrutu
Copy link
Member Author

But do we need the one with the Append functionality at this point?

@dmitryax
Copy link
Member

You mean AppendEmpty? It cannot be replaces with a one-liner. User would have to iterate over the source slice with At(i).CopyTo(dest.AppendEmpty())

@dmitryax
Copy link
Member

Sound good. I believe, if we confirm that MoveAndAppendTo is redundant in contrib, we can remove it

@bogdandrutu
Copy link
Member Author

bogdandrutu commented Oct 4, 2022

My investigation led to the conclusion that there are few cases where the "MoveAndAppend" is useful, see the usages:

Because of that, I believe we may want to keep it. The only things left are to investigate:

  1. Do we also need a MoveTo func as well? I believe this can be done also by adding a Clear func, and combine that with the current MoveAndAppendTo. We probably can postpone this.
  2. Is the MoveAndAppendTo a good enough name? I believe it is decent, unless anyone has a better suggestion I would not change it.

@open-telemetry/collector-approvers

@dmitryax
Copy link
Member

dmitryax commented Oct 5, 2022

I agree that name MoveAndAppendTo is good enough.

Currently we have only CopyTo and MoveAndAppendTo for slices. Maybe it make sense to have MoveTo, CopyTo, MoveAndAppendTo and CopyAndAppendTo for consistency? It'll be move clear that the first two override the destination. Or they can be removed in favor of Clear.

Also pcommon.Map currently has CopyTo only. I've seen a few places where merge capability would be pretty useful in contrib. So maybe we can add MoveTo, MoveAndPutTo, CopyAndPutTo there?

@bogdandrutu
Copy link
Member Author

Is anything right now that blocks us to evolve in the future? Adding new funcs can always happen later, the problem is with removing, so do we want to remove any of them?

@dmitryax
Copy link
Member

Right. I don't see any method that should be removed at this point.

@bogdandrutu
Copy link
Member Author

bogdandrutu commented Oct 12, 2022

Then we can move this after the release?

@dmitryax
Copy link
Member

dmitryax commented Oct 13, 2022

Then we can move this after the release?

Sure, no rush needed with that. No breaking changes expected

@bogdandrutu
Copy link
Member Author

I think this issue is now complete. If needed in the future to extend the functionality we can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants