| <!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>SourceTestUtils (Apache Beam 2.38.0-SNAPSHOT)</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="SourceTestUtils (Apache Beam 2.38.0-SNAPSHOT)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9}; |
| var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| </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/testing/SerializableMatchers.SerializableSupplier.html" title="interface in org.apache.beam.sdk.testing"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.ExpectedSplitOutcome.html" title="enum in org.apache.beam.sdk.testing"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/beam/sdk/testing/SourceTestUtils.html" target="_top">Frames</a></li> |
| <li><a href="SourceTestUtils.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="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></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.testing</div> |
| <h2 title="Class SourceTestUtils" class="title">Class SourceTestUtils</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li>java.lang.Object</li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.beam.sdk.testing.SourceTestUtils</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>public class <span class="typeNameLabel">SourceTestUtils</span> |
| extends java.lang.Object</pre> |
| <div class="block">Helper functions and test harnesses for checking correctness of <a href="../../../../../org/apache/beam/sdk/io/Source.html" title="class in org.apache.beam.sdk.io"><code>Source</code></a> implementations. |
| |
| <p>Contains a few lightweight utilities (e.g. reading items from a source or a reader, such as |
| <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readFromSource-org.apache.beam.sdk.io.BoundedSource-org.apache.beam.sdk.options.PipelineOptions-"><code>readFromSource(org.apache.beam.sdk.io.BoundedSource<T>, org.apache.beam.sdk.options.PipelineOptions)</code></a> and <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readFromUnstartedReader-org.apache.beam.sdk.io.Source.Reader-"><code>readFromUnstartedReader(org.apache.beam.sdk.io.Source.Reader<T>)</code></a>), as well as heavyweight property |
| testing and stress testing harnesses that help getting a large amount of test coverage with few |
| code. Most notable ones are: |
| |
| <ul> |
| <li><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSourcesEqualReferenceSource-org.apache.beam.sdk.io.BoundedSource-java.util.List-org.apache.beam.sdk.options.PipelineOptions-"><code>assertSourcesEqualReferenceSource(org.apache.beam.sdk.io.BoundedSource<T>, java.util.List<? extends org.apache.beam.sdk.io.BoundedSource<T>>, org.apache.beam.sdk.options.PipelineOptions)</code></a> helps testing that the data read by the union of |
| sources produced by <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html#split-long-org.apache.beam.sdk.options.PipelineOptions-"><code>BoundedSource.split(long, org.apache.beam.sdk.options.PipelineOptions)</code></a> is the same as data read by the original |
| source. |
| <li>If your source implements dynamic work rebalancing, use the <code>assertSplitAtFraction</code> |
| family of functions - they test behavior of <code>BoundedSource.BoundedReader#splitAtFraction</code>, in particular, that various consistency |
| properties are respected and the total set of data read by the source is preserved when |
| splits happen. Use <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionBehavior-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.testing.SourceTestUtils.ExpectedSplitOutcome-org.apache.beam.sdk.options.PipelineOptions-"><code>assertSplitAtFractionBehavior(org.apache.beam.sdk.io.BoundedSource<T>, int, double, org.apache.beam.sdk.testing.SourceTestUtils.ExpectedSplitOutcome, org.apache.beam.sdk.options.PipelineOptions)</code></a> to test individual cases of |
| <code>splitAtFraction</code> and use <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionExhaustive-org.apache.beam.sdk.io.BoundedSource-org.apache.beam.sdk.options.PipelineOptions-"><code>assertSplitAtFractionExhaustive(org.apache.beam.sdk.io.BoundedSource<T>, org.apache.beam.sdk.options.PipelineOptions)</code></a> as a heavy-weight |
| stress test including concurrency. We strongly recommend to use both. |
| </ul> |
| |
| For example usages, see the unit tests of classes such as <code>AvroSource</code> or <code>TextSource</code>. |
| |
| <p>Like <a href="../../../../../org/apache/beam/sdk/testing/PAssert.html" title="class in org.apache.beam.sdk.testing"><code>PAssert</code></a>, requires JUnit and Hamcrest to be present in the classpath.</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/testing/SourceTestUtils.ExpectedSplitOutcome.html" title="enum in org.apache.beam.sdk.testing">SourceTestUtils.ExpectedSplitOutcome</a></span></code> |
| <div class="block">Expected outcome of <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>BoundedSource.BoundedReader.splitAtFraction(double)</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/testing/SourceTestUtils.html#SourceTestUtils--">SourceTestUtils</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> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code>static <T> void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSourcesEqualReferenceSource-org.apache.beam.sdk.io.BoundedSource-java.util.List-org.apache.beam.sdk.options.PipelineOptions-">assertSourcesEqualReferenceSource</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> referenceSource, |
| java.util.List<? extends <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T>> sources, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Given a reference <code>Source</code> and a list of <code>Source</code>s, assert that the union of the |
| records read from the list of sources is equal to the records read from the reference source.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code>static <T> org.apache.beam.sdk.testing.SourceTestUtils.SplitAtFractionResult</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionBehavior-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.testing.SourceTestUtils.ExpectedSplitOutcome-org.apache.beam.sdk.options.PipelineOptions-">assertSplitAtFractionBehavior</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| int numItemsToReadBeforeSplit, |
| double splitFraction, |
| <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.ExpectedSplitOutcome.html" title="enum in org.apache.beam.sdk.testing">SourceTestUtils.ExpectedSplitOutcome</a> expectedOutcome, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Asserts that the <code>source</code>'s reader either fails to <code>splitAtFraction(fraction)</code> |
| after reading <code>numItemsToReadBeforeSplit</code> items, or succeeds in a way that is consistent |
| according to <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionSucceedsAndConsistent-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.options.PipelineOptions-"><code>assertSplitAtFractionSucceedsAndConsistent(org.apache.beam.sdk.io.BoundedSource<T>, int, double, org.apache.beam.sdk.options.PipelineOptions)</code></a>.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>static <T> void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionExhaustive-org.apache.beam.sdk.io.BoundedSource-org.apache.beam.sdk.options.PipelineOptions-">assertSplitAtFractionExhaustive</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Asserts that for each possible start position, <code>BoundedSource.BoundedReader#splitAtFraction</code> at every interesting fraction (halfway between two |
| fractions that differ by at least one item) can be called successfully and the results are |
| consistent if a split succeeds.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code>static <T> void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionFails-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.options.PipelineOptions-">assertSplitAtFractionFails</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| int numItemsToReadBeforeSplit, |
| double splitFraction, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Asserts that the <code>source</code>'s reader fails to <code>splitAtFraction(fraction)</code> after |
| reading <code>numItemsToReadBeforeSplit</code> items.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code>static <T> void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionSucceedsAndConsistent-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.options.PipelineOptions-">assertSplitAtFractionSucceedsAndConsistent</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| int numItemsToReadBeforeSplit, |
| double splitFraction, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Verifies some consistency properties of <code>BoundedSource.BoundedReader#splitAtFraction</code> on |
| the given source.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code>static <T> void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertUnstartedReaderReadsSameAsItsSource-org.apache.beam.sdk.io.BoundedSource.BoundedReader-org.apache.beam.sdk.options.PipelineOptions-">assertUnstartedReaderReadsSameAsItsSource</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io">BoundedSource.BoundedReader</a><T> reader, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Assert that a <code>Reader</code> returns a <code>Source</code> that, when read from, produces the same |
| records as the reader.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code>static <T> java.util.List<org.apache.beam.sdk.testing.SourceTestUtils.ReadableStructuralValue<T>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#createStructuralValues-org.apache.beam.sdk.coders.Coder-java.util.List-">createStructuralValues</a></span>(<a href="../../../../../org/apache/beam/sdk/coders/Coder.html" title="class in org.apache.beam.sdk.coders">Coder</a><T> coder, |
| java.util.List<T> list)</code> |
| <div class="block">Testing utilities below depend on standard assertions and matchers to compare elements read by |
| sources.</div> |
| </td> |
| </tr> |
| <tr id="i7" class="rowColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readFromSource-org.apache.beam.sdk.io.BoundedSource-org.apache.beam.sdk.options.PipelineOptions-">readFromSource</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> |
| <div class="block">Reads all elements from the given <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource</code></a>.</div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readFromSplitsOfSource-org.apache.beam.sdk.io.BoundedSource-long-org.apache.beam.sdk.options.PipelineOptions-">readFromSplitsOfSource</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| long desiredBundleSizeBytes, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options)</code> </td> |
| </tr> |
| <tr id="i9" class="rowColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readFromStartedReader-org.apache.beam.sdk.io.Source.Reader-">readFromStartedReader</a></span>(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader)</code> |
| <div class="block">Reads all elements from the given started <code>Source.Reader</code>.</div> |
| </td> |
| </tr> |
| <tr id="i10" class="altColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readFromUnstartedReader-org.apache.beam.sdk.io.Source.Reader-">readFromUnstartedReader</a></span>(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader)</code> |
| <div class="block">Reads all elements from the given unstarted <code>Source.Reader</code>.</div> |
| </td> |
| </tr> |
| <tr id="i11" class="rowColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readNItemsFromStartedReader-org.apache.beam.sdk.io.Source.Reader-int-">readNItemsFromStartedReader</a></span>(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader, |
| int n)</code> |
| <div class="block">Read elements from a <code>Source.Reader</code> that has already had <code>Source.Reader#start</code> |
| called on it, until n elements are read.</div> |
| </td> |
| </tr> |
| <tr id="i12" class="altColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readNItemsFromUnstartedReader-org.apache.beam.sdk.io.Source.Reader-int-">readNItemsFromUnstartedReader</a></span>(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader, |
| int n)</code> |
| <div class="block">Read elements from a <code>Source.Reader</code> until n elements are read.</div> |
| </td> |
| </tr> |
| <tr id="i13" class="rowColor"> |
| <td class="colFirst"><code>static <T> java.util.List<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#readRemainingFromReader-org.apache.beam.sdk.io.Source.Reader-boolean-">readRemainingFromReader</a></span>(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader, |
| boolean started)</code> |
| <div class="block">Read all remaining elements from a <code>Source.Reader</code>.</div> |
| </td> |
| </tr> |
| <tr id="i14" class="altColor"> |
| <td class="colFirst"><code>static <T> <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#toUnsplittableSource-org.apache.beam.sdk.io.BoundedSource-">toUnsplittableSource</a></span>(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> boundedSource)</code> |
| <div class="block">Returns an equivalent unsplittable <code>BoundedSource<T></code>.</div> |
| </td> |
| </tr> |
| </table> |
| <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="SourceTestUtils--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>SourceTestUtils</h4> |
| <pre>public SourceTestUtils()</pre> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="createStructuralValues-org.apache.beam.sdk.coders.Coder-java.util.List-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>createStructuralValues</h4> |
| <pre>public static <T> java.util.List<org.apache.beam.sdk.testing.SourceTestUtils.ReadableStructuralValue<T>> createStructuralValues(<a href="../../../../../org/apache/beam/sdk/coders/Coder.html" title="class in org.apache.beam.sdk.coders">Coder</a><T> coder, |
| java.util.List<T> list) |
| throws java.lang.Exception</pre> |
| <div class="block">Testing utilities below depend on standard assertions and matchers to compare elements read by |
| sources. In general the elements may not implement <code>equals</code>/<code>hashCode</code> properly, |
| however every source has a <a href="../../../../../org/apache/beam/sdk/coders/Coder.html" title="class in org.apache.beam.sdk.coders"><code>Coder</code></a> and every <code>Coder</code> can produce a <a href="../../../../../org/apache/beam/sdk/coders/Coder.html#structuralValue-T-"><code>Coder.structuralValue(T)</code></a> whose <code>equals</code>/<code>hashCode</code> is consistent with equality of |
| encoded format. So we use this <a href="../../../../../org/apache/beam/sdk/coders/Coder.html#structuralValue-T-"><code>Coder.structuralValue(T)</code></a> to compare elements read by |
| sources.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readFromSource-org.apache.beam.sdk.io.BoundedSource-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readFromSource</h4> |
| <pre>public static <T> java.util.List<T> readFromSource(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.io.IOException</pre> |
| <div class="block">Reads all elements from the given <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource</code></a>.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readFromSplitsOfSource-org.apache.beam.sdk.io.BoundedSource-long-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readFromSplitsOfSource</h4> |
| <pre>public static <T> java.util.List<T> readFromSplitsOfSource(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| long desiredBundleSizeBytes, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readFromUnstartedReader-org.apache.beam.sdk.io.Source.Reader-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readFromUnstartedReader</h4> |
| <pre>public static <T> java.util.List<T> readFromUnstartedReader(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader) |
| throws java.io.IOException</pre> |
| <div class="block">Reads all elements from the given unstarted <code>Source.Reader</code>.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readFromStartedReader-org.apache.beam.sdk.io.Source.Reader-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readFromStartedReader</h4> |
| <pre>public static <T> java.util.List<T> readFromStartedReader(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader) |
| throws java.io.IOException</pre> |
| <div class="block">Reads all elements from the given started <code>Source.Reader</code>.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readNItemsFromUnstartedReader-org.apache.beam.sdk.io.Source.Reader-int-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readNItemsFromUnstartedReader</h4> |
| <pre>public static <T> java.util.List<T> readNItemsFromUnstartedReader(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader, |
| int n) |
| throws java.io.IOException</pre> |
| <div class="block">Read elements from a <code>Source.Reader</code> until n elements are read.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readNItemsFromStartedReader-org.apache.beam.sdk.io.Source.Reader-int-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readNItemsFromStartedReader</h4> |
| <pre>public static <T> java.util.List<T> readNItemsFromStartedReader(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader, |
| int n) |
| throws java.io.IOException</pre> |
| <div class="block">Read elements from a <code>Source.Reader</code> that has already had <code>Source.Reader#start</code> |
| called on it, until n elements are read.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readRemainingFromReader-org.apache.beam.sdk.io.Source.Reader-boolean-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readRemainingFromReader</h4> |
| <pre>public static <T> java.util.List<T> readRemainingFromReader(<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a><T> reader, |
| boolean started) |
| throws java.io.IOException</pre> |
| <div class="block">Read all remaining elements from a <code>Source.Reader</code>.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="assertSourcesEqualReferenceSource-org.apache.beam.sdk.io.BoundedSource-java.util.List-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>assertSourcesEqualReferenceSource</h4> |
| <pre>public static <T> void assertSourcesEqualReferenceSource(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> referenceSource, |
| java.util.List<? extends <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T>> sources, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <div class="block">Given a reference <code>Source</code> and a list of <code>Source</code>s, assert that the union of the |
| records read from the list of sources is equal to the records read from the reference source.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="assertUnstartedReaderReadsSameAsItsSource-org.apache.beam.sdk.io.BoundedSource.BoundedReader-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>assertUnstartedReaderReadsSameAsItsSource</h4> |
| <pre>public static <T> void assertUnstartedReaderReadsSameAsItsSource(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io">BoundedSource.BoundedReader</a><T> reader, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <div class="block">Assert that a <code>Reader</code> returns a <code>Source</code> that, when read from, produces the same |
| records as the reader.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="assertSplitAtFractionBehavior-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.testing.SourceTestUtils.ExpectedSplitOutcome-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>assertSplitAtFractionBehavior</h4> |
| <pre>public static <T> org.apache.beam.sdk.testing.SourceTestUtils.SplitAtFractionResult assertSplitAtFractionBehavior(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| int numItemsToReadBeforeSplit, |
| double splitFraction, |
| <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.ExpectedSplitOutcome.html" title="enum in org.apache.beam.sdk.testing">SourceTestUtils.ExpectedSplitOutcome</a> expectedOutcome, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <div class="block">Asserts that the <code>source</code>'s reader either fails to <code>splitAtFraction(fraction)</code> |
| after reading <code>numItemsToReadBeforeSplit</code> items, or succeeds in a way that is consistent |
| according to <a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.html#assertSplitAtFractionSucceedsAndConsistent-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.options.PipelineOptions-"><code>assertSplitAtFractionSucceedsAndConsistent(org.apache.beam.sdk.io.BoundedSource<T>, int, double, org.apache.beam.sdk.options.PipelineOptions)</code></a>. |
| |
| <p>Returns SplitAtFractionResult.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="assertSplitAtFractionSucceedsAndConsistent-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>assertSplitAtFractionSucceedsAndConsistent</h4> |
| <pre>public static <T> void assertSplitAtFractionSucceedsAndConsistent(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| int numItemsToReadBeforeSplit, |
| double splitFraction, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <div class="block">Verifies some consistency properties of <code>BoundedSource.BoundedReader#splitAtFraction</code> on |
| the given source. Equivalent to the following pseudocode: |
| |
| <pre> |
| Reader reader = source.createReader(); |
| read N items from reader; |
| Source residual = reader.splitAtFraction(splitFraction); |
| Source primary = reader.getCurrentSource(); |
| assert: items in primary == items we read so far |
| + items we'll get by continuing to read from reader; |
| assert: items in original source == items in primary + items in residual |
| </pre></div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="assertSplitAtFractionFails-org.apache.beam.sdk.io.BoundedSource-int-double-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>assertSplitAtFractionFails</h4> |
| <pre>public static <T> void assertSplitAtFractionFails(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| int numItemsToReadBeforeSplit, |
| double splitFraction, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <div class="block">Asserts that the <code>source</code>'s reader fails to <code>splitAtFraction(fraction)</code> after |
| reading <code>numItemsToReadBeforeSplit</code> items.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="assertSplitAtFractionExhaustive-org.apache.beam.sdk.io.BoundedSource-org.apache.beam.sdk.options.PipelineOptions-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>assertSplitAtFractionExhaustive</h4> |
| <pre>public static <T> void assertSplitAtFractionExhaustive(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> source, |
| <a href="../../../../../org/apache/beam/sdk/options/PipelineOptions.html" title="interface in org.apache.beam.sdk.options">PipelineOptions</a> options) |
| throws java.lang.Exception</pre> |
| <div class="block">Asserts that for each possible start position, <code>BoundedSource.BoundedReader#splitAtFraction</code> at every interesting fraction (halfway between two |
| fractions that differ by at least one item) can be called successfully and the results are |
| consistent if a split succeeds. Verifies multithreaded splitting as well.</div> |
| <dl> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.lang.Exception</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="toUnsplittableSource-org.apache.beam.sdk.io.BoundedSource-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>toUnsplittableSource</h4> |
| <pre>public static <T> <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> toUnsplittableSource(<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a><T> boundedSource)</pre> |
| <div class="block">Returns an equivalent unsplittable <code>BoundedSource<T></code>. |
| |
| <p>It forwards most methods to the given <code>boundedSource</code>, except: |
| |
| <ol> |
| <li><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html#split-long-org.apache.beam.sdk.options.PipelineOptions-"><code>BoundedSource.split(long, org.apache.beam.sdk.options.PipelineOptions)</code></a> rejects initial splitting by returning itself in a list. |
| <li><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>BoundedSource.BoundedReader.splitAtFraction(double)</code></a> rejects dynamic splitting by returning null. |
| </ol></div> |
| </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/testing/SerializableMatchers.SerializableSupplier.html" title="interface in org.apache.beam.sdk.testing"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/beam/sdk/testing/SourceTestUtils.ExpectedSplitOutcome.html" title="enum in org.apache.beam.sdk.testing"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/beam/sdk/testing/SourceTestUtils.html" target="_top">Frames</a></li> |
| <li><a href="SourceTestUtils.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="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |