TransformHierarchy

TransformHierarchy is a relationship graph of named TransformHierarchy.Nodes (of PTransforms).

Creating Instance

TransformHierarchy takes no arguments to be created.

TransformHierarchy creates empty producers, producerInput and unexpandedInputs internal registries. TransformHierarchy creates the root node and makes it current.

TransformHierarchy is created for Pipeline.

Root Node

TransformHierarchy creates a root-level TransformHierarchy.Node when created.

Immediately after being created the root-level node becomes the current node.

Current Node

Node getCurrent()

getCurrent returns the TransformHierarchy.Node currently being worked on.

pushNode Method

Node pushNode(
  String name,
  PInput input,
  PTransform<?, ?> transform)

pushNode creates a new TransformHierarchy.Node with the current node as the enclosing node (and the given name, the PInput and PTransform).

pushNode adds the new Node to the unexpandedInputs registry.

pushNode requests the current node to addComposite (with the new Node) and makes the new Node the current node.

pushNode is used when Pipeline is requested to applyInternal.

finishSpecifyingInput Method

void finishSpecifyingInput()

finishSpecifyingInput is used when Pipeline is requested to applyInternal.

setOutput Method

void setOutput(
  POutput output)

setOutput is used when Pipeline is requested to applyInternal and applyReplacement.

replaceNode Method

Node replaceNode(
  Node existing,
  PInput input,
  PTransform<?, ?> transform)

replaceNode is used when Pipeline is requested to applyReplacement.

popNode Method

void popNode()

popNode requests the current node to finishSpecifying.

popNode removes the current node from unexpandedInputs internal registry.

popNode requests the current node to getEnclosingNode and makes it the current node.

popNode throws an IllegalStateException when the enclosing node is not available (null):

Can't pop the root node of a TransformHierarchy

popNode is used when Pipeline is requested to applyInternal and applyReplacement.

visit Method

Set<PValue> visit(
  PipelineVisitor visitor)

visit finishSpecifying and requests the root node to visit (using the given PipelineVisitor). In the end, visit returns the PValues (that were collected during visit).

visit is used when Pipeline is requested to traverseTopologically.

finishSpecifying Internal Method

void finishSpecifying()

finishSpecifying…​FIXME

finishSpecifying is used when TransformHierarchy is requested to visit.

Internal Properties

unexpandedInputs

Map<Node, PInput> unexpandedInputs

unexpandedInputs are Nodes with the PInput "unexpanded" (i.e. PInputs before expand).

unexpandedInputs is added a new pair when pushNode and replaceNode.

unexpandedInputs is removed a pair when popNode and replaceNode.

unexpandedInputs is used when setOutput.

producers

Map<POutput, Node> producers

producerInput

Map<PValue, PInput> producerInput

Demo

import org.apache.beam.sdk.runners.TransformHierarchy
val th = new TransformHierarchy

scala> println(th.getCurrent)
RootNode

scala> println(th.getCurrent.getClass.getName)
org.apache.beam.sdk.runners.TransformHierarchy$Node