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


##########
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:
   Updated in 918d2aa840e to use 
`_TIMESTAMP_CODER_IMPL.decode_from_stream(stream, nested)` instead of 
`stream.read_bigendian_int64()`.



##########
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:
   Updated in 918d2aa840e to define `_TIMESTAMP_ENCODED_SIZE = 
_TIMESTAMP_CODER_IMPL.estimate_size(Timestamp(0))` next to 
`_TIMESTAMP_CODER_IMPL` and use it in both `estimate_size` methods.



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