blob: 920a66bc72eee519c60d4d03490e77b263b0936b [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) on Mon Mar 07 09:03:16 PST 2016 -->
<title>TStream (Quarks v0.4.0)</title>
<meta name="date" content="2016-03-07">
<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="TStream (Quarks v0.4.0)";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":6,"i5":6,"i6":6,"i7":6,"i8":6,"i9":6,"i10":6,"i11":6,"i12":6,"i13":6,"i14":6,"i15":6,"i16":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract 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 role="navigation" title ="TOP_Navigation" aria-label ="Top Navigation Bar"/>
<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="class-use/TStream.html">Use</a></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="../../quarks/topology/TSink.html" title="interface in quarks.topology"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../quarks/topology/TWindow.html" title="interface in quarks.topology"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?quarks/topology/TStream.html" target="_top">Frames</a></li>
<li><a href="TStream.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>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&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 role="main" title ="TStream" aria-labelledby ="Header1"/>
<div class="header">
<div class="subTitle">quarks.topology</div>
<h2 title="Interface TStream" class="title" id="Header1">Interface TStream&lt;T&gt;</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - Tuple type.</dd>
</dl>
<dl>
<dt>All Superinterfaces:</dt>
<dd><a href="../../quarks/topology/TopologyElement.html" title="interface in quarks.topology">TopologyElement</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">TStream&lt;T&gt;</span>
extends <a href="../../quarks/topology/TopologyElement.html" title="interface in quarks.topology">TopologyElement</a></pre>
<div class="block">A <code>TStream</code> is a declaration of a continuous sequence of tuples. A
connected topology of streams and functional transformations is built using
<a href="../../quarks/topology/Topology.html" title="interface in quarks.topology"><code>Topology</code></a>. <BR>
Generic methods on this interface provide the ability to
<a href="../../quarks/topology/TStream.html#filter-quarks.function.Predicate-"><code>filter</code></a>, <a href="../../quarks/topology/TStream.html#map-quarks.function.Function-"><code>map (or transform)</code></a> or <a href="../../quarks/topology/TStream.html#sink-quarks.function.Consumer-"><code>sink</code></a> this declared stream using a
function.
<P>
<code>TStream</code> is not a runtime representation of a stream,
it is a declaration used in building a topology.
The actual runtime stream is created once the topology
is <a href="../../quarks/execution/Submitter.html#submit-E-"><code>submitted</code></a>
to a runtime.
</P></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== 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></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><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;java.lang.String&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#asString--">asString</a></span>()</code>
<div class="block">Convert this stream to a stream of <code>String</code> tuples by calling
<code>toString()</code> on each tuple.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#filter-quarks.function.Predicate-">filter</a></span>(<a href="../../quarks/function/Predicate.html" title="interface in quarks.function">Predicate</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;predicate)</code>
<div class="block">Declare a new stream that filters tuples from this stream.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>&lt;U&gt;&nbsp;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;U&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#flatMap-quarks.function.Function-">flatMap</a></span>(<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,java.lang.Iterable&lt;U&gt;&gt;&nbsp;mapper)</code>
<div class="block">Declare a new stream that maps tuples from this stream into one or
more (or zero) tuples of a different type <code>U</code>.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>java.util.Set&lt;java.lang.String&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#getTags--">getTags</a></span>()</code>
<div class="block">Returns the set of tags associated with this stream.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>&lt;K&gt;&nbsp;<a href="../../quarks/topology/TWindow.html" title="interface in quarks.topology">TWindow</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#last-int-quarks.function.Function-">last</a></span>(int&nbsp;count,
<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;&nbsp;keyFunction)</code>
<div class="block">Declare a partitioned window that continually represents the last <code>count</code>
tuples on this stream for each partition.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>&lt;K&gt;&nbsp;<a href="../../quarks/topology/TWindow.html" title="interface in quarks.topology">TWindow</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#last-long-java.util.concurrent.TimeUnit-quarks.function.Function-">last</a></span>(long&nbsp;time,
java.util.concurrent.TimeUnit&nbsp;unit,
<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;&nbsp;keyFunction)</code>
<div class="block">Declare a partitioned window that continually represents the last <code>time</code> seconds of
tuples on this stream for each partition.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>&lt;U&gt;&nbsp;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;U&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#map-quarks.function.Function-">map</a></span>(<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,U&gt;&nbsp;mapper)</code>
<div class="block">Declare a new stream that maps (or transforms) each tuple from this stream into one
(or zero) tuple of a different type <code>U</code>.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#modify-quarks.function.UnaryOperator-">modify</a></span>(<a href="../../quarks/function/UnaryOperator.html" title="interface in quarks.function">UnaryOperator</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;modifier)</code>
<div class="block">Declare a new stream that modifies each tuple from this stream into one
(or zero) tuple of the same type <code>T</code>.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#peek-quarks.function.Consumer-">peek</a></span>(<a href="../../quarks/function/Consumer.html" title="interface in quarks.function">Consumer</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;peeker)</code>
<div class="block">Declare a stream that contains the same contents as this stream while
peeking at each element using <code>peeker</code>.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>&lt;U&gt;&nbsp;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;U&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#pipe-quarks.oplet.core.Pipe-">pipe</a></span>(<a href="../../quarks/oplet/core/Pipe.html" title="class in quarks.oplet.core">Pipe</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,U&gt;&nbsp;pipe)</code>
<div class="block">Declare a stream that contains the output of the specified <a href="../../quarks/oplet/core/Pipe.html" title="class in quarks.oplet.core"><code>Pipe</code></a>
oplet applied to this stream.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology">TSink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#print--">print</a></span>()</code>
<div class="block">Utility method to print the contents of this stream
to <code>System.out</code> at runtime.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology">TSink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#sink-quarks.function.Consumer-">sink</a></span>(<a href="../../quarks/function/Consumer.html" title="interface in quarks.function">Consumer</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;sinker)</code>
<div class="block">Sink (terminate) this stream using a function.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology">TSink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#sink-quarks.oplet.core.Sink-">sink</a></span>(<a href="../../quarks/oplet/core/Sink.html" title="class in quarks.oplet.core">Sink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;oplet)</code>
<div class="block">Sink (terminate) this stream using a oplet.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>java.util.List&lt;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#split-int-quarks.function.ToIntFunction-">split</a></span>(int&nbsp;n,
<a href="../../quarks/function/ToIntFunction.html" title="interface in quarks.function">ToIntFunction</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;splitter)</code>
<div class="block">Split a stream's tuples among <code>n</code> streams as specified by
<code>splitter</code>.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#tag-java.lang.String...-">tag</a></span>(java.lang.String...&nbsp;values)</code>
<div class="block">Adds the specified tags to the stream.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#union-java.util.Set-">union</a></span>(java.util.Set&lt;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&gt;&nbsp;others)</code>
<div class="block">Declare a stream that will contain all tuples from this stream and all the
streams in <code>others</code>.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../quarks/topology/TStream.html#union-quarks.topology.TStream-">union</a></span>(<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;other)</code>
<div class="block">Declare a stream that will contain all tuples from this stream and
<code>other</code>.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.quarks.topology.TopologyElement">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;quarks.topology.<a href="../../quarks/topology/TopologyElement.html" title="interface in quarks.topology">TopologyElement</a></h3>
<code><a href="../../quarks/topology/TopologyElement.html#topology--">topology</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="filter-quarks.function.Predicate-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>filter</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;filter(<a href="../../quarks/function/Predicate.html" title="interface in quarks.function">Predicate</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;predicate)</pre>
<div class="block">Declare a new stream that filters tuples from this stream. Each tuple
<code>t</code> on this stream will appear in the returned stream if
<a href="../../quarks/function/Predicate.html#test-T-"><code>filter.test(t)</code></a> returns <code>true</code>. If
<code>filter.test(t)</code> returns <code>false</code> then then <code>t</code> will not
appear in the returned stream.
<P>
Examples of filtering out all empty strings from stream <code>s</code> of type
<code>String</code>
<pre>
<code>
TStream&lt;String> s = ...
TStream&lt;String> filtered = s.filter(t -> !t.isEmpty());
</code>
</pre>
</P></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>predicate</code> - Filtering logic to be executed against each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Filtered stream</dd>
</dl>
</li>
</ul>
<a name="map-quarks.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>map</h4>
<pre>&lt;U&gt;&nbsp;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;U&gt;&nbsp;map(<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,U&gt;&nbsp;mapper)</pre>
<div class="block">Declare a new stream that maps (or transforms) each tuple from this stream into one
(or zero) tuple of a different type <code>U</code>. For each tuple <code>t</code>
on this stream, the returned stream will contain a tuple that is the
result of <code>mapper.apply(t)</code> when the return is not <code>null</code>.
If <code>mapper.apply(t)</code> returns <code>null</code> then no tuple
is submitted to the returned stream for <code>t</code>.
<P>
Examples of transforming a stream containing numeric values as
<code>String</code> objects into a stream of <code>Double</code> values.
<pre>
<code>
// Using lambda expression
TStream&lt;String> strings = ...
TStream&lt;Double> doubles = strings.map(v -> Double.valueOf(v));
// Using method reference
TStream&lt;String> strings = ...
TStream&lt;Double> doubles = strings.map(Double::valueOf);
</code>
</pre>
</P></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - Mapping logic to be executed against each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Stream that will contain tuples of type <code>U</code> mapped from this
stream's tuples.</dd>
</dl>
</li>
</ul>
<a name="flatMap-quarks.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>flatMap</h4>
<pre>&lt;U&gt;&nbsp;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;U&gt;&nbsp;flatMap(<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,java.lang.Iterable&lt;U&gt;&gt;&nbsp;mapper)</pre>
<div class="block">Declare a new stream that maps tuples from this stream into one or
more (or zero) tuples of a different type <code>U</code>. For each tuple
<code>t</code> on this stream, the returned stream will contain all non-null tuples in
the <code>Iterator&lt;U&gt;</code> that is the result of <code>mapper.apply(t)</code>.
Tuples will be added to the returned stream in the order the iterator
returns them.
<BR>
If the return is null or an empty iterator then no tuples are added to
the returned stream for input tuple <code>t</code>.
<P>
Examples of mapping a stream containing lines of text into a stream
of words split out from each line. The order of the words in the stream
will match the order of the words in the lines.
<pre>
<code>
TStream&lt;String> lines = ...
TStream&lt;String> words = lines.flatMap(
line -> Arrays.asList(line.split(" ")));
</code>
</pre>
</P></div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>U</code> - Type of mapped input tuples.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>mapper</code> - Mapper logic to be executed against each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Stream that will contain tuples of type <code>U</code> mapped and flattened from this
stream's tuples.</dd>
</dl>
</li>
</ul>
<a name="split-int-quarks.function.ToIntFunction-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>split</h4>
<pre>java.util.List&lt;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&gt;&nbsp;split(int&nbsp;n,
<a href="../../quarks/function/ToIntFunction.html" title="interface in quarks.function">ToIntFunction</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;splitter)</pre>
<div class="block">Split a stream's tuples among <code>n</code> streams as specified by
<code>splitter</code>.
<P>
For each tuple on the stream, <code>splitter.applyAsInt(tuple)</code> is
called. The return value <code>r</code> determines the destination stream:
<pre>
if r < 0 the tuple is discarded
else it is sent to the stream at position (r % n) in the returned array.
</pre>
</P>
<P>
Each split <code>TStream</code> is exposed by the API. The user has full
control over the each stream's processing pipeline. Each stream's
pipeline must be declared explicitly. Each stream can have different
processing pipelines.
</P>
<P>
An N-way <code>split()</code> is logically equivalent to a collection of N
<code>filter()</code> invocations, each with a predicate to select the tuples
for its stream. <code>split()</code> is more efficient. Each tuple is analyzed
only once by a single <code>splitter</code> instance to identify the
destination stream. For example, these are logically equivalent:
<pre>
List&lt;TStream&lt;String>> streams = stream.split(2, tuple -> tuple.length());
TStream&lt;String> stream0 = stream.filter(tuple -> (tuple.length() % 2) == 0);
TStream&lt;String> stream1 = stream.filter(tuple -> (tuple.length() % 2) == 1);
</pre>
</P>
<P>
Example of splitting a stream of log records by their level attribute:
<pre>
<code>
TStream&lt;LogRecord> lrs = ...
List&lt;&lt;TStream&lt;LogRecord>> splits = lrr.split(3, lr -> {
if (SEVERE.equals(lr.getLevel()))
return 0;
else if (WARNING.equals(lr.getLevel()))
return 1;
else
return 2;
});
splits.get(0). ... // SEVERE log record processing pipeline
splits.get(1). ... // WARNING log record processing pipeline
splits.get(2). ... // "other" log record processing pipeline
</code>
</pre>
</P></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - the number of output streams</dd>
<dd><code>splitter</code> - the splitter function</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>List of <code>n</code> streams</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if <code>n &lt;= 0</code></dd>
</dl>
</li>
</ul>
<a name="peek-quarks.function.Consumer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>peek</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;peek(<a href="../../quarks/function/Consumer.html" title="interface in quarks.function">Consumer</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;peeker)</pre>
<div class="block">Declare a stream that contains the same contents as this stream while
peeking at each element using <code>peeker</code>. <BR>
For each tuple <code>t</code> on this stream, <code>peeker.accept(t)</code> will be
called.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>peeker</code> - Function to be called for each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>this</code></dd>
</dl>
</li>
</ul>
<a name="sink-quarks.function.Consumer-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sink</h4>
<pre><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology">TSink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;sink(<a href="../../quarks/function/Consumer.html" title="interface in quarks.function">Consumer</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;sinker)</pre>
<div class="block">Sink (terminate) this stream using a function. For each tuple <code>t</code> on this stream
<a href="../../quarks/function/Consumer.html#accept-T-"><code>sinker.accept(t)</code></a> will be called. This is
typically used to send information to external systems, such as databases
or dashboards.
<p>
If <code>sinker</code> implements <code>AutoCloseable</code>, its <code>close()</code>
method will be called when the topology's execution is terminated.
<P>
Example of terminating a stream of <code>String</code> tuples by printing them
to <code>System.out</code>.
<pre>
<code>
TStream&lt;String> values = ...
values.sink(t -> System.out.println(tuple));
</code>
</pre>
</P></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>sinker</code> - Logic to be executed against each tuple on this stream.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>sink element representing termination of this stream.</dd>
</dl>
</li>
</ul>
<a name="sink-quarks.oplet.core.Sink-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sink</h4>
<pre><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology">TSink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;sink(<a href="../../quarks/oplet/core/Sink.html" title="class in quarks.oplet.core">Sink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;oplet)</pre>
<div class="block">Sink (terminate) this stream using a oplet.
This provides a richer api for a sink than
<a href="../../quarks/topology/TStream.html#sink-quarks.function.Consumer-"><code>sink(Consumer)</code></a> with a full life-cycle of
the oplet as well as easy access to
<a href="../../quarks/execution/services/RuntimeServices.html" title="interface in quarks.execution.services"><code>runtime services</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>oplet</code> - Oplet processes each tuple without producing output.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>sink element representing termination of this stream.</dd>
</dl>
</li>
</ul>
<a name="pipe-quarks.oplet.core.Pipe-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pipe</h4>
<pre>&lt;U&gt;&nbsp;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;U&gt;&nbsp;pipe(<a href="../../quarks/oplet/core/Pipe.html" title="class in quarks.oplet.core">Pipe</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,U&gt;&nbsp;pipe)</pre>
<div class="block">Declare a stream that contains the output of the specified <a href="../../quarks/oplet/core/Pipe.html" title="class in quarks.oplet.core"><code>Pipe</code></a>
oplet applied to this stream.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>U</code> - Tuple type of the returned stream.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>pipe</code> - The <a href="../../quarks/oplet/core/Pipe.html" title="class in quarks.oplet.core"><code>Pipe</code></a> oplet.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Declared stream that contains the tuples emitted by the pipe
oplet.</dd>
</dl>
</li>
</ul>
<a name="modify-quarks.function.UnaryOperator-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>modify</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;modify(<a href="../../quarks/function/UnaryOperator.html" title="interface in quarks.function">UnaryOperator</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;modifier)</pre>
<div class="block">Declare a new stream that modifies each tuple from this stream into one
(or zero) tuple of the same type <code>T</code>. For each tuple <code>t</code>
on this stream, the returned stream will contain a tuple that is the
result of <code>modifier.apply(t)</code> when the return is not <code>null</code>.
The function may return the same reference as its input <code>t</code> or
a different object of the same type.
If <code>modifier.apply(t)</code> returns <code>null</code> then no tuple
is submitted to the returned stream for <code>t</code>.
<P>
Example of modifying a stream <code>String</code> values by adding the suffix '<code>extra</code>'.
<pre>
<code>
TStream&lt;String> strings = ...
TStream&lt;String> modifiedStrings = strings.modify(t -> t.concat("extra"));
</code>
</pre>
</P>
<P>
This method is equivalent to
<code>map(Function&lt;T,T&gt; modifier</code>).
</P</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>modifier</code> - Modifier logic to be executed against each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Stream that will contain tuples of type <code>T</code> modified from this
stream's tuples.</dd>
</dl>
</li>
</ul>
<a name="asString--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>asString</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;java.lang.String&gt;&nbsp;asString()</pre>
<div class="block">Convert this stream to a stream of <code>String</code> tuples by calling
<code>toString()</code> on each tuple. This is equivalent to
<code>map(Object::toString)</code>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Declared stream that will contain each the string representation
of each tuple on this stream.</dd>
</dl>
</li>
</ul>
<a name="print--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>print</h4>
<pre><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology">TSink</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;print()</pre>
<div class="block">Utility method to print the contents of this stream
to <code>System.out</code> at runtime. Each tuple is printed
using <code>System.out.println(tuple)</code>.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>TSink</code> for the sink processing.</dd>
</dl>
</li>
</ul>
<a name="last-int-quarks.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>last</h4>
<pre>&lt;K&gt;&nbsp;<a href="../../quarks/topology/TWindow.html" title="interface in quarks.topology">TWindow</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;&nbsp;last(int&nbsp;count,
<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;&nbsp;keyFunction)</pre>
<div class="block">Declare a partitioned window that continually represents the last <code>count</code>
tuples on this stream for each partition. Each partition independently maintains the last
<code>count</code> tuples for each key seen on this stream.
If no tuples have been seen on the stream for a key then the corresponding partition will be empty.
<BR>
The window is partitioned by each tuple's key, obtained by <code>keyFunction</code>.
For each tuple on the stream <code>keyFunction.apply(tuple)</code> is called
and the returned value is the tuple's key. For any two tuples <code>ta,tb</code> in a partition
<code>keyFunction.apply(ta).equals(keyFunction.apply(tb))</code> is true.
<BR>
The key function must return keys that implement <code>equals()</code> and <code>hashCode()</code> correctly.
<P>
To create a window partitioned using the tuple as the key use <a href="../../quarks/function/Functions.html#identity--"><code>identity()</code></a>
as the key function.
</P>
<P>
To create an unpartitioned window use a key function that returns a constant,
by convention <a href="../../quarks/function/Functions.html#unpartitioned--"><code>unpartitioned()</code></a> is recommended.
</P></div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>K</code> - Key type.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>count</code> - Number of tuples to maintain in each partition.</dd>
<dd><code>keyFunction</code> - Function that defines the key for each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Window on this stream representing the last <code>count</code> tuples for each partition.</dd>
</dl>
</li>
</ul>
<a name="last-long-java.util.concurrent.TimeUnit-quarks.function.Function-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>last</h4>
<pre>&lt;K&gt;&nbsp;<a href="../../quarks/topology/TWindow.html" title="interface in quarks.topology">TWindow</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;&nbsp;last(long&nbsp;time,
java.util.concurrent.TimeUnit&nbsp;unit,
<a href="../../quarks/function/Function.html" title="interface in quarks.function">Function</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>,K&gt;&nbsp;keyFunction)</pre>
<div class="block">Declare a partitioned window that continually represents the last <code>time</code> seconds of
tuples on this stream for each partition. If no tuples have been
seen on the stream for a key in the last <code>time</code> seconds then the partition will be empty.
Each partition independently maintains the last
<code>count</code> tuples for each key seen on this stream.
<BR>
The window is partitioned by each tuple's key, obtained by <code>keyFunction</code>.
For each tuple on the stream <code>keyFunction.apply(tuple)</code> is called
and the returned value is the tuple's key. For any two tuples <code>ta,tb</code> in a partition
<code>keyFunction.apply(ta).equals(keyFunction.apply(tb))</code> is true.
<BR>
The key function must return keys that implement <code>equals()</code> and <code>hashCode()</code> correctly.
<P>
To create a window partitioned using the tuple as the key use <a href="../../quarks/function/Functions.html#identity--"><code>identity()</code></a>
as the key function.
</P>
<P>
To create an unpartitioned window use a key function that returns a constant,
by convention <a href="../../quarks/function/Functions.html#unpartitioned--"><code>unpartitioned()</code></a> is recommended.
</P></div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>K</code> - Key type.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>time</code> - Time to retain a tuple in a partition.</dd>
<dd><code>unit</code> - Unit for <code>time</code>.</dd>
<dd><code>keyFunction</code> - Function that defines the key for each tuple.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Partitioned window on this stream representing the last <code>count</code> tuple.</dd>
</dl>
</li>
</ul>
<a name="union-quarks.topology.TStream-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>union</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;union(<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;other)</pre>
<div class="block">Declare a stream that will contain all tuples from this stream and
<code>other</code>. A stream cannot be unioned with itself, in this case
<code>this</code> will be returned.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>other</code> - </dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A stream that is the union of <code>this</code> and <code>other</code>.</dd>
</dl>
</li>
</ul>
<a name="union-java.util.Set-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>union</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;union(java.util.Set&lt;<a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&gt;&nbsp;others)</pre>
<div class="block">Declare a stream that will contain all tuples from this stream and all the
streams in <code>others</code>. A stream cannot be unioned with itself, in
this case the union will only contain tuples from this stream once. If
<code>others</code> is empty or only contains <code>this</code> then <code>this</code>
is returned.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>others</code> - Stream to union with this stream.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A stream that is the union of <code>this</code> and <code>others</code>.</dd>
</dl>
</li>
</ul>
<a name="tag-java.lang.String...-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>tag</h4>
<pre><a href="../../quarks/topology/TStream.html" title="interface in quarks.topology">TStream</a>&lt;<a href="../../quarks/topology/TStream.html" title="type parameter in TStream">T</a>&gt;&nbsp;tag(java.lang.String...&nbsp;values)</pre>
<div class="block">Adds the specified tags to the stream. Adding the same tag to
a stream multiple times will not change the result beyond the
initial application.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - Tag values.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The tagged stream.</dd>
</dl>
</li>
</ul>
<a name="getTags--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getTags</h4>
<pre>java.util.Set&lt;java.lang.String&gt;&nbsp;getTags()</pre>
<div class="block">Returns the set of tags associated with this stream.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>set of tags</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div role="navigation" title ="Bottom_NAVIGATION" aria-label ="Bottom Navigation Bar"/>
<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="class-use/TStream.html">Use</a></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 class="aboutLanguage"><a href="http://quarks-edge.github.io">quarks-edge community @ github.com</a></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../quarks/topology/TSink.html" title="interface in quarks.topology"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../quarks/topology/TWindow.html" title="interface in quarks.topology"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?quarks/topology/TStream.html" target="_top">Frames</a></li>
<li><a href="TStream.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>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<div role="contentinfo" title ="contentinfo_title" aria-label ="Contains footer note"/>
<p class="legalCopy"><small>Copyright IBM 2015,2016 - 2f6ad0e-20160307-0902</small></p>
</body>
</html>