| <!DOCTYPE HTML> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (17) --> |
| <title>KGroupedStream (kafka 3.6.1 API)</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta name="description" content="declaration: package: org.apache.kafka.streams.kstream, interface: KGroupedStream"> |
| <meta name="generator" content="javadoc/ClassWriterImpl"> |
| <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../script-dir/jquery-ui.min.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../jquery-ui.overrides.css" title="Style"> |
| <script type="text/javascript" src="../../../../../script.js"></script> |
| <script type="text/javascript" src="../../../../../script-dir/jquery-3.5.1.min.js"></script> |
| <script type="text/javascript" src="../../../../../script-dir/jquery-ui.min.js"></script> |
| </head> |
| <body class="class-declaration-page"> |
| <script type="text/javascript">var evenRowColor = "even-row-color"; |
| var oddRowColor = "odd-row-color"; |
| var tableTab = "table-tab"; |
| var activeTableTab = "active-table-tab"; |
| var pathtoroot = "../../../../../"; |
| loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <div class="flex-box"> |
| <header role="banner" class="flex-header"> |
| <nav role="navigation"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="top-nav" id="navbar-top"> |
| <div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div> |
| <ul id="navbar-top-firstrow" class="nav-list" title="Navigation"> |
| <li><a href="../../../../../index.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="nav-bar-cell1-rev">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#class">Help</a></li> |
| </ul> |
| </div> |
| <div class="sub-nav"> |
| <div> |
| <ul class="sub-nav-list"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| <ul class="sub-nav-list"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </div> |
| <div class="nav-list-search"><label for="search-input">SEARCH:</label> |
| <input type="text" id="search-input" value="search" disabled="disabled"> |
| <input type="reset" id="reset-button" value="reset" disabled="disabled"> |
| </div> |
| </div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <span class="skip-nav" id="skip-navbar-top"></span></nav> |
| </header> |
| <div class="flex-content"> |
| <main role="main"> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="sub-title"><span class="package-label-in-type">Package</span> <a href="package-summary.html">org.apache.kafka.streams.kstream</a></div> |
| <h1 title="Interface KGroupedStream" class="title">Interface KGroupedStream<K,<wbr>V></h1> |
| </div> |
| <section class="class-description" id="class-description"> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>K</code> - Type of keys</dd> |
| <dd><code>V</code> - Type of values</dd> |
| </dl> |
| <hr> |
| <div class="type-signature"><span class="modifiers">public interface </span><span class="element-name type-name-label">KGroupedStream<K,<wbr>V></span></div> |
| <div class="block"><code>KGroupedStream</code> is an abstraction of a <i>grouped</i> record stream of <a href="../KeyValue.html" title="class in org.apache.kafka.streams"><code>KeyValue</code></a> pairs. |
| It is an intermediate representation of a <a href="KStream.html" title="interface in org.apache.kafka.streams.kstream"><code>KStream</code></a> in order to apply an aggregation operation on the original |
| <a href="KStream.html" title="interface in org.apache.kafka.streams.kstream"><code>KStream</code></a> records. |
| <p> |
| It is an intermediate representation after a grouping of a <a href="KStream.html" title="interface in org.apache.kafka.streams.kstream"><code>KStream</code></a> before an aggregation is applied to the |
| new partitions resulting in a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a>. |
| <p> |
| A <code>KGroupedStream</code> must be obtained from a <a href="KStream.html" title="interface in org.apache.kafka.streams.kstream"><code>KStream</code></a> via <a href="KStream.html#groupByKey()"><code>groupByKey()</code></a> or |
| <a href="KStream.html#groupBy(org.apache.kafka.streams.kstream.KeyValueMapper)"><code>groupBy(...)</code></a>.</div> |
| <dl class="notes"> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="see-list"> |
| <li><a href="KStream.html" title="interface in org.apache.kafka.streams.kstream"><code>KStream</code></a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| <section class="summary"> |
| <ul class="summary-list"> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <li> |
| <section class="method-summary" id="method-summary"> |
| <h2>Method Summary</h2> |
| <div id="method-summary-table"> |
| <div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button></div> |
| <div id="method-summary-table.tabpanel" role="tabpanel"> |
| <div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0"> |
| <div class="table-header col-first">Modifier and Type</div> |
| <div class="table-header col-second">Method</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><VR> <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator)" class="member-name-link">aggregate</a><wbr>(<a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream">Initializer</a><VR> initializer, |
| <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VR> aggregator)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Aggregate the values of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><VR> <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Materialized)" class="member-name-link">aggregate</a><wbr>(<a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream">Initializer</a><VR> initializer, |
| <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VR> aggregator, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Aggregate the values of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><VR> <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Named,org.apache.kafka.streams.kstream.Materialized)" class="member-name-link">aggregate</a><wbr>(<a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream">Initializer</a><VR> initializer, |
| <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VR> aggregator, |
| <a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Aggregate the values of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><VOut> <a href="CogroupedKStream.html" title="interface in org.apache.kafka.streams.kstream">CogroupedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VOut></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#cogroup(org.apache.kafka.streams.kstream.Aggregator)" class="member-name-link">cogroup</a><wbr>(<a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VOut> aggregator)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Create a new <a href="CogroupedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>CogroupedKStream</code></a> from the this grouped KStream to allow cogrouping other |
| <code>KGroupedStream</code> to it.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#count()" class="member-name-link">count</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Count the number of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#count(org.apache.kafka.streams.kstream.Materialized)" class="member-name-link">count</a><wbr>(<a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Count the number of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#count(org.apache.kafka.streams.kstream.Named)" class="member-name-link">count</a><wbr>(<a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Count the number of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#count(org.apache.kafka.streams.kstream.Named,org.apache.kafka.streams.kstream.Materialized)" class="member-name-link">count</a><wbr>(<a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Count the number of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#reduce(org.apache.kafka.streams.kstream.Reducer)" class="member-name-link">reduce</a><wbr>(<a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream">Reducer</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>> reducer)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Combine the values of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#reduce(org.apache.kafka.streams.kstream.Reducer,org.apache.kafka.streams.kstream.Materialized)" class="member-name-link">reduce</a><wbr>(<a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream">Reducer</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>> reducer, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Combine the value of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#reduce(org.apache.kafka.streams.kstream.Reducer,org.apache.kafka.streams.kstream.Named,org.apache.kafka.streams.kstream.Materialized)" class="member-name-link">reduce</a><wbr>(<a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream">Reducer</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>> reducer, |
| <a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Combine the value of records in this stream by the grouped key.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="SessionWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream">SessionWindowedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#windowedBy(org.apache.kafka.streams.kstream.SessionWindows)" class="member-name-link">windowedBy</a><wbr>(<a href="SessionWindows.html" title="class in org.apache.kafka.streams.kstream">SessionWindows</a> windows)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Create a new <a href="SessionWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>SessionWindowedKStream</code></a> instance that can be used to perform session windowed aggregations.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream">TimeWindowedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#windowedBy(org.apache.kafka.streams.kstream.SlidingWindows)" class="member-name-link">windowedBy</a><wbr>(<a href="SlidingWindows.html" title="class in org.apache.kafka.streams.kstream">SlidingWindows</a> windows)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Create a new <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a> instance that can be used to perform sliding windowed aggregations.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><W extends <a href="Window.html" title="class in org.apache.kafka.streams.kstream">Window</a>><br><a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream">TimeWindowedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#windowedBy(org.apache.kafka.streams.kstream.Windows)" class="member-name-link">windowedBy</a><wbr>(<a href="Windows.html" title="class in org.apache.kafka.streams.kstream">Windows</a><W> windows)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Create a new <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a> instance that can be used to perform windowed aggregations.</div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <section class="details"> |
| <ul class="details-list"> |
| <!-- ============ METHOD DETAIL ========== --> |
| <li> |
| <section class="method-details" id="method-detail"> |
| <h2>Method Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="count()"> |
| <h3>count</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></span> <span class="element-name">count</span>()</div> |
| <div class="block">Count the number of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view). |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a>) will be backed by |
| an internal changelog topic that will be created in Kafka. |
| The changelog topic will be named "${applicationId}-${internalStoreName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "internalStoreName" is an internal name |
| and "-changelog" is a fixed suffix. |
| Note that the internal store name may not be queryable through Interactive Queries. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys and <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link"><code>Long</code></a> values that |
| represent the latest (rolling) count (i.e., number of records) for each key</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="count(org.apache.kafka.streams.kstream.Named)"> |
| <h3>count</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></span> <span class="element-name">count</span><wbr><span class="parameters">(<a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named)</span></div> |
| <div class="block">Count the number of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view). |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a>) will be backed by |
| an internal changelog topic that will be created in Kafka. |
| The changelog topic will be named "${applicationId}-${internalStoreName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "internalStoreName" is an internal name |
| and "-changelog" is a fixed suffix. |
| Note that the internal store name may not be queryable through Interactive Queries. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>named</code> - a <a href="Named.html" title="class in org.apache.kafka.streams.kstream"><code>Named</code></a> config used to name the processor in the topology</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys and <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link"><code>Long</code></a> values that |
| represent the latest (rolling) count (i.e., number of records) for each key</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="count(org.apache.kafka.streams.kstream.Materialized)"> |
| <h3>count</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></span> <span class="element-name">count</span><wbr><span class="parameters">(<a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</span></div> |
| <div class="block">Count the number of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view) |
| provided by the given store name in <code>materialized</code>. |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| To query the local <a href="../state/ReadOnlyKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>ReadOnlyKeyValueStore</code></a> it must be obtained via |
| <a href="../KafkaStreams.html#store(org.apache.kafka.streams.StoreQueryParameters)"><code>KafkaStreams#store(...)</code></a>. |
| <pre><code> |
| KafkaStreams streams = ... // counting words |
| String queryableStoreName = "storeName"; // the store name should be the name of the store as defined by the Materialized instance |
| StoreQueryParameters<ReadOnlyKeyValueStore<K, ValueAndTimestamp<Long>>> storeQueryParams = StoreQueryParameters.fromNameAndType(queryableStoreName, QueryableStoreTypes.timestampedKeyValueStore()); |
| ReadOnlyKeyValueStore<K, ValueAndTimestamp<Long>> localStore = streams.store(storeQueryParams); |
| K key = "some-word"; |
| ValueAndTimestamp<Long> countForWord = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) |
| </code></pre> |
| For non-local keys, a custom RPC mechanism must be implemented using <a href="../KafkaStreams.html#metadataForAllStreamsClients()"><code>KafkaStreams.metadataForAllStreamsClients()</code></a> to |
| query the value of the key on a parallel running instance of your Kafka Streams application. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a> -- regardless of what |
| is specified in the parameter <code>materialized</code>) will be backed by an internal changelog topic that will be created in Kafka. |
| Therefore, the store name defined by the Materialized instance must be a valid Kafka topic name and cannot contain characters other than ASCII |
| alphanumerics, '.', '_' and '-'. |
| The changelog topic will be named "${applicationId}-${storeName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "storeName" is the |
| provide store name defined in <code>Materialized</code>, and "-changelog" is a fixed suffix. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>materialized</code> - an instance of <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream"><code>Materialized</code></a> used to materialize a state store. Cannot be <code>null</code>. |
| Note: the valueSerde will be automatically set to <a href="../../common/serialization/Serdes.html#Long()"><code>Serdes#Long()</code></a> |
| if there is no valueSerde provided</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys and <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link"><code>Long</code></a> values that |
| represent the latest (rolling) count (i.e., number of records) for each key</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="count(org.apache.kafka.streams.kstream.Named,org.apache.kafka.streams.kstream.Materialized)"> |
| <h3>count</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>></span> <span class="element-name">count</span><wbr><span class="parameters">(<a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</span></div> |
| <div class="block">Count the number of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view) |
| provided by the given store name in <code>materialized</code>. |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| To query the local <a href="../state/ReadOnlyKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>ReadOnlyKeyValueStore</code></a> it must be obtained via |
| <a href="../KafkaStreams.html#store(org.apache.kafka.streams.StoreQueryParameters)"><code>KafkaStreams#store(...)</code></a>. |
| <pre><code> |
| KafkaStreams streams = ... // counting words |
| String queryableStoreName = "storeName"; // the store name should be the name of the store as defined by the Materialized instance |
| StoreQueryParameters<ReadOnlyKeyValueStore<K, ValueAndTimestamp<Long>>> storeQueryParams = StoreQueryParameters.fromNameAndType(queryableStoreName, QueryableStoreTypes.timestampedKeyValueStore()); |
| ReadOnlyKeyValueStore<K, ValueAndTimestamp<Long>> localStore = streams.store(storeQueryParams); |
| K key = "some-word"; |
| ValueAndTimestamp<Long> countForWord = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) |
| </code></pre> |
| For non-local keys, a custom RPC mechanism must be implemented using <a href="../KafkaStreams.html#metadataForAllStreamsClients()"><code>KafkaStreams.metadataForAllStreamsClients()</code></a> to |
| query the value of the key on a parallel running instance of your Kafka Streams application. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a> -- regardless of what |
| is specified in the parameter <code>materialized</code>) will be backed by an internal changelog topic that will be created in Kafka. |
| Therefore, the store name defined by the Materialized instance must be a valid Kafka topic name and cannot contain characters other than ASCII |
| alphanumerics, '.', '_' and '-'. |
| The changelog topic will be named "${applicationId}-${storeName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "storeName" is the |
| provide store name defined in <code>Materialized</code>, and "-changelog" is a fixed suffix. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>named</code> - a <a href="Named.html" title="class in org.apache.kafka.streams.kstream"><code>Named</code></a> config used to name the processor in the topology</dd> |
| <dd><code>materialized</code> - an instance of <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream"><code>Materialized</code></a> used to materialize a state store. Cannot be <code>null</code>. |
| Note: the valueSerde will be automatically set to <a href="../../common/serialization/Serdes.html#Long()"><code>Serdes#Long()</code></a> |
| if there is no valueSerde provided</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys and <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link"><code>Long</code></a> values that |
| represent the latest (rolling) count (i.e., number of records) for each key</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="reduce(org.apache.kafka.streams.kstream.Reducer)"> |
| <h3>reduce</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></span> <span class="element-name">reduce</span><wbr><span class="parameters">(<a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream">Reducer</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>> reducer)</span></div> |
| <div class="block">Combine the values of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| Combining implies that the type of the aggregate result is the same as the type of the input value |
| (c.f. <a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator)"><code>aggregate(Initializer, Aggregator)</code></a>). |
| <p> |
| The specified <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> is applied for each input record and computes a new aggregate using the current |
| aggregate and the record's value. |
| If there is no current aggregate the <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> is not applied and the new aggregate will be the record's |
| value as-is. |
| Thus, <code>reduce(Reducer)</code> can be used to compute aggregate functions like sum, min, or max. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a>) will be backed by |
| an internal changelog topic that will be created in Kafka. |
| The changelog topic will be named "${applicationId}-${internalStoreName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "internalStoreName" is an internal name |
| and "-changelog" is a fixed suffix. |
| Note that the internal store name may not be queryable through Interactive Queries. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>reducer</code> - a <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> that computes a new aggregate result. Cannot be <code>null</code>.</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys, and values that represent the |
| latest (rolling) aggregate for each key. If the reduce function returns <code>null</code>, it is then interpreted as |
| deletion for the key, and future messages of the same key coming from upstream operators |
| will be handled as newly initialized value.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="reduce(org.apache.kafka.streams.kstream.Reducer,org.apache.kafka.streams.kstream.Materialized)"> |
| <h3>reduce</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></span> <span class="element-name">reduce</span><wbr><span class="parameters">(<a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream">Reducer</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>> reducer, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</span></div> |
| <div class="block">Combine the value of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| Combining implies that the type of the aggregate result is the same as the type of the input value |
| (c.f. <a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Materialized)"><code>aggregate(Initializer, Aggregator, Materialized)</code></a>). |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view) |
| provided by the given store name in <code>materialized</code>. |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| The specified <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> is applied for each input record and computes a new aggregate using the current |
| aggregate (first argument) and the record's value (second argument): |
| <pre><code> |
| // At the example of a Reducer<Long> |
| new Reducer<Long>() { |
| public Long apply(Long aggValue, Long currValue) { |
| return aggValue + currValue; |
| } |
| } |
| </code></pre> |
| <p> |
| If there is no current aggregate the <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> is not applied and the new aggregate will be the record's |
| value as-is. |
| Thus, <code>reduce(Reducer, Materialized)</code> can be used to compute aggregate functions like sum, min, or |
| max. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| To query the local <a href="../state/ReadOnlyKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>ReadOnlyKeyValueStore</code></a> it must be obtained via |
| <a href="../KafkaStreams.html#store(org.apache.kafka.streams.StoreQueryParameters)"><code>KafkaStreams#store(...)</code></a>. |
| <pre><code> |
| KafkaStreams streams = ... // compute sum |
| String queryableStoreName = "storeName" // the store name should be the name of the store as defined by the Materialized instance |
| StoreQueryParameters<ReadOnlyKeyValueStore<K, ValueAndTimestamp<V>>> storeQueryParams = StoreQueryParameters.fromNameAndType(queryableStoreName, QueryableStoreTypes.timestampedKeyValueStore()); |
| ReadOnlyKeyValueStore<K, ValueAndTimestamp<V>> localStore = streams.store(storeQueryParams); |
| K key = "some-key"; |
| ValueAndTimestamp<V> reduceForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) |
| </code></pre> |
| For non-local keys, a custom RPC mechanism must be implemented using <a href="../KafkaStreams.html#metadataForAllStreamsClients()"><code>KafkaStreams.metadataForAllStreamsClients()</code></a> to |
| query the value of the key on a parallel running instance of your Kafka Streams application. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a> -- regardless of what |
| is specified in the parameter <code>materialized</code>) will be backed by an internal changelog topic that will be created in Kafka. |
| The changelog topic will be named "${applicationId}-${internalStoreName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "internalStoreName" is an internal name |
| and "-changelog" is a fixed suffix. |
| Note that the internal store name may not be queryable through Interactive Queries. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>reducer</code> - a <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> that computes a new aggregate result. Cannot be <code>null</code>.</dd> |
| <dd><code>materialized</code> - an instance of <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream"><code>Materialized</code></a> used to materialize a state store. Cannot be <code>null</code>.</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys, and values that represent the |
| latest (rolling) aggregate for each key</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="reduce(org.apache.kafka.streams.kstream.Reducer,org.apache.kafka.streams.kstream.Named,org.apache.kafka.streams.kstream.Materialized)"> |
| <h3>reduce</h3> |
| <div class="member-signature"><span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></span> <span class="element-name">reduce</span><wbr><span class="parameters">(<a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream">Reducer</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>> reducer, |
| <a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</span></div> |
| <div class="block">Combine the value of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| Combining implies that the type of the aggregate result is the same as the type of the input value |
| (c.f. <a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Materialized)"><code>aggregate(Initializer, Aggregator, Materialized)</code></a>). |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view) |
| provided by the given store name in <code>materialized</code>. |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| The specified <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> is applied for each input record and computes a new aggregate using the current |
| aggregate (first argument) and the record's value (second argument): |
| <pre><code> |
| // At the example of a Reducer<Long> |
| new Reducer<Long>() { |
| public Long apply(Long aggValue, Long currValue) { |
| return aggValue + currValue; |
| } |
| } |
| </code></pre> |
| <p> |
| If there is no current aggregate the <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> is not applied and the new aggregate will be the record's |
| value as-is. |
| Thus, <code>reduce(Reducer, Materialized)</code> can be used to compute aggregate functions like sum, min, or |
| max. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| To query the local <a href="../state/ReadOnlyKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>ReadOnlyKeyValueStore</code></a> it must be obtained via |
| <a href="../KafkaStreams.html#store(org.apache.kafka.streams.StoreQueryParameters)"><code>KafkaStreams#store(...)</code></a>. |
| <pre><code> |
| KafkaStreams streams = ... // compute sum |
| String queryableStoreName = "storeName" // the store name should be the name of the store as defined by the Materialized instance |
| StoreQueryParameters<ReadOnlyKeyValueStore<K, ValueAndTimestamp<V>>> storeQueryParams = StoreQueryParameters.fromNameAndType(queryableStoreName, QueryableStoreTypes.timestampedKeyValueStore()); |
| ReadOnlyKeyValueStore<K, ValueAndTimestamp<V>> localStore = streams.store(storeQueryParams); |
| K key = "some-key"; |
| ValueAndTimestamp<V> reduceForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) |
| </code></pre> |
| For non-local keys, a custom RPC mechanism must be implemented using <a href="../KafkaStreams.html#metadataForAllStreamsClients()"><code>KafkaStreams.metadataForAllStreamsClients()</code></a> to |
| query the value of the key on a parallel running instance of your Kafka Streams application. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a> -- regardless of what |
| is specified in the parameter <code>materialized</code>) will be backed by an internal changelog topic that will be created in Kafka. |
| The changelog topic will be named "${applicationId}-${internalStoreName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "internalStoreName" is an internal name |
| and "-changelog" is a fixed suffix. |
| Note that the internal store name may not be queryable through Interactive Queries. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>reducer</code> - a <a href="Reducer.html" title="interface in org.apache.kafka.streams.kstream"><code>Reducer</code></a> that computes a new aggregate result. Cannot be <code>null</code>.</dd> |
| <dd><code>named</code> - a <a href="Named.html" title="class in org.apache.kafka.streams.kstream"><code>Named</code></a> config used to name the processor in the topology.</dd> |
| <dd><code>materialized</code> - an instance of <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream"><code>Materialized</code></a> used to materialize a state store. Cannot be <code>null</code>.</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys, and values that represent the |
| latest (rolling) aggregate for each key. If the reduce function returns <code>null</code>, it is then interpreted as |
| deletion for the key, and future messages of the same key coming from upstream operators |
| will be handled as newly initialized value.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator)"> |
| <h3>aggregate</h3> |
| <div class="member-signature"><span class="type-parameters"><VR></span> <span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR></span> <span class="element-name">aggregate</span><wbr><span class="parameters">(<a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream">Initializer</a><VR> initializer, |
| <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VR> aggregator)</span></div> |
| <div class="block">Aggregate the values of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| Aggregating is a generalization of <a href="#reduce(org.apache.kafka.streams.kstream.Reducer)"><code>combining via reduce(...)</code></a> as it, for example, |
| allows the result to have a different type than the input values. |
| <p> |
| The specified <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> is applied once directly before the first input record is processed to |
| provide an initial intermediate aggregation result that is used to process the first record. |
| The specified <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> is applied for each input record and computes a new aggregate using the current |
| aggregate (or for the very first record using the intermediate aggregation result provided via the |
| <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a>) and the record's value. |
| Thus, <code>aggregate(Initializer, Aggregator)</code> can be used to compute aggregate functions like |
| count (c.f. <a href="#count()"><code>count()</code></a>). |
| <p> |
| The default value serde from config will be used for serializing the result. |
| If a different serde is required then you should use <a href="#aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Materialized)"><code>aggregate(Initializer, Aggregator, Materialized)</code></a>. |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a>) will be backed by |
| an internal changelog topic that will be created in Kafka. |
| The changelog topic will be named "${applicationId}-${internalStoreName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "internalStoreName" is an internal name |
| and "-changelog" is a fixed suffix. |
| Note that the internal store name may not be queryable through Interactive Queries. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>VR</code> - the value type of the resulting <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a></dd> |
| <dt>Parameters:</dt> |
| <dd><code>initializer</code> - an <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> that computes an initial intermediate aggregation result</dd> |
| <dd><code>aggregator</code> - an <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> that computes a new aggregate result</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys, and values that represent the |
| latest (rolling) aggregate for each key. If the aggregate function returns <code>null</code>, it is then interpreted as |
| deletion for the key, and future messages of the same key coming from upstream operators |
| will be handled as newly initialized value.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Materialized)"> |
| <h3>aggregate</h3> |
| <div class="member-signature"><span class="type-parameters"><VR></span> <span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR></span> <span class="element-name">aggregate</span><wbr><span class="parameters">(<a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream">Initializer</a><VR> initializer, |
| <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VR> aggregator, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</span></div> |
| <div class="block">Aggregate the values of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| Aggregating is a generalization of <a href="#reduce(org.apache.kafka.streams.kstream.Reducer)"><code>combining via reduce(...)</code></a> as it, for example, |
| allows the result to have a different type than the input values. |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view) |
| that can be queried by the given store name in <code>materialized</code>. |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| The specified <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> is applied once directly before the first input record is processed to |
| provide an initial intermediate aggregation result that is used to process the first record. |
| The specified <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> is applied for each input record and computes a new aggregate using the current |
| aggregate (or for the very first record using the intermediate aggregation result provided via the |
| <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a>) and the record's value. |
| Thus, <code>aggregate(Initializer, Aggregator, Materialized)</code> can be used to compute aggregate functions like |
| count (c.f. <a href="#count()"><code>count()</code></a>). |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| To query the local <a href="../state/ReadOnlyKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>ReadOnlyKeyValueStore</code></a> it must be obtained via |
| <a href="../KafkaStreams.html#store(org.apache.kafka.streams.StoreQueryParameters)"><code>KafkaStreams#store(...)</code></a>: |
| <pre><code> |
| KafkaStreams streams = ... // some aggregation on value type double |
| String queryableStoreName = "storeName" // the store name should be the name of the store as defined by the Materialized instance |
| StoreQueryParameters<ReadOnlyKeyValueStore<K, ValueAndTimestamp<VR>>> storeQueryParams = StoreQueryParameters.fromNameAndType(queryableStoreName, QueryableStoreTypes.timestampedKeyValueStore()); |
| ReadOnlyKeyValueStore<K, ValueAndTimestamp<VR>> localStore = streams.store(storeQueryParams); |
| K key = "some-key"; |
| ValueAndTimestamp<VR> aggForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) |
| </code></pre> |
| For non-local keys, a custom RPC mechanism must be implemented using <a href="../KafkaStreams.html#metadataForAllStreamsClients()"><code>KafkaStreams.metadataForAllStreamsClients()</code></a> to |
| query the value of the key on a parallel running instance of your Kafka Streams application. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a> -- regardless of what |
| is specified in the parameter <code>materialized</code>) will be backed by an internal changelog topic that will be created in Kafka. |
| Therefore, the store name defined by the Materialized instance must be a valid Kafka topic name and cannot contain characters other than ASCII |
| alphanumerics, '.', '_' and '-'. |
| The changelog topic will be named "${applicationId}-${storeName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "storeName" is the |
| provide store name defined in <code>Materialized</code>, and "-changelog" is a fixed suffix. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>VR</code> - the value type of the resulting <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a></dd> |
| <dt>Parameters:</dt> |
| <dd><code>initializer</code> - an <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> that computes an initial intermediate aggregation result</dd> |
| <dd><code>aggregator</code> - an <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> that computes a new aggregate result</dd> |
| <dd><code>materialized</code> - an instance of <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream"><code>Materialized</code></a> used to materialize a state store. Cannot be <code>null</code>.</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys, and values that represent the |
| latest (rolling) aggregate for each key</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="aggregate(org.apache.kafka.streams.kstream.Initializer,org.apache.kafka.streams.kstream.Aggregator,org.apache.kafka.streams.kstream.Named,org.apache.kafka.streams.kstream.Materialized)"> |
| <h3>aggregate</h3> |
| <div class="member-signature"><span class="type-parameters"><VR></span> <span class="return-type"><a href="KTable.html" title="interface in org.apache.kafka.streams.kstream">KTable</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR></span> <span class="element-name">aggregate</span><wbr><span class="parameters">(<a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream">Initializer</a><VR> initializer, |
| <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VR> aggregator, |
| <a href="Named.html" title="class in org.apache.kafka.streams.kstream">Named</a> named, |
| <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream">Materialized</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VR,<wbr><a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><org.apache.kafka.common.utils.Bytes,<wbr>byte[]>> materialized)</span></div> |
| <div class="block">Aggregate the values of records in this stream by the grouped key. |
| Records with <code>null</code> key or value are ignored. |
| Aggregating is a generalization of <a href="#reduce(org.apache.kafka.streams.kstream.Reducer)"><code>combining via reduce(...)</code></a> as it, for example, |
| allows the result to have a different type than the input values. |
| The result is written into a local <a href="../state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> (which is basically an ever-updating materialized view) |
| that can be queried by the given store name in <code>materialized</code>. |
| Furthermore, updates to the store are sent downstream into a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> changelog stream. |
| <p> |
| The specified <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> is applied once directly before the first input record is processed to |
| provide an initial intermediate aggregation result that is used to process the first record. |
| The specified <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> is applied for each input record and computes a new aggregate using the current |
| aggregate (or for the very first record using the intermediate aggregation result provided via the |
| <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a>) and the record's value. |
| Thus, <code>aggregate(Initializer, Aggregator, Materialized)</code> can be used to compute aggregate functions like |
| count (c.f. <a href="#count()"><code>count()</code></a>). |
| <p> |
| Not all updates might get sent downstream, as an internal cache is used to deduplicate consecutive updates to |
| the same key. |
| The rate of propagated updates depends on your input data rate, the number of distinct keys, the number of |
| parallel running Kafka Streams instances, and the <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>configuration</code></a> parameters for |
| <a href="../StreamsConfig.html#STATESTORE_CACHE_MAX_BYTES_CONFIG"><code>cache size</code></a>, and |
| <a href="../StreamsConfig.html#COMMIT_INTERVAL_MS_CONFIG"><code>commit interval</code></a>. |
| <p> |
| To query the local <a href="../state/ReadOnlyKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>ReadOnlyKeyValueStore</code></a> it must be obtained via |
| <a href="../KafkaStreams.html#store(org.apache.kafka.streams.StoreQueryParameters)"><code>KafkaStreams#store(...)</code></a>: |
| <pre><code> |
| KafkaStreams streams = ... // some aggregation on value type double |
| String queryableStoreName = "storeName" // the store name should be the name of the store as defined by the Materialized instance |
| StoreQueryParameters<ReadOnlyKeyValueStore<K, ValueAndTimestamp<VR>>> storeQueryParams = StoreQueryParameters.fromNameAndType(queryableStoreName, QueryableStoreTypes.timestampedKeyValueStore()); |
| ReadOnlyKeyValueStore<K, ValueAndTimestamp<VR>> localStore = streams.store(storeQueryParams); |
| K key = "some-key"; |
| ValueAndTimestamp<VR> aggForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) |
| </code></pre> |
| For non-local keys, a custom RPC mechanism must be implemented using <a href="../KafkaStreams.html#metadataForAllStreamsClients()"><code>KafkaStreams.metadataForAllStreamsClients()</code></a> to |
| query the value of the key on a parallel running instance of your Kafka Streams application. |
| |
| <p> |
| For failure and recovery the store (which always will be of type <a href="../state/TimestampedKeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>TimestampedKeyValueStore</code></a> -- regardless of what |
| is specified in the parameter <code>materialized</code>) will be backed by an internal changelog topic that will be created in Kafka. |
| Therefore, the store name defined by the Materialized instance must be a valid Kafka topic name and cannot contain characters other than ASCII |
| alphanumerics, '.', '_' and '-'. |
| The changelog topic will be named "${applicationId}-${storeName}-changelog", where "applicationId" is |
| user-specified in <a href="../StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a> via parameter |
| <a href="../StreamsConfig.html#APPLICATION_ID_CONFIG"><code>APPLICATION_ID_CONFIG</code></a>, "storeName" is the |
| provide store name defined in <code>Materialized</code>, and "-changelog" is a fixed suffix. |
| |
| You can retrieve all generated internal topic names via <a href="../Topology.html#describe()"><code>Topology.describe()</code></a>.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>VR</code> - the value type of the resulting <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a></dd> |
| <dt>Parameters:</dt> |
| <dd><code>initializer</code> - an <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> that computes an initial intermediate aggregation result</dd> |
| <dd><code>aggregator</code> - an <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> that computes a new aggregate result</dd> |
| <dd><code>named</code> - a <a href="Named.html" title="class in org.apache.kafka.streams.kstream"><code>Named</code></a> config used to name the processor in the topology</dd> |
| <dd><code>materialized</code> - an instance of <a href="Materialized.html" title="class in org.apache.kafka.streams.kstream"><code>Materialized</code></a> used to materialize a state store. Cannot be <code>null</code>.</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a> that contains "update" records with unmodified keys, and values that represent the |
| latest (rolling) aggregate for each key. If the aggregate function returns <code>null</code>, it is then interpreted as |
| deletion for the key, and future messages of the same key coming from upstream operators |
| will be handled as newly initialized value.</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="windowedBy(org.apache.kafka.streams.kstream.Windows)"> |
| <h3>windowedBy</h3> |
| <div class="member-signature"><span class="type-parameters"><W extends <a href="Window.html" title="class in org.apache.kafka.streams.kstream">Window</a>></span> <span class="return-type"><a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream">TimeWindowedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></span> <span class="element-name">windowedBy</span><wbr><span class="parameters">(<a href="Windows.html" title="class in org.apache.kafka.streams.kstream">Windows</a><W> windows)</span></div> |
| <div class="block">Create a new <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a> instance that can be used to perform windowed aggregations.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>W</code> - the window type</dd> |
| <dt>Parameters:</dt> |
| <dd><code>windows</code> - the specification of the aggregation <a href="Windows.html" title="class in org.apache.kafka.streams.kstream"><code>Windows</code></a></dd> |
| <dt>Returns:</dt> |
| <dd>an instance of <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a></dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="windowedBy(org.apache.kafka.streams.kstream.SlidingWindows)"> |
| <h3>windowedBy</h3> |
| <div class="member-signature"><span class="return-type"><a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream">TimeWindowedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></span> <span class="element-name">windowedBy</span><wbr><span class="parameters">(<a href="SlidingWindows.html" title="class in org.apache.kafka.streams.kstream">SlidingWindows</a> windows)</span></div> |
| <div class="block">Create a new <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a> instance that can be used to perform sliding windowed aggregations.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>windows</code> - the specification of the aggregation <a href="SlidingWindows.html" title="class in org.apache.kafka.streams.kstream"><code>SlidingWindows</code></a></dd> |
| <dt>Returns:</dt> |
| <dd>an instance of <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a></dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="windowedBy(org.apache.kafka.streams.kstream.SessionWindows)"> |
| <h3>windowedBy</h3> |
| <div class="member-signature"><span class="return-type"><a href="SessionWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream">SessionWindowedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr><a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>></span> <span class="element-name">windowedBy</span><wbr><span class="parameters">(<a href="SessionWindows.html" title="class in org.apache.kafka.streams.kstream">SessionWindows</a> windows)</span></div> |
| <div class="block">Create a new <a href="SessionWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>SessionWindowedKStream</code></a> instance that can be used to perform session windowed aggregations.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>windows</code> - the specification of the aggregation <a href="SessionWindows.html" title="class in org.apache.kafka.streams.kstream"><code>SessionWindows</code></a></dd> |
| <dt>Returns:</dt> |
| <dd>an instance of <a href="TimeWindowedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>TimeWindowedKStream</code></a></dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="cogroup(org.apache.kafka.streams.kstream.Aggregator)"> |
| <h3>cogroup</h3> |
| <div class="member-signature"><span class="type-parameters"><VOut></span> <span class="return-type"><a href="CogroupedKStream.html" title="interface in org.apache.kafka.streams.kstream">CogroupedKStream</a><<a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>VOut></span> <span class="element-name">cogroup</span><wbr><span class="parameters">(<a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream">Aggregator</a><? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">K</a>,<wbr>? super <a href="KGroupedStream.html" title="type parameter in KGroupedStream">V</a>,<wbr>VOut> aggregator)</span></div> |
| <div class="block">Create a new <a href="CogroupedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>CogroupedKStream</code></a> from the this grouped KStream to allow cogrouping other |
| <code>KGroupedStream</code> to it. |
| <a href="CogroupedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>CogroupedKStream</code></a> is an abstraction of multiple <i>grouped</i> record streams of <a href="../KeyValue.html" title="class in org.apache.kafka.streams"><code>KeyValue</code></a> pairs. |
| It is an intermediate representation after a grouping of <a href="KStream.html" title="interface in org.apache.kafka.streams.kstream"><code>KStream</code></a>s, before the |
| aggregations are applied to the new partitions resulting in a <a href="KTable.html" title="interface in org.apache.kafka.streams.kstream"><code>KTable</code></a>. |
| <p> |
| The specified <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> is applied in the actual <a href="CogroupedKStream.html#aggregate(org.apache.kafka.streams.kstream.Initializer)"><code>aggregation</code></a> step for each input record and computes a new aggregate using the current aggregate (or for the very |
| first record per key using the initial intermediate aggregation result provided via the <a href="Initializer.html" title="interface in org.apache.kafka.streams.kstream"><code>Initializer</code></a> that |
| is passed into <a href="CogroupedKStream.html#aggregate(org.apache.kafka.streams.kstream.Initializer)"><code>CogroupedKStream.aggregate(Initializer)</code></a>) and the record's value.</div> |
| <dl class="notes"> |
| <dt>Type Parameters:</dt> |
| <dd><code>VOut</code> - the type of the output values</dd> |
| <dt>Parameters:</dt> |
| <dd><code>aggregator</code> - an <a href="Aggregator.html" title="interface in org.apache.kafka.streams.kstream"><code>Aggregator</code></a> that computes a new aggregate result</dd> |
| <dt>Returns:</dt> |
| <dd>a <a href="CogroupedKStream.html" title="interface in org.apache.kafka.streams.kstream"><code>CogroupedKStream</code></a></dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <!-- ========= END OF CLASS DATA ========= --> |
| </main> |
| </div> |
| </div> |
| </body> |
| </html> |