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


##########
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

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



##########
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:
   Do we want to enforce the class strictly or allow matching for subclasses 
too? 
   e.g.
   
   ``` python
   if issubclass(value_t, t):
     ...
   ```



-- 
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