blob: 5bf4a5b6ed7c8e03cf0719c09157762cfe281bfd [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 Mon Jan 27 16:42:32 PST 2020 -->
<title>BoundedSource.BoundedReader (Apache Beam 2.20.0-SNAPSHOT)</title>
<meta name="date" content="2020-01-27">
<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="BoundedSource.BoundedReader (Apache Beam 2.20.0-SNAPSHOT)";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract 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/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/io/CompressedSource.html" title="class in org.apache.beam.sdk.io"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" target="_top">Frames</a></li>
<li><a href="BoundedSource.BoundedReader.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>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</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.io</div>
<h2 title="Class BoundedSource.BoundedReader" class="title">Class BoundedSource.BoundedReader&lt;T&gt;</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">org.apache.beam.sdk.io.Source.Reader</a>&lt;T&gt;</li>
<li>
<ul class="inheritance">
<li>org.apache.beam.sdk.io.BoundedSource.BoundedReader&lt;T&gt;</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>java.lang.AutoCloseable</dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../../../org/apache/beam/sdk/io/gcp/bigquery/BigQueryStorageStreamSource.BigQueryStorageStreamReader.html" title="class in org.apache.beam.sdk.io.gcp.bigquery">BigQueryStorageStreamSource.BigQueryStorageStreamReader</a>, <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html" title="class in org.apache.beam.sdk.io">OffsetBasedSource.OffsetBasedReader</a></dd>
</dl>
<dl>
<dt>Enclosing class:</dt>
<dd><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="type parameter in BoundedSource">T</a>&gt;</dd>
</dl>
<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#SOURCE_SINK">SOURCE_SINK</a>)
public abstract static class <span class="typeNameLabel">BoundedSource.BoundedReader&lt;T&gt;</span>
extends <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a>&lt;T&gt;</pre>
<div class="block">A <code>Reader</code> that reads a bounded amount of input and supports some additional operations,
such as progress estimation and dynamic work rebalancing.
<h3>Boundedness</h3>
<p>Once <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> has returned false, neither will be called again on
this object.
<h3>Thread safety</h3>
<p>All methods will be run from the same thread except <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a>, <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getFractionConsumed--"><code>getFractionConsumed()</code></a>, <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>, <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>getSplitPointsConsumed()</code></a>, and <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--"><code>getSplitPointsRemaining()</code></a>, all of which can be called concurrently from a different thread.
There will not be multiple concurrent calls to <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a>.
<p>It must be safe to call <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a>, <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getFractionConsumed--"><code>getFractionConsumed()</code></a>, <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>, <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>getSplitPointsConsumed()</code></a>, and <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--"><code>getSplitPointsRemaining()</code></a>
concurrently with other methods.
<p>Additionally, a successful <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a> call must, by definition, cause <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a> to start returning a different value. Callers of <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>
need to be aware of the possibility that the returned value can change at any time, and must
only access the properties of the source returned by <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a> which do not
change between <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a> calls.
<h3>Implementing <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a></h3>
<p>In the course of dynamic work rebalancing, the method <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a> may be called
concurrently with <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a>. It is critical that their interaction is
implemented in a thread-safe way, otherwise data loss is possible.
<p>Sources which support dynamic work rebalancing should use <a href="../../../../../org/apache/beam/sdk/io/range/RangeTracker.html" title="interface in org.apache.beam.sdk.io.range"><code>RangeTracker</code></a> to manage the (source-specific) range of positions
that is being split.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#SPLIT_POINTS_UNKNOWN">SPLIT_POINTS_UNKNOWN</a></span></code>
<div class="block">A constant to use as the return value for <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>getSplitPointsConsumed()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--"><code>getSplitPointsRemaining()</code></a> when the exact value is unknown.</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">&nbsp;</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/io/BoundedSource.BoundedReader.html#BoundedReader--">BoundedReader</a></span>()</code>&nbsp;</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">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</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>abstract <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="type parameter in BoundedSource.BoundedReader">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--">getCurrentSource</a></span>()</code>
<div class="block">Returns a <code>Source</code> describing the same input that this <code>Reader</code> currently reads
(including items already read).</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="https://static.javadoc.io/joda-time/joda-time/2.10.3/org/joda/time/Instant.html?is-external=true" title="class or interface in org.joda.time">Instant</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentTimestamp--">getCurrentTimestamp</a></span>()</code>
<div class="block">By default, returns the minimum possible timestamp.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>java.lang.Double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getFractionConsumed--">getFractionConsumed</a></span>()</code>
<div class="block">Returns a value in [0, 1] representing approximately what fraction of the <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>current source</code></a> this reader has read so far, or <code>null</code> if such an
estimate is not available.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--">getSplitPointsConsumed</a></span>()</code>
<div class="block">Returns the total amount of parallelism in the consumed (returned and processed) range of
this reader's current <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource</code></a> (as would be returned by <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>).</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--">getSplitPointsRemaining</a></span>()</code>
<div class="block">Returns the total amount of parallelism in the unprocessed part of this reader's current
<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource</code></a> (as would be returned by <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>).</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="type parameter in BoundedSource.BoundedReader">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-">splitAtFraction</a></span>(double&nbsp;fraction)</code>
<div class="block">Tells the reader to narrow the range of the input it's going to read and give up the
remainder, so that the new range would contain approximately the given fraction of the amount
of data in the current range.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.org.apache.beam.sdk.io.Source.Reader">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.beam.sdk.io.<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a></h3>
<code><a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--">advance</a>, <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#close--">close</a>, <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#getCurrent--">getCurrent</a>, <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--">start</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;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">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="SPLIT_POINTS_UNKNOWN">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>SPLIT_POINTS_UNKNOWN</h4>
<pre>public static final&nbsp;long SPLIT_POINTS_UNKNOWN</pre>
<div class="block">A constant to use as the return value for <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>getSplitPointsConsumed()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--"><code>getSplitPointsRemaining()</code></a> when the exact value is unknown.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../constant-values.html#org.apache.beam.sdk.io.BoundedSource.BoundedReader.SPLIT_POINTS_UNKNOWN">Constant Field Values</a></dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="BoundedReader--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>BoundedReader</h4>
<pre>public&nbsp;BoundedReader()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getFractionConsumed--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getFractionConsumed</h4>
<pre><a href="https://static.javadoc.io/com.google.code.findbugs/jsr305/3.0.2/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</a>
public&nbsp;java.lang.Double&nbsp;getFractionConsumed()</pre>
<div class="block">Returns a value in [0, 1] representing approximately what fraction of the <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>current source</code></a> this reader has read so far, or <code>null</code> if such an
estimate is not available.
<p>It is recommended that this method should satisfy the following properties:
<ul>
<li>Should return 0 before the <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> call.
<li>Should return 1 after a <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> call that returns false.
<li>The returned values should be non-decreasing (though they don't have to be unique).
</ul>
<p>By default, returns null to indicate that this cannot be estimated.
<h3>Thread safety</h3>
If <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a> is implemented, this method can be called concurrently to other
methods (including itself), and it is therefore critical for it to be implemented in a
thread-safe way.</div>
</li>
</ul>
<a name="getSplitPointsConsumed--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSplitPointsConsumed</h4>
<pre>public&nbsp;long&nbsp;getSplitPointsConsumed()</pre>
<div class="block">Returns the total amount of parallelism in the consumed (returned and processed) range of
this reader's current <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource</code></a> (as would be returned by <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>). This corresponds to all split point records (see <a href="../../../../../org/apache/beam/sdk/io/range/RangeTracker.html" title="interface in org.apache.beam.sdk.io.range"><code>RangeTracker</code></a>)
returned by this reader, <em>excluding</em> the last split point returned if the reader is
not finished.
<p>Consider the following examples: (1) An input that can be read in parallel down to the
individual records, such as <a href="../../../../../org/apache/beam/sdk/io/CountingSource.html#upTo-long-"><code>CountingSource.upTo(long)</code></a>, is called "perfectly splittable".
(2) a "block-compressed" file format such as <a href="../../../../../org/apache/beam/sdk/io/AvroIO.html" title="class in org.apache.beam.sdk.io"><code>AvroIO</code></a>, in which a block of records has
to be read as a whole, but different blocks can be read in parallel. (3) An "unsplittable"
input such as a cursor in a database.
<ul>
<li>Any <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io"><code>reader</code></a> that is unstarted (aka, has never had a call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a>) has a consumed parallelism of 0. This condition holds independent of whether
the input is splittable.
<li>Any <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io"><code>reader</code></a> that has only returned its first element (aka, has
never had a call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a>) has a consumed parallelism of 0: the first
element is the current element and is still being processed. This condition holds
independent of whether the input is splittable.
<li>For an empty reader (in which the call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> returned false), the consumed
parallelism is 0. This condition holds independent of whether the input is splittable.
<li>For a non-empty, finished reader (in which the call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> returned true and
a call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> has returned false), the value returned must be at least 1
and should equal the total parallelism in the source.
<li>For example (1): After returning record #30 (starting at 1) out of 50 in a perfectly
splittable 50-record input, this value should be 29. When finished, the consumed
parallelism should be 50.
<li>For example (2): In a block-compressed value consisting of 5 blocks, the value should
stay at 0 until the first record of the second block is returned; stay at 1 until the
first record of the third block is returned, etc. Only once the end-of-file is reached
then the fifth block has been consumed and the value should stay at 5.
<li>For example (3): For any non-empty unsplittable input, the consumed parallelism is 0
until the reader is finished (because the last call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> returned false,
at which point it becomes 1.
</ul>
<p>A reader that is implemented using a <a href="../../../../../org/apache/beam/sdk/io/range/RangeTracker.html" title="interface in org.apache.beam.sdk.io.range"><code>RangeTracker</code></a> is encouraged to use the range
tracker's ability to count split points to implement this method. See <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html" title="class in org.apache.beam.sdk.io"><code>OffsetBasedSource.OffsetBasedReader</code></a> and <a href="../../../../../org/apache/beam/sdk/io/range/OffsetRangeTracker.html" title="class in org.apache.beam.sdk.io.range"><code>OffsetRangeTracker</code></a> for an example.
<p>Defaults to <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#SPLIT_POINTS_UNKNOWN"><code>SPLIT_POINTS_UNKNOWN</code></a>. Any value less than 0 will be interpreted as
unknown.
<h3>Thread safety</h3>
See the javadoc on <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource.BoundedReader</code></a> for information about thread safety.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--"><code>getSplitPointsRemaining()</code></a></dd>
</dl>
</li>
</ul>
<a name="getSplitPointsRemaining--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSplitPointsRemaining</h4>
<pre>public&nbsp;long&nbsp;getSplitPointsRemaining()</pre>
<div class="block">Returns the total amount of parallelism in the unprocessed part of this reader's current
<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource</code></a> (as would be returned by <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>). This corresponds
to all unprocessed split point records (see <a href="../../../../../org/apache/beam/sdk/io/range/RangeTracker.html" title="interface in org.apache.beam.sdk.io.range"><code>RangeTracker</code></a>), including the last split
point returned, in the remainder part of the source.
<p>This function should be implemented only <strong>in addition to <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>getSplitPointsConsumed()</code></a></strong> and only if <em>an exact value can be returned</em>.
<p>Consider the following examples: (1) An input that can be read in parallel down to the
individual records, such as <a href="../../../../../org/apache/beam/sdk/io/CountingSource.html#upTo-long-"><code>CountingSource.upTo(long)</code></a>, is called "perfectly splittable".
(2) a "block-compressed" file format such as <a href="../../../../../org/apache/beam/sdk/io/AvroIO.html" title="class in org.apache.beam.sdk.io"><code>AvroIO</code></a>, in which a block of records has
to be read as a whole, but different blocks can be read in parallel. (3) An "unsplittable"
input such as a cursor in a database.
<p>Assume for examples (1) and (2) that the number of records or blocks remaining is known:
<ul>
<li>Any <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io"><code>reader</code></a> for which the last call to <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> has returned true should should not return 0, because this reader itself
represents parallelism at least 1. This condition holds independent of whether the
input is splittable.
<li>A finished reader (for which <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a>) has returned false
should return a value of 0. This condition holds independent of whether the input is
splittable.
<li>For example 1: After returning record #30 (starting at 1) out of 50 in a perfectly
splittable 50-record input, this value should be 21 (20 remaining + 1 current) if the
total number of records is known.
<li>For example 2: After returning a record in block 3 in a block-compressed file
consisting of 5 blocks, this value should be 3 (since blocks 4 and 5 can be processed
in parallel by new readers produced via dynamic work rebalancing, while the current
reader continues processing block 3) if the total number of blocks is known.
<li>For example (3): a reader for any non-empty unsplittable input, should return 1 until
it is finished, at which point it should return 0.
<li>For any reader: After returning the last split point in a file (e.g., the last record
in example (1), the first record in the last block for example (2), or the first record
in the file for example (3), this value should be 1: apart from the current task, no
additional remainder can be split off.
</ul>
<p>Defaults to <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#SPLIT_POINTS_UNKNOWN"><code>SPLIT_POINTS_UNKNOWN</code></a>. Any value less than 0 will be interpreted as
unknown.
<h3>Thread safety</h3>
See the javadoc on <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource.BoundedReader</code></a> for information about thread safety.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>getSplitPointsConsumed()</code></a></dd>
</dl>
</li>
</ul>
<a name="getCurrentSource--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCurrentSource</h4>
<pre>public abstract&nbsp;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="type parameter in BoundedSource.BoundedReader">T</a>&gt;&nbsp;getCurrentSource()</pre>
<div class="block">Returns a <code>Source</code> describing the same input that this <code>Reader</code> currently reads
(including items already read).
<h3>Usage</h3>
<p>Reader subclasses can use this method for convenience to access unchanging properties of
the source being read. Alternatively, they can cache these properties in the constructor.
<p>The framework will call this method in the course of dynamic work rebalancing, e.g. after
a successful <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a> call.
<h3>Mutability and thread safety</h3>
<p>Remember that <a href="../../../../../org/apache/beam/sdk/io/Source.html" title="class in org.apache.beam.sdk.io"><code>Source</code></a> objects must always be immutable. However, the return value
of this function may be affected by dynamic work rebalancing, happening asynchronously via
<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#splitAtFraction-double-"><code>splitAtFraction(double)</code></a>, meaning it can return a different <a href="../../../../../org/apache/beam/sdk/io/Source.html" title="class in org.apache.beam.sdk.io"><code>Source</code></a> object. However, the returned object itself will still itself be immutable. Callers
must take care not to rely on properties of the returned source that may be asynchronously
changed as a result of this process (e.g. do not cache an end offset when reading a file).
<h3>Implementation</h3>
<p>For convenience, subclasses should usually return the most concrete subclass of <a href="../../../../../org/apache/beam/sdk/io/Source.html" title="class in org.apache.beam.sdk.io"><code>Source</code></a> possible. In practice, the implementation of this method should nearly always be one
of the following:
<ul>
<li>Source that inherits from a base class that already implements <a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--"><code>getCurrentSource()</code></a>: delegate to base class. In this case, it is almost always an error
for the subclass to maintain its own copy of the source.
<pre><code>
public FooReader(FooSource&lt;T&gt; source) {
super(source);
}
public FooSource&lt;T&gt; getCurrentSource() {
return (FooSource&lt;T&gt;)super.getCurrentSource();
}
</code></pre>
<li>Source that does not support dynamic work rebalancing: return a private final variable.
<pre><code>
private final FooSource&lt;T&gt; source;
public FooReader(FooSource&lt;T&gt; source) {
this.source = source;
}
public FooSource&lt;T&gt; getCurrentSource() {
return source;
}
</code></pre>
<li><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io"><code>BoundedSource.BoundedReader</code></a> that explicitly supports dynamic work rebalancing:
maintain a variable pointing to an immutable source object, and protect it with
synchronization.
<pre><code>
private FooSource&lt;T&gt; source;
public FooReader(FooSource&lt;T&gt; source) {
this.source = source;
}
public synchronized FooSource&lt;T&gt; getCurrentSource() {
return source;
}
public synchronized FooSource&lt;T&gt; splitAtFraction(double fraction) {
...
FooSource&lt;T&gt; primary = ...;
FooSource&lt;T&gt; residual = ...;
this.source = primary;
return residual;
}
</code></pre>
</ul></div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#getCurrentSource--">getCurrentSource</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="type parameter in BoundedSource.BoundedReader">T</a>&gt;</code></dd>
</dl>
</li>
</ul>
<a name="splitAtFraction-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>splitAtFraction</h4>
<pre><a href="https://static.javadoc.io/com.google.code.findbugs/jsr305/3.0.2/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</a>
public&nbsp;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.html" title="class in org.apache.beam.sdk.io">BoundedSource</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="type parameter in BoundedSource.BoundedReader">T</a>&gt;&nbsp;splitAtFraction(double&nbsp;fraction)</pre>
<div class="block">Tells the reader to narrow the range of the input it's going to read and give up the
remainder, so that the new range would contain approximately the given fraction of the amount
of data in the current range.
<p>Returns a <code>BoundedSource</code> representing the remainder.
<h3>Detailed description</h3>
Assuming the following sequence of calls:
<pre><code>
BoundedSource&lt;T&gt; initial = reader.getCurrentSource();
BoundedSource&lt;T&gt; residual = reader.splitAtFraction(fraction);
BoundedSource&lt;T&gt; primary = reader.getCurrentSource();
</code></pre>
<ul>
<li>The "primary" and "residual" sources, when read, should together cover the same set of
records as "initial".
<li>The current reader should continue to be in a valid state, and continuing to read from
it should, together with the records it already read, yield the same records as would
have been read by "primary".
<li>The amount of data read by "primary" should ideally represent approximately the given
fraction of the amount of data read by "initial".
</ul>
For example, a reader that reads a range of offsets <i>[A, B)</i> in a file might implement
this method by truncating the current range to <i>[A, A + fraction*(B-A))</i> and returning a
Source representing the range <i>[A + fraction*(B-A), B)</i>.
<p>This method should return <code>null</code> if the split cannot be performed for this fraction
while satisfying the semantics above. E.g., a reader that reads a range of offsets in a file
should return <code>null</code> if it is already past the position in its range corresponding to
the given fraction. In this case, the method MUST have no effect (the reader must behave as
if the method hadn't been called at all).
<h3>Statefulness</h3>
Since this method (if successful) affects the reader's source, in subsequent invocations
"fraction" should be interpreted relative to the new current source.
<h3>Thread safety and blocking</h3>
This method will be called concurrently to other methods (however there will not be multiple
concurrent invocations of this method itself), and it is critical for it to be implemented in
a thread-safe way (otherwise data loss is possible).
<p>It is also very important that this method always completes quickly. In particular, it
should not perform or wait on any blocking operations such as I/O, RPCs etc. Violating this
requirement may stall completion of the work item or even cause it to fail.
<p>It is incorrect to make both this method and <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a>/<a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> <code>synchronized</code>, because those methods can perform blocking operations, and then this method
would have to wait for those calls to complete.
<p><a href="../../../../../org/apache/beam/sdk/io/range/RangeTracker.html" title="interface in org.apache.beam.sdk.io.range"><code>RangeTracker</code></a> makes it easy to implement this method
safely and correctly.
<p>By default, returns null to indicate that splitting is not possible.</div>
</li>
</ul>
<a name="getCurrentTimestamp--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getCurrentTimestamp</h4>
<pre>public&nbsp;<a href="https://static.javadoc.io/joda-time/joda-time/2.10.3/org/joda/time/Instant.html?is-external=true" title="class or interface in org.joda.time">Instant</a>&nbsp;getCurrentTimestamp()
throws java.util.NoSuchElementException</pre>
<div class="block">By default, returns the minimum possible timestamp.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#getCurrentTimestamp--">getCurrentTimestamp</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html" title="class in org.apache.beam.sdk.io">Source.Reader</a>&lt;<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="type parameter in BoundedSource.BoundedReader">T</a>&gt;</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.util.NoSuchElementException</code> - if the reader is at the beginning of the input and <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> wasn't called, or if the last <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#start--"><code>Source.Reader.start()</code></a> or <a href="../../../../../org/apache/beam/sdk/io/Source.Reader.html#advance--"><code>Source.Reader.advance()</code></a> returned <code>false</code>.</dd>
</dl>
</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/io/BoundedSource.html" title="class in org.apache.beam.sdk.io"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/io/CompressedSource.html" title="class in org.apache.beam.sdk.io"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" target="_top">Frames</a></li>
<li><a href="BoundedSource.BoundedReader.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>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>