damccorm commented on code in PR #41240:
URL: https://github.com/apache/beam/pull/41240#discussion_r4681671106


##########
sdks/python/apache_beam/coders/coder_impl.py:
##########
@@ -1803,17 +1806,16 @@ def __init__(self, window_coder_impl: CoderImpl) -> 
None:
     self._window_coder_impl = window_coder_impl
 
   def encode_to_stream(self, value, stream, nested):
-    TimestampCoderImpl().encode_to_stream(value.max_timestamp(), stream, 
nested)
+    _TIMESTAMP_CODER_IMPL.encode_to_stream(
+        value.max_timestamp(), stream, nested)
     self._window_coder_impl.encode_to_stream(value, stream, nested)
 
   def decode_from_stream(self, stream, nested):
-    TimestampCoderImpl().decode_from_stream(stream, nested)
+    stream.read_bigendian_int64()

Review Comment:
   This isn't exactly equivalent to the original, so we can't make this change. 
Instead, do this to avoid the TimestampCoderImpl initialization:
   
   ```suggestion
       _TIMESTAMP_CODER_IMPL.decode_from_stream(stream, nested)
   ```



##########
sdks/python/apache_beam/coders/coder_impl.py:
##########
@@ -1803,17 +1806,16 @@ def __init__(self, window_coder_impl: CoderImpl) -> 
None:
     self._window_coder_impl = window_coder_impl
 
   def encode_to_stream(self, value, stream, nested):
-    TimestampCoderImpl().encode_to_stream(value.max_timestamp(), stream, 
nested)
+    _TIMESTAMP_CODER_IMPL.encode_to_stream(
+        value.max_timestamp(), stream, nested)
     self._window_coder_impl.encode_to_stream(value, stream, nested)
 
   def decode_from_stream(self, stream, nested):
-    TimestampCoderImpl().decode_from_stream(stream, nested)
+    stream.read_bigendian_int64()
     return self._window_coder_impl.decode_from_stream(stream, nested)
 
   def estimate_size(self, value: Any, nested: bool = False) -> int:
-    return (
-        TimestampCoderImpl().estimate_size(value.max_timestamp()) +
-        self._window_coder_impl.estimate_size(value, nested))
+    return 8 + self._window_coder_impl.estimate_size(value, nested)

Review Comment:
   Where does 8 come from? Can we make this a constant next to 
`_TIMESTAMP_CODER_IMPL` and actually calculate it for a real timestamp instead 
of using a magic number?



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