damccorm commented on code in PR #41267:
URL: https://github.com/apache/beam/pull/41267#discussion_r4683006761
##########
sdks/python/apache_beam/coders/coder_impl.py:
##########
@@ -1670,18 +1672,14 @@ def get_estimated_size_and_observables(self, value,
nested=False):
# Should never be here.
# TODO(robertwb): Remove when coders are set correctly.
return 0, [(value, self._value_coder)]
- estimated_size = 0
- observables = [] # type: Observables
- value_estimated_size, value_observables = (
+ value_estimated_size, observables = (
self._value_coder.get_estimated_size_and_observables(
value.value, nested=nested))
- estimated_size += value_estimated_size
- observables += value_observables
- estimated_size += (
- self._timestamp_coder.estimate_size(value.timestamp, nested=True))
- estimated_size += (
- self._windows_coder.estimate_size(value.windows, nested=True))
- estimated_size += (
+ # Timestamp is always encoded as an 8-byte big-endian uint64; avoid
+ # accessing value.timestamp which lazily allocates a Timestamp object.
+ estimated_size = (
+ value_estimated_size + 8 +
Review Comment:
Updated in 94a24d18e07 to compute `self._timestamp_encoded_size =
timestamp_coder.estimate_size(Timestamp(0), nested=True)` once in
`WindowedValueCoderImpl.__init__` (declared `cdef int _timestamp_encoded_size`
in `coder_impl.pxd`) and reuse it in `get_estimated_size_and_observables`.
--
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]