damccorm commented on code in PR #41176:
URL: https://github.com/apache/beam/pull/41176#discussion_r4529815550
##########
sdks/python/apache_beam/runners/worker/operations.py:
##########
@@ -1222,16 +1223,23 @@ def finish(self):
def flush(self, target):
# type: (int) -> None
limit = self.size - target
- for ix, (kw, vs) in enumerate(list(self.table.items())):
+ if limit <= 0:
+ return
+ keys_to_delete = []
+ for ix, (kw, vs) in enumerate(self.table.items()):
if ix >= limit:
break
- del self.table[kw]
+ keys_to_delete.append(kw)
key, windows = kw
output_value = [v.value[1] for v in vs]
- windowed_value = WindowedValue((key, output_value),
- vs[0].timestamp,
- windows)
+ windowed_value = windowed_value_create((key, output_value),
+ vs[0].timestamp_micros,
+ windows,
+ vs[0].pane_info)
self.output(windowed_value)
+ for kw in keys_to_delete:
+ del self.table[kw]
+ self.size -= len(keys_to_delete)
Review Comment:
Fixed in 389aa1819f9: added the `target <= 0` full-flush fast path
(`self.table.clear()` and `self.size = 0`) and decremented `self.size -=
len(vs)` per flushed key until `self.size <= target` on partial flushes.
--
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]