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

Remove some code duplication between SequentialWriter and SequentialCompressionWriter #527

Merged
merged 4 commits into from
Oct 2, 2020

Conversation

jaisontj
Copy link
Contributor

@jaisontj jaisontj commented Sep 29, 2020

[Edited] Major changes:

  • SequentialCompressionWriter now inherits from SequentialWriter
  • New method get_writeable_message inside of SequentialWriter to be called to get the message to be written to storage or cache

from SequentialWriter.
Created a new function prepare_to_open in SequentialWriter to reuse code
with SequentialCompressionWriter

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
@jaisontj jaisontj changed the title Remove some of the code duplication between SequentialWriter and SequentialCompressionWriter Remove some code duplication between SequentialWriter and SequentialCompressionWriter Sep 30, 2020
@jaisontj jaisontj marked this pull request as ready for review September 30, 2020 16:56
@jaisontj jaisontj requested a review from a team as a code owner September 30, 2020 16:56
Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

This LGTM - but it looks like it will need another pass to consolidate the logic in write, so that the caching logic is not duplicated. In this case, it seems like the SequentialCompressionWriter isn't doing caching at all, that's how badly it's diverged.

get_writeable_message which performs the operations on messages before
writing it to storage or cache.

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
Copy link
Contributor

@dabonnie dabonnie left a comment

Choose a reason for hiding this comment

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

Can you please add unit tests for new methods?

@jaisontj
Copy link
Contributor Author

jaisontj commented Oct 1, 2020

Can you please add unit tests for new methods?

@dabonnie The new methods are non public and used internally as helper methods. Do we usually write unit tests for those?

@emersonknapp
Copy link
Collaborator

No, generally you unit test the public interface, not the implementation details (private methods). You can of course unit test protected methods by making a test-specific subclass of the given class, but that depends on how much you consider it an interface surface vs an implementation detail.

overriding open

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
which open worked inside compressionwriter does not really matter

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
Copy link
Contributor

@dabonnie dabonnie left a comment

Choose a reason for hiding this comment

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

Thanks for iterating, this is much cleaner!

@jaisontj
Copy link
Contributor Author

jaisontj commented Oct 1, 2020

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jaisontj jaisontj merged commit d745972 into ros2:master Oct 2, 2020
@jaisontj jaisontj deleted the jaisontj/refactor-write branch October 2, 2020 01:30
emersonknapp pushed a commit that referenced this pull request Feb 2, 2021
…ompressionWriter (#527)

Remove code duplication between SequentialWriter and SequentialCompressionWriter

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
emersonknapp pushed a commit that referenced this pull request Feb 17, 2021
…ompressionWriter (#527)

Remove code duplication between SequentialWriter and SequentialCompressionWriter

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
skudryas pushed a commit to skudryas/rosbag2 that referenced this pull request Mar 12, 2021
…ompressionWriter (ros2#527)

Remove code duplication between SequentialWriter and SequentialCompressionWriter

Signed-off-by: Jaison Titus <jaisontj@amazon.com>
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.

None yet

3 participants