yifanmai commented on a change in pull request #13303:
URL: https://github.com/apache/beam/pull/13303#discussion_r523237999



##########
File path: 
sdks/python/apache_beam/runners/portability/fn_api_runner/translations.py
##########
@@ -1212,6 +1213,22 @@ def get_ancestors(name):
   return None
 
 
+def _parent_for_fused_stages(stages, context):
+  # type: (Iterable[str], TransformContext) -> Optional[str]
+
+  '''Returns the name of the new parent for the fused stages.
+
+  The new parent is the lowest common ancestor of the fused stages that is not
+  contained in the set of fused stages. The provided context is used to compute
+  ancestors of stages.
+  '''
+  result = functools.reduce(
+      lambda a, b: _lowest_common_ancestor(a, b, context), stages)
+  if result in stages:
+    result = context.parents_map().get(result)

Review comment:
       Yes; if `result` was the lowest common ancestor for set S (where nodes 
are ancestors of themselves), then it is impossible for `result`'s parent to 
still be in S; otherwise `result` would not be an ancestor of `result`'s 
parent, which is in S, which contradicts `result`'s status as lowest common 
ancestor of S.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to