blob: bf148c701e879885b3ac400a82199366ff3aa9ed [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_181-google-v7) on Wed Aug 14 17:37:13 PDT 2019 -->
<title>DoFn.ProcessElement (Apache Beam 2.15.0-SNAPSHOT)</title>
<meta name="date" content="2019-08-14">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DoFn.ProcessElement (Apache Beam 2.15.0-SNAPSHOT)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessContinuation.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/transforms/DoFn.RequiresStableInput.html" title="annotation in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/DoFn.ProcessElement.html" target="_top">Frames</a></li>
<li><a href="DoFn.ProcessElement.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.beam.sdk.transforms</div>
<h2 title="Annotation Type DoFn.ProcessElement" class="title">Annotation Type DoFn.ProcessElement</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Documented
@Retention(value=RUNTIME)
@Target(value=METHOD)
public static @interface <span class="memberNameLabel">DoFn.ProcessElement</span></pre>
<div class="block">Annotation for the method to use for processing elements. A subclass of <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a> must have
a method with this annotation.
<p>The signature of this method must satisfy the following constraints:
<ul>
<li>If one of its arguments is a <a href="../../../../../org/apache/beam/sdk/transforms/splittabledofn/RestrictionTracker.html" title="class in org.apache.beam.sdk.transforms.splittabledofn"><code>RestrictionTracker</code></a>, then it is a <a
href="https://s.apache.org/splittable-do-fn">splittable</a> <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a> subject to the
separate requirements described below. Items below are assuming this is not a splittable
<a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a>.
<li>If one of its arguments is tagged with the <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.Element.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.Element</code></a> annotation, then it will be
passed the current element being processed; the argument type must match the input type
of this DoFn.
<li>If one of its arguments is tagged with the <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.Timestamp.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.Timestamp</code></a> annotation, then it will be
passed the timestamp of the current element being processed; the argument must be of type
<a href="https://static.javadoc.io/joda-time/joda-time/2.10.1/org/joda/time/Instant.html?is-external=true" title="class or interface in org.joda.time"><code>Instant</code></a>.
<li>If one of its arguments is a subtype of <a href="../../../../../org/apache/beam/sdk/transforms/windowing/BoundedWindow.html" title="class in org.apache.beam.sdk.transforms.windowing"><code>BoundedWindow</code></a>, then it will be passed the
window of the current element. When applied by <a href="../../../../../org/apache/beam/sdk/transforms/ParDo.html" title="class in org.apache.beam.sdk.transforms"><code>ParDo</code></a> the subtype of <a href="../../../../../org/apache/beam/sdk/transforms/windowing/BoundedWindow.html" title="class in org.apache.beam.sdk.transforms.windowing"><code>BoundedWindow</code></a> must match the type of windows on the input <a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values"><code>PCollection</code></a>. If the
window is not accessed a runner may perform additional optimizations.
<li>If one of its arguments is of type <a href="../../../../../org/apache/beam/sdk/transforms/windowing/PaneInfo.html" title="class in org.apache.beam.sdk.transforms.windowing"><code>PaneInfo</code></a>, then it will be passed information
about the current triggering pane.
<li>If one of the parameters is of type <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options"><code>PipelineOptions</code></a>, then it will be passed the
options for the current pipeline.
<li>If one of the parameters is of type <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.OutputReceiver.html" title="interface in org.apache.beam.sdk.transforms"><code>DoFn.OutputReceiver</code></a>, then it will be passed an
output receiver for outputting elements to the default output.
<li>If one of the parameters is of type <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.MultiOutputReceiver.html" title="interface in org.apache.beam.sdk.transforms"><code>DoFn.MultiOutputReceiver</code></a>, then it will be passed
an output receiver for outputting to multiple tagged outputs.
<li>If one of the parameters is of type <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.BundleFinalizer.html" title="interface in org.apache.beam.sdk.transforms"><code>DoFn.BundleFinalizer</code></a>, then it will be passed a
mechanism to register a callback that will be invoked after the runner successfully
commits the output of this bundle. See <a
href="https://s.apache.org/beam-finalizing-bundles">Apache Beam Portability API: How to
Finalize Bundles</a> for further details.
<li>It must return <code>void</code>.
</ul>
<h2>Splittable DoFn's</h2>
<p>A <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a> is <i>splittable</i> if its <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.ProcessElement</code></a> method has a parameter
whose type is of <a href="../../../../../org/apache/beam/sdk/transforms/splittabledofn/RestrictionTracker.html" title="class in org.apache.beam.sdk.transforms.splittabledofn"><code>RestrictionTracker</code></a>. This is an advanced feature and an overwhelming
majority of users will never need to write a splittable <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a>.
<p>Not all runners support Splittable DoFn. See the <a
href="https://beam.apache.org/documentation/runners/capability-matrix/">capability matrix</a>.
<p>See <a href="https://s.apache.org/splittable-do-fn">the proposal</a> for an overview of the
involved concepts (<i>splittable DoFn</i>, <i>restriction</i>, <i>restriction tracker</i>).
<p>If a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a> is splittable, the following constraints must be respected:
<ul>
<li>It <i>must</i> define a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.GetInitialRestriction.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.GetInitialRestriction</code></a> method.
<li>It <i>may</i> define a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.GetSize.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.GetSize</code></a> method.
<li>It <i>may</i> define a <code>GetPartitition</code> method.
<li>It <i>may</i> define a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.SplitRestriction.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.SplitRestriction</code></a> method.
<li>It <i>may</i> define a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.NewTracker.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.NewTracker</code></a> method returning a subtype of <code>RestrictionTracker&lt;R&gt;</code> where <code>R</code> is the restriction type returned by <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.GetInitialRestriction.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.GetInitialRestriction</code></a>. This method is optional in case the restriction type returned by
<a href="../../../../../org/apache/beam/sdk/transforms/DoFn.GetInitialRestriction.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.GetInitialRestriction</code></a> implements <a href="../../../../../org/apache/beam/sdk/transforms/splittabledofn/HasDefaultTracker.html" title="interface in org.apache.beam.sdk.transforms.splittabledofn"><code>HasDefaultTracker</code></a>.
<li>It <i>may</i> define a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.GetRestrictionCoder.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.GetRestrictionCoder</code></a> method.
<li>The type of restrictions used by all of these methods must be the same.
<li>Its <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.ProcessElement</code></a> method <i>may</i> return a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessContinuation.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn.ProcessContinuation</code></a> to
indicate whether there is more work to be done for the current element.
<li>Its <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.ProcessElement</code></a> method <i>must not</i> use any extra context parameters, such
as <a href="../../../../../org/apache/beam/sdk/transforms/windowing/BoundedWindow.html" title="class in org.apache.beam.sdk.transforms.windowing"><code>BoundedWindow</code></a>.
<li>The <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a> itself <i>may</i> be annotated with <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.BoundedPerElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.BoundedPerElement</code></a> or <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.UnboundedPerElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.UnboundedPerElement</code></a>, but not both at the same time. If it's not annotated with either of
these, it's assumed to be <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.BoundedPerElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.BoundedPerElement</code></a> if its <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.ProcessElement</code></a> method
returns <code>void</code> and <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.UnboundedPerElement.html" title="annotation in org.apache.beam.sdk.transforms"><code>DoFn.UnboundedPerElement</code></a> if it returns a <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessContinuation.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn.ProcessContinuation</code></a>.
</ul>
<p>A non-splittable <a href="../../../../../org/apache/beam/sdk/transforms/DoFn.html" title="class in org.apache.beam.sdk.transforms"><code>DoFn</code></a> <i>must not</i> define any of these methods.</div>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/beam/sdk/transforms/DoFn.ProcessContinuation.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/transforms/DoFn.RequiresStableInput.html" title="annotation in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/DoFn.ProcessElement.html" target="_top">Frames</a></li>
<li><a href="DoFn.ProcessElement.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>