Eliaaazzz commented on code in PR #39090:
URL: https://github.com/apache/beam/pull/39090#discussion_r3672435458


##########
sdks/python/apache_beam/io/watch.py:
##########
@@ -322,18 +382,31 @@ def __init__(self, output_coder: Coder, termination: 
TerminationCondition):
         nullable_ts,
         coders.ListCoder(TupleCoder([coders.BytesCoder(), TimestampCoder()])),
     ])
+    self._cursor_polling_coder = TupleCoder([
+        termination.state_coder(),
+        nullable_ts,
+        coders.ListCoder(TupleCoder([coders.BytesCoder(), TimestampCoder()])),
+        TimestampCoder(),
+    ])
     self._non_polling_coder = TupleCoder([
         nullable_ts,
         coders.ListCoder(_TimestampedValueCoder(output_coder)),
     ])
 
   def encode(self, state: _GrowthState) -> bytes:
     if isinstance(state, _PollingGrowthState):
-      payload = self._polling_coder.encode((
+      if state.cursor is None:
+        payload = self._polling_coder.encode((
+            state.termination_state,
+            state.poll_watermark,
+            list(state.completed.items())))
+        return self._envelope_coder.encode((0, payload))
+      payload = self._cursor_polling_coder.encode((
           state.termination_state,
           state.poll_watermark,
-          list(state.completed.items())))
-      return self._envelope_coder.encode((0, payload))
+          list(state.completed.items()),

Review Comment:
   One more follow up commit, 098623b: the hash to cursor switch now seeds the 
cursor from the hash map's greatest recorded event time instead of starting 
empty, so the switch cannot re-emit already seen outputs. 



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