Browse Source

Add explicit grace period to tumbling window example (#8520)

pull/6649/merge
Liam Clarke-Hutchinson 5 years ago committed by GitHub
parent
commit
7004fc22db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      docs/streams/developer-guide/dsl-api.html

8
docs/streams/developer-guide/dsl-api.html

@ -3262,12 +3262,14 @@ become t=300,000).</span></p> @@ -3262,12 +3262,14 @@ become t=300,000).</span></p>
<span class="kn">import</span> <span class="nn">org.apache.kafka.streams.kstream.TimeWindows</span><span class="o">;</span>
<span class="c1">// A tumbling time window with a size of 5 minutes (and, by definition, an implicit</span>
<span class="c1">// advance interval of 5 minutes).</span>
<span class="c1">// advance interval of 5 minutes). Note the explicit grace period, as the current</span>
<span class="c1">// default value is 24 hours, which may be larger than needed for smaller windows. </span>
<span class="kt">Duration</span> <span class="n">windowSizeMs</span> <span class="o">=</span> <span class="n">Duration</span><span class="o">.</span><span class="na">ofMinutes</span><span class="o">(</span><span class="mi">5</span><span class="o">);</span>
<span class="n">TimeWindows</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="n">windowSizeMs</span><span class="o">);</span>
<span class="kt">Duration</span> <span class="n">gracePeriodMs</span> <span class="o">=</span> <span class="n">Duration</span><span class="o">.</span><span class="na">ofMinutes</span><span class="o">(</span><span class="mi">1</span><span class="o">);</span>
<span class="n">TimeWindows</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="n">windowSizeMs</span><span class="o">).</span><span class="na">grace</span><span class="o">(</span><span class="n">gracePeriodMs</span><span class="o">);</span>
<span class="c1">// The above is equivalent to the following code:</span>
<span class="n">TimeWindows</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="n">windowSizeMs</span><span class="o">).</span><span class="na">advanceBy</span><span class="o">(</span><span class="n">windowSizeMs</span><span class="o">);</span>
<span class="n">TimeWindows</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="n">windowSizeMs</span><span class="o">).</span><span class="na">advanceBy</span><span class="o">(</span><span class="n">windowSizeMs</span><span class="o">).</span><span class="na">grace</span><span class="o">(</span><span class="n">gracePeriodMs</span><span class="o">);</span>
</pre></div>
</div>
</div>

Loading…
Cancel
Save