diff --git a/website/www/site/content/en/documentation/programming-guide.md b/website/www/site/content/en/documentation/programming-guide.md index 1ee679d30635..838a408520c6 100644 --- a/website/www/site/content/en/documentation/programming-guide.md +++ b/website/www/site/content/en/documentation/programming-guide.md @@ -1095,9 +1095,11 @@ that for you. Your `@ProcessElement` method should accept a parameter tagged wit `@Element`, which will be populated with the input element. In order to output elements, the method can also take a parameter of type `OutputReceiver` which provides a method for emitting elements. The parameter types must match the input -and output types of your `DoFn` or the framework will raise an error. Note: `@Element` and -`OutputReceiver` were introduced in Beam 2.5.0; if using an earlier release of Beam, a -`ProcessContext` parameter should be used instead. +and output types of your `DoFn` or the framework will raise an error. `@Element` and +`OutputReceiver`, introduced in Beam 2.5.0, provide element access and output without the older +`ProcessContext` parameter (`c.element()` and `c.output(...)`), which remains supported. Prefer +these narrower parameters when they are sufficient: declaring only what your `DoFn` uses tells +the runner which capabilities it needs, whereas `ProcessContext` can access the full context. {{< /paragraph >}} {{< paragraph class="language-py language-typescript" >}} @@ -2679,6 +2681,13 @@ first map a field to an iterable type and then follow this transform with an exploded field. {{< /paragraph >}} +{{< paragraph class="language-java">}} +For multiple outputs, prefer `MultiOutputReceiver` over a `ProcessContext` when it covers your +output needs. The receiver exposes only tagged output emitters, while `ProcessContext` can access +the full execution context. Declaring the narrower dependency lets the runner assume that your +`DoFn` uses only the output capability it declares. +{{< /paragraph >}} + {{< highlight java >}} // Inside your ParDo's DoFn, you can emit an element to a specific output PCollection by providing a // MultiOutputReceiver to your process method, and passing in the appropriate TupleTag to obtain an OutputReceiver.