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


##########
sdks/python/apache_beam/runners/worker/bundle_processor.py:
##########
@@ -1030,9 +1034,9 @@ def _create_state(
               bag_user_state=beam_fn_api_pb2.StateKey.BagUserState(
                   transform_id=self._transform_id,
                   user_state_id=state_spec.name,
-                  window=self._window_coder.encode(window),
+                  window=self._window_coder_impl.encode(window),

Review Comment:
   This shouldn't change the output — for `FastCoder` subclasses (all built-in 
window coders like `GlobalWindowCoder`), `Coder.encode(value)` just calls 
`self.get_impl().encode(value)`.
   
   For custom `Coder` subclasses that only override `encode()`, 
`Coder._create_impl()` wraps `self.encode` in a `CallbackCoderImpl` whose 
`.encode()` calls back into `coder.encode(value)`. Caching `_window_coder_impl` 
and `_key_coder_impl` in `__init__` just avoids the extra wrapper call and 
`hasattr(self, '_impl')` check on each `_create_state` call.
   
   Same comment applies elsewhere



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