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

Faster default coder for unknown windows. #33382

Merged
merged 3 commits into from
Dec 17, 2024
Merged

Conversation

robertwb
Copy link
Contributor

This will get used in a windowed reshuffle, among other places.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

This will get used in a windowed reshuffle, among other places.
@robertwb
Copy link
Contributor Author

R: @shunping

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

Copy link
Contributor

@shunping shunping left a comment

Choose a reason for hiding this comment

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

I left some minor comments. LGTM overall.

@@ -1421,6 +1421,37 @@ def estimate_size(self, value, nested=False):
return size


class _OrderedUnionCoderImpl(StreamCoderImpl):
def __init__(self, coder_impl_types, fallback_coder_impl):
assert len(coder_impl_types) < 128
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, why do we set the upper bound to 128 here? Shouldn't it be 255 given ix==0xFF is reserved for fallback coder in the following code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first I was thinking about avoiding any sign issues, but also this leaves headroom for expanding the protocol in the future.

def encode_to_stream(self, value, out, nested):
value_t = type(value)
for (ix, t) in enumerate(self._types):
if value_t is t:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to enforce the class strictly or allow matching for subclasses too?
e.g.

if issubclass(value_t, t):
  ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm comparing exact types here to make the round trip faithful. E.g. a Coder[T] is unlikely to faithfully encode and decode all subclasses of T. This is how fast primitives coder works as well.

@robertwb
Copy link
Contributor Author

Thanks for the review.

@robertwb robertwb merged commit f7a7bdd into apache:master Dec 17, 2024
92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants