| <!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 --> |
| <title>WithFailures (Apache Beam 2.47.0)</title> |
| <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="WithFailures (Apache Beam 2.47.0)"; |
| } |
| } |
| 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/Watch.WatchGrowthFn.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/WithFailures.html" target="_top">Frames</a></li> |
| <li><a href="WithFailures.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../../allclasses-noframe.html">All 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: </li> |
| <li><a href="#nested.class.summary">Nested</a> | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#methods.inherited.from.class.java.lang.Object">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li>Method</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="Class WithFailures" class="title">Class WithFailures</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li>java.lang.Object</li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.beam.sdk.transforms.WithFailures</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre><a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html" title="annotation in org.apache.beam.sdk.annotations">@Experimental</a>(<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html#value--">value</a>=<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.Kind.html#WITH_EXCEPTIONS">WITH_EXCEPTIONS</a>) |
| public class <span class="typeNameLabel">WithFailures</span> |
| extends java.lang.Object</pre> |
| <div class="block">A collection of utilities for writing transforms that can handle exceptions raised during |
| processing of elements. |
| |
| <p>Consuming transforms such as <a href="../../../../../org/apache/beam/sdk/transforms/MapElements.MapWithFailures.html" title="class in org.apache.beam.sdk.transforms"><code>MapElements.MapWithFailures</code></a> follow the general pattern of |
| taking in a user-defined exception handler of type <code>ProcessFunction<ExceptionElement<InputT>, FailureOutputT></code> where the input <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html" title="class in org.apache.beam.sdk.transforms"><code>WithFailures.ExceptionElement</code></a> contains an exception along with the input element that was being processed |
| when the exception was raised. This handler is responsible for producing some output element that |
| captures relevant details of the failure and can be encoded as part of a failure output <a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values"><code>PCollection</code></a>. Transforms can then package together their output and failure collections in a |
| <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="class in org.apache.beam.sdk.transforms"><code>WithFailures.Result</code></a> that avoids users needing to interact with <code>TupleTag</code>s and |
| indexing into a <a href="../../../../../org/apache/beam/sdk/values/PCollectionTuple.html" title="class in org.apache.beam.sdk.values"><code>PCollectionTuple</code></a>. |
| |
| <p>Exception handlers can narrow their scope by rethrowing the passed <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html#exception--"><code>WithFailures.ExceptionElement.exception()</code></a> and catching only specific subclasses of <code>Exception</code>. |
| Unhandled exceptions will generally bubble up to a top-level <a href="../../../../../org/apache/beam/sdk/Pipeline.PipelineExecutionException.html" title="class in org.apache.beam.sdk"><code>Pipeline.PipelineExecutionException</code></a> that halts progress. |
| |
| <p>Users can take advantage of <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html#failuresTo-java.util.List-"><code>WithFailures.Result.failuresTo(List)</code></a> for fluent chaining of transforms |
| that handle exceptions: |
| |
| <pre><code> |
| PCollection<Integer> input = ... |
| List<PCollection<Map<String, String>> failureCollections = new ArrayList<>(); |
| input.apply(MapElements.via(...).exceptionsVia(...)) |
| .failuresTo(failureCollections) |
| .apply(MapElements.via(...).exceptionsVia(...)) |
| .failuresTo(failureCollections); |
| PCollection<Map<String, String>> failures = PCollectionList.of(failureCollections) |
| .apply("FlattenFailureCollections", Flatten.pCollections()); |
| </code></pre></div> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ======== NESTED CLASS SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="nested.class.summary"> |
| <!-- --> |
| </a> |
| <h3>Nested Class Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation"> |
| <caption><span>Nested Classes</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Class and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>static class </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="class in org.apache.beam.sdk.transforms">WithFailures.ExceptionAsMapHandler</a><<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="type parameter in WithFailures.ExceptionAsMapHandler">T</a>></span></code> |
| <div class="block">A simple handler that extracts information from an exception to a <code>Map<String, String></code> |
| and returns a <a href="../../../../../org/apache/beam/sdk/values/KV.html" title="class in org.apache.beam.sdk.values"><code>KV</code></a> where the key is the input element that failed processing, and the |
| value is the map of exception attributes.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>static class </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html" title="class in org.apache.beam.sdk.transforms">WithFailures.ExceptionElement</a><<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html" title="type parameter in WithFailures.ExceptionElement">T</a>></span></code> |
| <div class="block">The value type passed as input to exception handlers.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>static class </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="class in org.apache.beam.sdk.transforms">WithFailures.Result</a><<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="type parameter in WithFailures.Result">OutputT</a> extends <a href="../../../../../org/apache/beam/sdk/values/POutput.html" title="interface in org.apache.beam.sdk.values">POutput</a>,<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="type parameter in WithFailures.Result">FailureElementT</a>></span></code> |
| <div class="block">An intermediate output type for PTransforms that allows an output collection to live alongside |
| a collection of elements that failed the transform.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>static class </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ThrowableHandler.html" title="class in org.apache.beam.sdk.transforms">WithFailures.ThrowableHandler</a><<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ThrowableHandler.html" title="type parameter in WithFailures.ThrowableHandler">T</a>></span></code> |
| <div class="block">A handler that holds onto the <code>Throwable</code> that led to the exception, returning it along |
| with the original value as a <a href="../../../../../org/apache/beam/sdk/values/KV.html" title="class in org.apache.beam.sdk.values"><code>KV</code></a>.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.summary"> |
| <!-- --> |
| </a> |
| <h3>Constructor Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colOne" scope="col">Constructor and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.html#WithFailures--">WithFailures</a></span>()</code> </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.Object</h3> |
| <code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.detail"> |
| <!-- --> |
| </a> |
| <h3>Constructor Detail</h3> |
| <a name="WithFailures--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>WithFailures</h4> |
| <pre>public WithFailures()</pre> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </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/Watch.WatchGrowthFn.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/WithFailures.html" target="_top">Frames</a></li> |
| <li><a href="WithFailures.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../../allclasses-noframe.html">All 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: </li> |
| <li><a href="#nested.class.summary">Nested</a> | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#methods.inherited.from.class.java.lang.Object">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li>Method</li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |