| <!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>AvroSource.AvroReader (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="AvroSource.AvroReader (Apache Beam 2.38.0-SNAPSHOT)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance 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/AvroSource.html" title="class in org.apache.beam.sdk.io"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/beam/sdk/io/AvroSource.DatumReaderFactory.html" title="interface in org.apache.beam.sdk.io"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/beam/sdk/io/AvroSource.AvroReader.html" target="_top">Frames</a></li> |
| <li><a href="AvroSource.AvroReader.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>Nested | </li> |
| <li><a href="#fields.inherited.from.class.org.apache.beam.sdk.io.BoundedSource.BoundedReader">Field</a> | </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.io</div> |
| <h2 title="Class AvroSource.AvroReader" class="title">Class AvroSource.AvroReader<T></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><T></li> |
| <li> |
| <ul class="inheritance"> |
| <li><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io">org.apache.beam.sdk.io.BoundedSource.BoundedReader</a><T></li> |
| <li> |
| <ul class="inheritance"> |
| <li><a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html" title="class in org.apache.beam.sdk.io">org.apache.beam.sdk.io.OffsetBasedSource.OffsetBasedReader</a><T></li> |
| <li> |
| <ul class="inheritance"> |
| <li><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html" title="class in org.apache.beam.sdk.io">org.apache.beam.sdk.io.FileBasedSource.FileBasedReader</a><T></li> |
| <li> |
| <ul class="inheritance"> |
| <li><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">org.apache.beam.sdk.io.BlockBasedSource.BlockBasedReader</a><T></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.beam.sdk.io.AvroSource.AvroReader<T></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - The type of records contained in the block.</dd> |
| </dl> |
| <dl> |
| <dt>All Implemented Interfaces:</dt> |
| <dd>java.lang.AutoCloseable</dd> |
| </dl> |
| <dl> |
| <dt>Enclosing class:</dt> |
| <dd><a href="../../../../../org/apache/beam/sdk/io/AvroSource.html" title="class in org.apache.beam.sdk.io">AvroSource</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.html" title="type parameter in AvroSource">T</a>></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 static class <span class="typeNameLabel">AvroSource.AvroReader<T></span> |
| extends <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">BlockBasedSource.BlockBasedReader</a><T></pre> |
| <div class="block">A <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io"><code>BlockBasedSource.BlockBasedReader</code></a> for reading blocks from Avro files. |
| |
| <p>An Avro Object Container File consists of a header followed by a 16-bit sync marker and then |
| a sequence of blocks, where each block begins with two encoded longs representing the total |
| number of records in the block and the block's size in bytes, followed by the block's |
| (optionally-encoded) records. Each block is terminated by a 16-bit sync marker.</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> |
| <ul class="blockList"> |
| <li class="blockList"><a name="fields.inherited.from.class.org.apache.beam.sdk.io.BoundedSource.BoundedReader"> |
| <!-- --> |
| </a> |
| <h3>Fields inherited from class org.apache.beam.sdk.io.<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io">BoundedSource.BoundedReader</a></h3> |
| <code><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#SPLIT_POINTS_UNKNOWN">SPLIT_POINTS_UNKNOWN</a></code></li> |
| </ul> |
| </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/io/AvroSource.AvroReader.html#AvroReader-org.apache.beam.sdk.io.AvroSource-">AvroReader</a></span>(<a href="../../../../../org/apache/beam/sdk/io/AvroSource.html" title="class in org.apache.beam.sdk.io">AvroSource</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>> source)</code> |
| <div class="block">Reads Avro records of type <code>T</code> from the specified source.</div> |
| </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="t2" class="tableTab"><span><a href="javascript:show(2);">Instance 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>org.apache.beam.sdk.io.AvroSource.AvroBlock<<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html#getCurrentBlock--">getCurrentBlock</a></span>()</code> |
| <div class="block">Returns the current block (the block that was read by the last successful call to <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#readNextBlock--"><code>BlockBasedSource.BlockBasedReader.readNextBlock()</code></a>).</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code>long</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html#getCurrentBlockOffset--">getCurrentBlockOffset</a></span>()</code> |
| <div class="block">Returns the largest offset such that starting to read from that offset includes the current |
| block.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>long</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html#getCurrentBlockSize--">getCurrentBlockSize</a></span>()</code> |
| <div class="block">Returns the size of the current block in bytes as it is represented in the underlying file, |
| if possible.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../../org/apache/beam/sdk/io/AvroSource.html" title="class in org.apache.beam.sdk.io">AvroSource</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.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="i4" class="altColor"> |
| <td class="colFirst"><code>long</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.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>BoundedSource.BoundedReader.getCurrentSource()</code></a>).</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html#readNextBlock--">readNextBlock</a></span>()</code> |
| <div class="block">Read the next block from the input.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code>protected void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html#startReading-java.nio.channels.ReadableByteChannel-">startReading</a></span>(java.nio.channels.ReadableByteChannel channel)</code> |
| <div class="block">Performs any initialization of the subclass of <code>FileBasedReader</code> that involves IO |
| operations.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.org.apache.beam.sdk.io.BlockBasedSource.BlockBasedReader"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class org.apache.beam.sdk.io.<a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">BlockBasedSource.BlockBasedReader</a></h3> |
| <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrent--">getCurrent</a>, <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentOffset--">getCurrentOffset</a>, <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getFractionConsumed--">getFractionConsumed</a>, <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#isAtSplitPoint--">isAtSplitPoint</a>, <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#readNextRecord--">readNextRecord</a></code></li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.org.apache.beam.sdk.io.FileBasedSource.FileBasedReader"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class org.apache.beam.sdk.io.<a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html" title="class in org.apache.beam.sdk.io">FileBasedSource.FileBasedReader</a></h3> |
| <code><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#advanceImpl--">advanceImpl</a>, <a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#allowsDynamicSplitting--">allowsDynamicSplitting</a>, <a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#close--">close</a>, <a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#startImpl--">startImpl</a></code></li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.org.apache.beam.sdk.io.OffsetBasedSource.OffsetBasedReader"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class org.apache.beam.sdk.io.<a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html" title="class in org.apache.beam.sdk.io">OffsetBasedSource.OffsetBasedReader</a></h3> |
| <code><a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#advance--">advance</a>, <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#getSplitPointsConsumed--">getSplitPointsConsumed</a>, <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#isDone--">isDone</a>, <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#isStarted--">isStarted</a>, <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#splitAtFraction-double-">splitAtFraction</a>, <a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#start--">start</a></code></li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.org.apache.beam.sdk.io.BoundedSource.BoundedReader"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class org.apache.beam.sdk.io.<a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html" title="class in org.apache.beam.sdk.io">BoundedSource.BoundedReader</a></h3> |
| <code><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentTimestamp--">getCurrentTimestamp</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 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="AvroReader-org.apache.beam.sdk.io.AvroSource-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>AvroReader</h4> |
| <pre>public AvroReader(<a href="../../../../../org/apache/beam/sdk/io/AvroSource.html" title="class in org.apache.beam.sdk.io">AvroSource</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>> source)</pre> |
| <div class="block">Reads Avro records of type <code>T</code> from the specified source.</div> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="getCurrentSource--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getCurrentSource</h4> |
| <pre>public <a href="../../../../../org/apache/beam/sdk/io/AvroSource.html" title="class in org.apache.beam.sdk.io">AvroSource</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>> getCurrentSource()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getCurrentSource--">BoundedSource.BoundedReader</a></code></span></div> |
| <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>BoundedSource.BoundedReader.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>BoundedSource.BoundedReader.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>BoundedSource.BoundedReader.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<T> source) { |
| super(source); |
| } |
| |
| public FooSource<T> getCurrentSource() { |
| return (FooSource<T>)super.getCurrentSource(); |
| } |
| </code></pre> |
| <li>Source that does not support dynamic work rebalancing: return a private final variable. |
| <pre><code> |
| private final FooSource<T> source; |
| |
| public FooReader(FooSource<T> source) { |
| this.source = source; |
| } |
| |
| public FooSource<T> 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<T> source; |
| |
| public FooReader(FooSource<T> source) { |
| this.source = source; |
| } |
| |
| public synchronized FooSource<T> getCurrentSource() { |
| return source; |
| } |
| |
| public synchronized FooSource<T> splitAtFraction(double fraction) { |
| ... |
| FooSource<T> primary = ...; |
| FooSource<T> residual = ...; |
| this.source = primary; |
| return residual; |
| } |
| </code></pre> |
| </ul></div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Overrides:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#getCurrentSource--">getCurrentSource</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html" title="class in org.apache.beam.sdk.io">FileBasedSource.FileBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readNextBlock--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readNextBlock</h4> |
| <pre>public boolean readNextBlock() |
| throws java.io.IOException</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#readNextBlock--">BlockBasedSource.BlockBasedReader</a></code></span></div> |
| <div class="block">Read the next block from the input.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#readNextBlock--">readNextBlock</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">BlockBasedSource.BlockBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getCurrentBlock--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getCurrentBlock</h4> |
| <pre>public org.apache.beam.sdk.io.AvroSource.AvroBlock<<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>> getCurrentBlock()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentBlock--">BlockBasedSource.BlockBasedReader</a></code></span></div> |
| <div class="block">Returns the current block (the block that was read by the last successful call to <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#readNextBlock--"><code>BlockBasedSource.BlockBasedReader.readNextBlock()</code></a>). May return null initially, or if no block has been |
| successfully read.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentBlock--">getCurrentBlock</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">BlockBasedSource.BlockBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getCurrentBlockOffset--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getCurrentBlockOffset</h4> |
| <pre>public long getCurrentBlockOffset()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentBlockOffset--">BlockBasedSource.BlockBasedReader</a></code></span></div> |
| <div class="block">Returns the largest offset such that starting to read from that offset includes the current |
| block.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentBlockOffset--">getCurrentBlockOffset</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">BlockBasedSource.BlockBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getCurrentBlockSize--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getCurrentBlockSize</h4> |
| <pre>public long getCurrentBlockSize()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentBlockSize--">BlockBasedSource.BlockBasedReader</a></code></span></div> |
| <div class="block">Returns the size of the current block in bytes as it is represented in the underlying file, |
| if possible. This method may return <code>0</code> if the size of the current block is unknown. |
| |
| <p>The size returned by this method must be such that for two successive blocks A and B, |
| <code>offset(A) + size(A) <= offset(B)</code>. If this is not satisfied, the progress reported by |
| the <code>BlockBasedReader</code> will be non-monotonic and will interfere with the quality (but |
| not correctness) of dynamic work rebalancing. |
| |
| <p>This method and <a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.Block.html#getFractionOfBlockConsumed--"><code>BlockBasedSource.Block.getFractionOfBlockConsumed()</code></a> are used to provide an estimate |
| of progress within a block (<code>getCurrentBlock().getFractionOfBlockConsumed() * |
| getCurrentBlockSize()</code>). It is acceptable for the result of this computation to be <code>0</code>, |
| but progress estimation will be inaccurate.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html#getCurrentBlockSize--">getCurrentBlockSize</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/BlockBasedSource.BlockBasedReader.html" title="class in org.apache.beam.sdk.io">BlockBasedSource.BlockBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getSplitPointsRemaining--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getSplitPointsRemaining</h4> |
| <pre>public long getSplitPointsRemaining()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsRemaining--">BoundedSource.BoundedReader</a></code></span></div> |
| <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>BoundedSource.BoundedReader.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>BoundedSource.BoundedReader.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>BoundedSource.BoundedReader.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="overrideSpecifyLabel">Overrides:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html#getSplitPointsRemaining--">getSplitPointsRemaining</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/OffsetBasedSource.OffsetBasedReader.html" title="class in org.apache.beam.sdk.io">OffsetBasedSource.OffsetBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../../org/apache/beam/sdk/io/BoundedSource.BoundedReader.html#getSplitPointsConsumed--"><code>BoundedSource.BoundedReader.getSplitPointsConsumed()</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="startReading-java.nio.channels.ReadableByteChannel-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>startReading</h4> |
| <pre>protected void startReading(java.nio.channels.ReadableByteChannel channel) |
| throws java.io.IOException</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from class: <code><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#startReading-java.nio.channels.ReadableByteChannel-">FileBasedSource.FileBasedReader</a></code></span></div> |
| <div class="block">Performs any initialization of the subclass of <code>FileBasedReader</code> that involves IO |
| operations. Will only be invoked once and before that invocation the base class will seek the |
| channel to the source's starting offset. |
| |
| <p>Provided <code>ReadableByteChannel</code> is for the file represented by the source of this |
| reader. Subclass may use the <code>channel</code> to build a higher level IO abstraction, e.g., a |
| BufferedReader or an XML parser. |
| |
| <p>If the corresponding source is for a subrange of a file, <code>channel</code> is guaranteed to |
| be an instance of the type <code>SeekableByteChannel</code>. |
| |
| <p>After this method is invoked the base class will not be reading data from the channel or |
| adjusting the position of the channel. But the base class is responsible for properly closing |
| the channel.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html#startReading-java.nio.channels.ReadableByteChannel-">startReading</a></code> in class <code><a href="../../../../../org/apache/beam/sdk/io/FileBasedSource.FileBasedReader.html" title="class in org.apache.beam.sdk.io">FileBasedSource.FileBasedReader</a><<a href="../../../../../org/apache/beam/sdk/io/AvroSource.AvroReader.html" title="type parameter in AvroSource.AvroReader">T</a>></code></dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>channel</code> - a byte channel representing the file backing the reader.</dd> |
| <dt><span class="throwsLabel">Throws:</span></dt> |
| <dd><code>java.io.IOException</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/AvroSource.html" title="class in org.apache.beam.sdk.io"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../org/apache/beam/sdk/io/AvroSource.DatumReaderFactory.html" title="interface in org.apache.beam.sdk.io"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../index.html?org/apache/beam/sdk/io/AvroSource.AvroReader.html" target="_top">Frames</a></li> |
| <li><a href="AvroSource.AvroReader.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>Nested | </li> |
| <li><a href="#fields.inherited.from.class.org.apache.beam.sdk.io.BoundedSource.BoundedReader">Field</a> | </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> |