tvalentyn commented on code in PR #32513:
URL: https://github.com/apache/beam/pull/32513#discussion_r1772107978


##########
sdks/python/apache_beam/transforms/periodicsequence.py:
##########
@@ -48,14 +48,27 @@ def initial_restriction(self, element):
   def create_tracker(self, restriction):
     return OffsetRestrictionTracker(restriction)
 
-  def restriction_size(self, unused_element, restriction):
-    return restriction.size()
+  def restriction_size(self, element, restriction):
+    return sequence_backlog_bytes(element, time.time(), restriction)
 
   # On drain, immediately stop emitting new elements
   def truncate(self, unused_element, unused_restriction):
     return None
 
 
+def sequence_backlog_bytes(element, now, offset_range):

Review Comment:
   ```suggestion
   def _sequence_backlog_bytes(element, now, offset_range):
   ```
   
   (Since it's seems to be an internal helper)



##########
sdks/python/apache_beam/transforms/periodicsequence.py:
##########
@@ -48,14 +48,27 @@ def initial_restriction(self, element):
   def create_tracker(self, restriction):
     return OffsetRestrictionTracker(restriction)
 
-  def restriction_size(self, unused_element, restriction):
-    return restriction.size()
+  def restriction_size(self, element, restriction):
+    return sequence_backlog_bytes(element, time.time(), restriction)
 
   # On drain, immediately stop emitting new elements
   def truncate(self, unused_element, unused_restriction):
     return None
 
 
+def sequence_backlog_bytes(element, now, offset_range):

Review Comment:
   Is it important for the return value to be precise (e.g. up to a byte), or 
these are all estimates?



##########
sdks/python/apache_beam/transforms/periodicsequence.py:
##########
@@ -48,14 +48,27 @@ def initial_restriction(self, element):
   def create_tracker(self, restriction):
     return OffsetRestrictionTracker(restriction)
 
-  def restriction_size(self, unused_element, restriction):
-    return restriction.size()
+  def restriction_size(self, element, restriction):
+    return sequence_backlog_bytes(element, time.time(), restriction)
 
   # On drain, immediately stop emitting new elements
   def truncate(self, unused_element, unused_restriction):
     return None
 
 
+def sequence_backlog_bytes(element, now, offset_range):

Review Comment:
   Would this be an appropriate docstring?
   
   "Calculates size of the output that the sequence should have emitted up to 
now"
   



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