blob: b72b747d32ff0a5823511929584000b0e8a68ba3 [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_402) on Mon Apr 15 02:01:51 UTC 2024 -->
<title>TestGroupState (Spark 3.4.3 JavaDoc)</title>
<meta name="date" content="2024-04-15">
<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="TestGroupState (Spark 3.4.3 JavaDoc)";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6,"i2":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 class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/spark/sql/streaming/StreamingQueryStatus.html" title="class in org.apache.spark.sql.streaming"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/spark/sql/streaming/Trigger.html" title="class in org.apache.spark.sql.streaming"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/spark/sql/streaming/TestGroupState.html" target="_top">Frames</a></li>
<li><a href="TestGroupState.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 class="header">
<div class="subTitle">org.apache.spark.sql.streaming</div>
<h2 title="Interface TestGroupState" class="title">Interface TestGroupState&lt;S&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>S</code> - User-defined type of the state to be stored for each group. Must be encodable into
Spark SQL types (see <code>Encoder</code> for more details).</dd>
</dl>
<dl>
<dt>All Superinterfaces:</dt>
<dd><a href="../../../../../org/apache/spark/sql/streaming/GroupState.html" title="interface in org.apache.spark.sql.streaming">GroupState</a>&lt;S&gt;, org.apache.spark.sql.catalyst.plans.logical.LogicalGroupState&lt;S&gt;</dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">TestGroupState&lt;S&gt;</span>
extends <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html" title="interface in org.apache.spark.sql.streaming">GroupState</a>&lt;S&gt;</pre>
<div class="block">:: Experimental ::
<p>
The extended version of <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html" title="interface in org.apache.spark.sql.streaming"><code>GroupState</code></a> interface with extra getters of state machine fields
to improve testability of the <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html" title="interface in org.apache.spark.sql.streaming"><code>GroupState</code></a> implementations
which inherit from the extended interface.
<p>
Scala example of using <code>TestGroupState</code>:
<pre><code>
// Please refer to ScalaDoc of `GroupState` for the Scala definition of `mappingFunction()`
import org.apache.spark.api.java.Optional
import org.apache.spark.sql.streaming.GroupStateTimeout
import org.apache.spark.sql.streaming.TestGroupState
// other imports
// test class setups
test("MapGroupsWithState state transition function") {
// Creates the prevState input for the state transition function
// with desired configs. The `create()` API would guarantee that
// the generated instance has the same behavior as the one built by
// engine with the same configs.
val prevState = TestGroupState.create[Int](
optionalState = Optional.empty[Int],
timeoutConf = NoTimeout,
batchProcessingTimeMs = 1L,
eventTimeWatermarkMs = Optional.of(1L),
hasTimedOut = false)
val key: String = ...
val values: Iterator[Int] = ...
// Asserts the prevState is in init state without updates.
assert(!prevState.isUpdated)
// Calls the state transition function with the test previous state
// with desired configs.
mappingFunction(key, values, prevState)
// Asserts the test GroupState object has been updated but not removed
// after calling the state transition function
assert(prevState.isUpdated)
assert(!prevState.isRemoved)
}
</code></pre>
<p>
Java example of using <code>TestGroupSate</code>:
<pre><code>
// Please refer to ScalaDoc of `GroupState` for the Java definition of `mappingFunction()`
import org.apache.spark.api.java.Optional;
import org.apache.spark.sql.streaming.GroupStateTimeout;
import org.apache.spark.sql.streaming.TestGroupState;
// other imports
// test class setups
// test `MapGroupsWithState` state transition function `mappingFunction()`
public void testMappingFunctionWithTestGroupState() {
// Creates the prevState input for the state transition function
// with desired configs. The `create()` API would guarantee that
// the generated instance has the same behavior as the one built by
// engine with the same configs.
TestGroupState&lt;Int&gt; prevState = TestGroupState.create(
Optional.empty(),
GroupStateTimeout.NoTimeout(),
1L,
Optional.of(1L),
false);
String key = ...;
Integer[] values = ...;
// Asserts the prevState is in init state without updates.
Assert.assertFalse(prevState.isUpdated());
// Calls the state transition function with the test previous state
// with desired configs.
mappingFunction.call(key, Arrays.asList(values).iterator(), prevState);
// Asserts the test GroupState object has been updated but not removed
// after calling the state transition function
Assert.assertTrue(prevState.isUpdated());
Assert.assertFalse(prevState.isRemoved());
}
</code></pre>
<p></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>3.2.0</dd>
</dl>
</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="../../../../../org/apache/spark/api/java/Optional.html" title="class in org.apache.spark.api.java">Optional</a>&lt;Object&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/spark/sql/streaming/TestGroupState.html#getTimeoutTimestampMs--">getTimeoutTimestampMs</a></span>()</code>
<div class="block">Returns the timestamp if <code>setTimeoutTimestamp()</code> is called.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/spark/sql/streaming/TestGroupState.html#isRemoved--">isRemoved</a></span>()</code>
<div class="block">Whether the state has been marked for removing</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/spark/sql/streaming/TestGroupState.html#isUpdated--">isUpdated</a></span>()</code>
<div class="block">Whether the state has been updated but not removed</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.org.apache.spark.sql.streaming.GroupState">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;org.apache.spark.sql.streaming.<a href="../../../../../org/apache/spark/sql/streaming/GroupState.html" title="interface in org.apache.spark.sql.streaming">GroupState</a></h3>
<code><a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#exists--">exists</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#get--">get</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#getCurrentProcessingTimeMs--">getCurrentProcessingTimeMs</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#getCurrentWatermarkMs--">getCurrentWatermarkMs</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#getOption--">getOption</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#hasTimedOut--">hasTimedOut</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#remove--">remove</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#setTimeoutDuration-long-">setTimeoutDuration</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#setTimeoutDuration-java.lang.String-">setTimeoutDuration</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#setTimeoutTimestamp-java.sql.Date-">setTimeoutTimestamp</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#setTimeoutTimestamp-java.sql.Date-java.lang.String-">setTimeoutTimestamp</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#setTimeoutTimestamp-long-">setTimeoutTimestamp</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#setTimeoutTimestamp-long-java.lang.String-">setTimeoutTimestamp</a>, <a href="../../../../../org/apache/spark/sql/streaming/GroupState.html#update-S-">update</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="isRemoved--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isRemoved</h4>
<pre>boolean&nbsp;isRemoved()</pre>
<div class="block">Whether the state has been marked for removing</div>
</li>
</ul>
<a name="isUpdated--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isUpdated</h4>
<pre>boolean&nbsp;isUpdated()</pre>
<div class="block">Whether the state has been updated but not removed</div>
</li>
</ul>
<a name="getTimeoutTimestampMs--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getTimeoutTimestampMs</h4>
<pre><a href="../../../../../org/apache/spark/api/java/Optional.html" title="class in org.apache.spark.api.java">Optional</a>&lt;Object&gt;&nbsp;getTimeoutTimestampMs()</pre>
<div class="block">Returns the timestamp if <code>setTimeoutTimestamp()</code> is called.
Or, returns batch processing time + the duration when
<code>setTimeoutDuration()</code> is called.
<p>
Otherwise, returns <code>Optional.empty</code> if not set.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>(undocumented)</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/spark/sql/streaming/StreamingQueryStatus.html" title="class in org.apache.spark.sql.streaming"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/spark/sql/streaming/Trigger.html" title="class in org.apache.spark.sql.streaming"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/spark/sql/streaming/TestGroupState.html" target="_top">Frames</a></li>
<li><a href="TestGroupState.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 ======= -->
<script defer="defer" type="text/javascript" src="../../../../../lib/jquery.js"></script><script defer="defer" type="text/javascript" src="../../../../../lib/api-javadocs.js"></script></body>
</html>