robertwb commented on code in PR #33382:
URL: https://github.com/apache/beam/pull/33382#discussion_r1888862483


##########
sdks/python/apache_beam/coders/coder_impl.py:
##########
@@ -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
+    self._types, self._coder_impls = zip(*coder_impl_types)
+    self._fallback_coder_impl = fallback_coder_impl
+
+  def encode_to_stream(self, value, out, nested):
+    value_t = type(value)
+    for (ix, t) in enumerate(self._types):
+      if value_t is t:

Review Comment:
   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. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to