Skip to content

Remove BatchContainer::{copy, copy_range}.#508

Merged
frankmcsherry merged 2 commits intoTimelyDataflow:masterfrom
frankmcsherry:remove_batchcontainer_copy
May 31, 2024
Merged

Remove BatchContainer::{copy, copy_range}.#508
frankmcsherry merged 2 commits intoTimelyDataflow:masterfrom
frankmcsherry:remove_batchcontainer_copy

Conversation

@frankmcsherry
Copy link
Member

This PR replaces BatchContainer::copy with a PushInto requirement. We could leave the copy method while insisting on the PushInto implementation, if that provides more clarity about when we are specifically copying back a ReadItem, but it felt best to use the one idiom we have for implementing pushing into a container, vs having multiple implementations around (which we had).

BatchContainer::copy_range was removed because no one is using it. No harm adding it back, but in that case perhaps we instead want to support PushInto for a range type (or some wrapper around one).

@frankmcsherry frankmcsherry requested a review from antiguru May 31, 2024 13:19

/// A general-purpose container resembling `Vec<T>`.
pub trait BatchContainer: 'static {
pub trait BatchContainer: for<'a> PushInto<Self::ReadItem<'a>> + 'static {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in person: We could opt out of requiring BatchContainer to be PushInto<...> which would permit implementing containers that cannot be pushed at. For the moment, the change as implemented is probably the right thing to do, but in the future we could split the trait into ReadBatchContainer and BatchContainer where the former does not expose any functionality to modify the contents of the container. There's a similar idea in flatcontainer: antiguru/flatcontainer#27

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. I think this is a non-regression in the sense that copy prevents a read-only container also, and the main change is that in this PR that logic must be done through PushInto, and .. idk perhaps it's hard to use it for the implementation. But .. as long as it works for our current containers, great and it seems easy to roll back at any point.

@frankmcsherry frankmcsherry merged commit be698bc into TimelyDataflow:master May 31, 2024
@frankmcsherry frankmcsherry deleted the remove_batchcontainer_copy branch May 31, 2024 14:52
@frankmcsherry
Copy link
Member Author

Thanks for the review!

This was referenced Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants