mirror of https://github.com/apache/kafka.git
KQE-289: Replace SerDe with Serde (#11050)
Right now, we have scattered uses of `SerDes` throughout the docs. These should be updated to be `Serdes`, as that's what we commonly use now. Reviewers: Boyang Chen <bchen11@outlook.com>
This commit is contained in:
parent
6fbea5743d
commit
d88989d595
|
@ -55,7 +55,7 @@
|
|||
<div class="section" id="configuring-serdes">
|
||||
<h2>Configuring Serdes<a class="headerlink" href="#configuring-serdes" title="Permalink to this headline"></a></h2>
|
||||
<p>Serdes specified in the Streams configuration are used as the default in your Kafka Streams application.
|
||||
Because this config's default is null, you must either set a default SerDe by using this
|
||||
Because this config's default is null, you must either set a default Serde by using this
|
||||
configuration or pass in Serdes explicitly, as described below.</p>
|
||||
<pre class="line-numbers"><code class="language-java">import org.apache.kafka.common.serialization.Serdes;
|
||||
import org.apache.kafka.streams.StreamsConfig;
|
||||
|
|
|
@ -74,8 +74,8 @@
|
|||
<li><a class="reference internal" href="#scala-dsl" id="id27">Kafka Streams DSL for Scala</a></li>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#scala-dsl-sample-usage" id="id28">Sample Usage</a></li>
|
||||
<li><a class="reference internal" href="#scala-dsl-implicit-serdes" id="id29">Implicit SerDes</a></li>
|
||||
<li><a class="reference internal" href="#scala-dsl-user-defined-serdes" id="id30">User-Defined SerDes</a></li>
|
||||
<li><a class="reference internal" href="#scala-dsl-implicit-serdes" id="id29">Implicit Serdes</a></li>
|
||||
<li><a class="reference internal" href="#scala-dsl-user-defined-serdes" id="id30">User-Defined Serdes</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -254,11 +254,11 @@ KStream<String, Long> wordCounts = builder.stream(
|
|||
Serdes.String(), /* key serde */
|
||||
Serdes.Long() /* value serde */
|
||||
);</code></pre>
|
||||
<p>If you do not specify SerDes explicitly, the default SerDes from the
|
||||
<p>If you do not specify Serdes explicitly, the default Serdes from the
|
||||
<a class="reference internal" href="config-streams.html#streams-developer-guide-configuration"><span class="std std-ref">configuration</span></a> are used.</p>
|
||||
<p>You <strong>must specify SerDes explicitly</strong> if the key or value types of the records in the Kafka input
|
||||
topics do not match the configured default SerDes. For information about configuring default SerDes, available
|
||||
SerDes, and implementing your own custom SerDes see <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a>.</p>
|
||||
<p>You <strong>must specify Serdes explicitly</strong> if the key or value types of the records in the Kafka input
|
||||
topics do not match the configured default Serdes. For information about configuring default Serdes, available
|
||||
Serdes, and implementing your own custom Serdes see <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a>.</p>
|
||||
<p class="last">Several variants of <code class="docutils literal"><span class="pre">stream</span></code> exist. For example, you can specify a regex pattern for input topics to read from (note that all matching topics will be part of the same input topic group, and the work will not be parallelized for different topics if subscribed to in this way).</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -278,11 +278,11 @@ KStream<String, Long> wordCounts = builder.stream(
|
|||
<a class="reference internal" href="../architecture.html#streams_architecture_state"><span class="std std-ref">state store</span></a> that backs the table). This is required for
|
||||
supporting <a class="reference internal" href="interactive-queries.html#streams-developer-guide-interactive-queries"><span class="std std-ref">interactive queries</span></a> against the table. When a
|
||||
name is not provided the table will not be queryable and an internal name will be provided for the state store.</p>
|
||||
<p>If you do not specify SerDes explicitly, the default SerDes from the
|
||||
<p>If you do not specify Serdes explicitly, the default Serdes from the
|
||||
<a class="reference internal" href="config-streams.html#streams-developer-guide-configuration"><span class="std std-ref">configuration</span></a> are used.</p>
|
||||
<p>You <strong>must specify SerDes explicitly</strong> if the key or value types of the records in the Kafka input
|
||||
topics do not match the configured default SerDes. For information about configuring default SerDes, available
|
||||
SerDes, and implementing your own custom SerDes see <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a>.</p>
|
||||
<p>You <strong>must specify Serdes explicitly</strong> if the key or value types of the records in the Kafka input
|
||||
topics do not match the configured default Serdes. For information about configuring default Serdes, available
|
||||
Serdes, and implementing your own custom Serdes see <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a>.</p>
|
||||
<p class="last">Several variants of <code class="docutils literal"><span class="pre">table</span></code> exist, for example to specify the <code class="docutils literal"><span class="pre">auto.offset.reset</span></code> policy to be used when
|
||||
reading from the input topic.</p>
|
||||
</td>
|
||||
|
@ -315,10 +315,10 @@ GlobalKTable<String, Long> wordCounts = builder.globalTable(
|
|||
.withKeySerde(Serdes.String()) /* key serde */
|
||||
.withValueSerde(Serdes.Long()) /* value serde */
|
||||
);</code></pre>
|
||||
<p>You <strong>must specify SerDes explicitly</strong> if the key or value types of the records in the Kafka input
|
||||
topics do not match the configured default SerDes. For information about configuring default SerDes, available
|
||||
SerDes, and implementing your own custom SerDes see <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a>.</p>
|
||||
<p class="last">Several variants of <code class="docutils literal"><span class="pre">globalTable</span></code> exist to e.g. specify explicit SerDes.</p>
|
||||
<p>You <strong>must specify Serdes explicitly</strong> if the key or value types of the records in the Kafka input
|
||||
topics do not match the configured default Serdes. For information about configuring default Serdes, available
|
||||
Serdes, and implementing your own custom Serdes see <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a>.</p>
|
||||
<p class="last">Several variants of <code class="docutils literal"><span class="pre">globalTable</span></code> exist to e.g. specify explicit Serdes.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -518,10 +518,10 @@ stream.foreach(
|
|||
(<a class="reference external" href="/{{version}}/javadoc/org/apache/kafka/streams/kstream/KStream.html#groupByKey--">details</a>)</p>
|
||||
<p>Grouping is a prerequisite for <a class="reference internal" href="#streams-developer-guide-dsl-aggregating"><span class="std std-ref">aggregating a stream or a table</span></a>
|
||||
and ensures that data is properly partitioned (“keyed”) for subsequent operations.</p>
|
||||
<p><strong>When to set explicit SerDes:</strong>
|
||||
Variants of <code class="docutils literal"><span class="pre">groupByKey</span></code> exist to override the configured default SerDes of your application, which <strong>you</strong>
|
||||
<p><strong>When to set explicit Serdes:</strong>
|
||||
Variants of <code class="docutils literal"><span class="pre">groupByKey</span></code> exist to override the configured default Serdes of your application, which <strong>you</strong>
|
||||
<strong>must do</strong> if the key and/or value types of the resulting <code class="docutils literal"><span class="pre">KGroupedStream</span></code> do not match the configured default
|
||||
SerDes.</p>
|
||||
Serdes.</p>
|
||||
<div class="admonition note">
|
||||
<p><b>Note</b></p>
|
||||
<p class="last"><strong>Grouping vs. Windowing:</strong>
|
||||
|
@ -562,10 +562,10 @@ KGroupedStream<byte[], String> groupedStream = stream.groupByKey(
|
|||
<a class="reference external" href="/{{version}}/javadoc/org/apache/kafka/streams/kstream/KTable.html#groupBy-org.apache.kafka.streams.kstream.KeyValueMapper-">KTable details</a>)</p>
|
||||
<p>Grouping is a prerequisite for <a class="reference internal" href="#streams-developer-guide-dsl-aggregating"><span class="std std-ref">aggregating a stream or a table</span></a>
|
||||
and ensures that data is properly partitioned (“keyed”) for subsequent operations.</p>
|
||||
<p><strong>When to set explicit SerDes:</strong>
|
||||
Variants of <code class="docutils literal"><span class="pre">groupBy</span></code> exist to override the configured default SerDes of your application, which <strong>you must</strong>
|
||||
<p><strong>When to set explicit Serdes:</strong>
|
||||
Variants of <code class="docutils literal"><span class="pre">groupBy</span></code> exist to override the configured default Serdes of your application, which <strong>you must</strong>
|
||||
<strong>do</strong> if the key and/or value types of the resulting <code class="docutils literal"><span class="pre">KGroupedStream</span></code> or <code class="docutils literal"><span class="pre">KGroupedTable</span></code> do not match the
|
||||
configured default SerDes.</p>
|
||||
configured default Serdes.</p>
|
||||
<div class="admonition note">
|
||||
<p><b>Note</b></p>
|
||||
<p class="last"><strong>Grouping vs. Windowing:</strong>
|
||||
|
@ -3566,12 +3566,12 @@ groupedTable
|
|||
(<a class="reference external" href="/{{version}}/javadoc/org/apache/kafka/streams/kstream/KStream.html#to(java.lang.String)">KStream details</a>)</p>
|
||||
<p>When to provide serdes explicitly:</p>
|
||||
<ul class="simple">
|
||||
<li>If you do not specify SerDes explicitly, the default SerDes from the
|
||||
<li>If you do not specify Serdes explicitly, the default Serdes from the
|
||||
<a class="reference internal" href="config-streams.html#streams-developer-guide-configuration"><span class="std std-ref">configuration</span></a> are used.</li>
|
||||
<li>You <strong>must specify SerDes explicitly</strong> via the <code class="docutils literal"><span class="pre">Produced</span></code> class if the key and/or value types of the
|
||||
<code class="docutils literal"><span class="pre">KStream</span></code> do not match the configured default SerDes.</li>
|
||||
<li>See <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a> for information about configuring default SerDes, available SerDes,
|
||||
and implementing your own custom SerDes.</li>
|
||||
<li>You <strong>must specify Serdes explicitly</strong> via the <code class="docutils literal"><span class="pre">Produced</span></code> class if the key and/or value types of the
|
||||
<code class="docutils literal"><span class="pre">KStream</span></code> do not match the configured default Serdes.</li>
|
||||
<li>See <a class="reference internal" href="datatypes.html#streams-developer-guide-serdes"><span class="std std-ref">Data Types and Serialization</span></a> for information about configuring default Serdes, available Serdes,
|
||||
and implementing your own custom Serdes.</li>
|
||||
</ul>
|
||||
<p>A variant of <code class="docutils literal"><span class="pre">to</span></code> exists that enables you to specify how the data is produced by using a <code class="docutils literal"><span class="pre">Produced</span></code>
|
||||
instance to specify, for example, a <code class="docutils literal"><span class="pre">StreamPartitioner</span></code> that gives you control over
|
||||
|
@ -3621,7 +3621,7 @@ stream.to("my-stream-output-topic", Produced.with(Serdes.String(), Ser
|
|||
<ol class="last arabic simple">
|
||||
<li><strong>Additional type annotations</strong> - The Java APIs use Java generics in a way that are not fully compatible with the type inferencer of the Scala compiler. Hence the user has to add type annotations to the Scala code, which seems rather non-idiomatic in Scala.</li>
|
||||
<li><strong>Verbosity</strong> - In some cases the Java APIs appear too verbose compared to idiomatic Scala.</li>
|
||||
<li><strong>Type Unsafety</strong> - The Java APIs offer some options where the compile time type safety is sometimes subverted and can result in runtime errors. This stems from the fact that the SerDes defined as part of config are not type checked during compile time. Hence any missing SerDes can result in runtime errors.</li>
|
||||
<li><strong>Type Unsafety</strong> - The Java APIs offer some options where the compile time type safety is sometimes subverted and can result in runtime errors. This stems from the fact that the Serdes defined as part of config are not type checked during compile time. Hence any missing Serdes can result in runtime errors.</li>
|
||||
</ol>
|
||||
<p id="scala-dsl-overview">The Kafka Streams DSL for Scala library is a wrapper over the existing Java APIs for Kafka Streams DSL that addresses the concerns raised above.
|
||||
It does not attempt to provide idiomatic Scala APIs that one would implement in a Scala library developed from scratch. The intention is to make the Java APIs more usable in Scala through better type inferencing, enhanced expressiveness, and lesser boilerplates.
|
||||
|
@ -3648,7 +3648,7 @@ stream.to("my-stream-output-topic", Produced.with(Serdes.String(), Ser
|
|||
<p>The library also has several utility abstractions and modules that the user needs to use for proper semantics.</p>
|
||||
<ul>
|
||||
<li><code class="docutils literal"><span class="pre">org.apache.kafka.streams.scala.ImplicitConversions</span></code>: Module that brings into scope the implicit conversions between the Scala and Java classes.</li>
|
||||
<li><code class="docutils literal"><span class="pre">org.apache.kafka.streams.scala.serialization.Serdes</span></code>: Module that contains all primitive SerDes that can be imported as implicits and a helper to create custom SerDes.</li>
|
||||
<li><code class="docutils literal"><span class="pre">org.apache.kafka.streams.scala.serialization.Serdes</span></code>: Module that contains all primitive Serdes that can be imported as implicits and a helper to create custom Serdes.</li>
|
||||
</ul>
|
||||
<p>The library is cross-built with Scala 2.12 and 2.13. To reference the library compiled against Scala {{scalaVersion}} include the following in your maven <code>pom.xml</code> add the following:</p>
|
||||
<pre class="line-numbers"><code class="language-xml"><dependency>
|
||||
|
@ -3698,15 +3698,15 @@ object WordCountApplication extends App {
|
|||
streams.close(Duration.ofSeconds(10))
|
||||
}
|
||||
}</code></pre>
|
||||
<p>In the above code snippet, we don't have to provide any SerDes, <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> explicitly. They will also not be dependent on any SerDes specified in the config. <strong>In fact all SerDes specified in the config will be ignored by the Scala APIs</strong>. All SerDes and <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> will be handled through implicit SerDes as discussed later in the <a href="#scala-dsl-implicit-serdes">Implicit SerDes</a> section. The complete independence from configuration based SerDes is what makes this library completely typesafe. Any missing instances of SerDes, <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> will be flagged as a compile time error.</p>
|
||||
<p>In the above code snippet, we don't have to provide any Serdes, <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> explicitly. They will also not be dependent on any Serdes specified in the config. <strong>In fact all Serdes specified in the config will be ignored by the Scala APIs</strong>. All Serdes and <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> will be handled through implicit Serdes as discussed later in the <a href="#scala-dsl-implicit-serdes">Implicit Serdes</a> section. The complete independence from configuration based Serdes is what makes this library completely typesafe. Any missing instances of Serdes, <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> will be flagged as a compile time error.</p>
|
||||
</div>
|
||||
<div class="section" id="scala-dsl-implicit-serdes">
|
||||
<span id="streams-developer-guide-dsl-scala-dsl-implicit-serdes"></span><h3><a class="toc-backref" href="#id29">Implicit SerDes</a><a class="headerlink" href="#scala-dsl-implicit-serdes" title="Permalink to this headline"></a></h3>
|
||||
<p>One of the common complaints of Scala users with the Java API has been the repetitive usage of the SerDes in API invocations. Many of the APIs need to take the SerDes through abstractions like <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Repartitioned</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code>. And the user has to supply them every time through the with function of these classes.</p>
|
||||
<p>The library uses the power of <a href="https://docs.scala-lang.org/tour/implicit-parameters.html">Scala implicit parameters</a> to alleviate this concern. As a user you can provide implicit SerDes or implicit values of <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Repartitioned</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> once and make your code less verbose. In fact you can just have the implicit SerDes in scope and the library will make the instances of <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> available in scope.</p>
|
||||
<p>The library also bundles all implicit SerDes of the commonly used primitive types in a Scala module - so just import the module vals and have all SerDes in scope. A similar strategy of modular implicits can be adopted for any user-defined SerDes as well (User-defined SerDes are discussed in the next section).</p>
|
||||
<span id="streams-developer-guide-dsl-scala-dsl-implicit-serdes"></span><h3><a class="toc-backref" href="#id29">Implicit Serdes</a><a class="headerlink" href="#scala-dsl-implicit-serdes" title="Permalink to this headline"></a></h3>
|
||||
<p>One of the common complaints of Scala users with the Java API has been the repetitive usage of the Serdes in API invocations. Many of the APIs need to take the Serdes through abstractions like <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Repartitioned</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code>. And the user has to supply them every time through the with function of these classes.</p>
|
||||
<p>The library uses the power of <a href="https://docs.scala-lang.org/tour/implicit-parameters.html">Scala implicit parameters</a> to alleviate this concern. As a user you can provide implicit Serdes or implicit values of <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Repartitioned</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> once and make your code less verbose. In fact you can just have the implicit Serdes in scope and the library will make the instances of <code class="docutils literal"><span class="pre">Grouped</span></code>, <code class="docutils literal"><span class="pre">Produced</span></code>, <code class="docutils literal"><span class="pre">Consumed</span></code> or <code class="docutils literal"><span class="pre">Joined</span></code> available in scope.</p>
|
||||
<p>The library also bundles all implicit Serdes of the commonly used primitive types in a Scala module - so just import the module vals and have all Serdes in scope. A similar strategy of modular implicits can be adopted for any user-defined Serdes as well (User-defined Serdes are discussed in the next section).</p>
|
||||
<p>Here's an example:</p>
|
||||
<pre class="line-numbers"><code class="language-scala">// DefaultSerdes brings into scope implicit SerDes (mostly for primitives)
|
||||
<pre class="line-numbers"><code class="language-scala">// DefaultSerdes brings into scope implicit Serdes (mostly for primitives)
|
||||
// that will set up all Grouped, Produced, Consumed and Joined instances.
|
||||
// So all APIs below that accept Grouped, Produced, Consumed or Joined will
|
||||
// get these instances automatically
|
||||
|
@ -3720,7 +3720,7 @@ val userRegionsTable: KTable[String, String] = builder.table(userRegionsTopic)
|
|||
|
||||
// The following code fragment does not have a single instance of Grouped,
|
||||
// Produced, Consumed or Joined supplied explicitly.
|
||||
// All of them are taken care of by the implicit SerDes imported by DefaultSerdes
|
||||
// All of them are taken care of by the implicit Serdes imported by DefaultSerdes
|
||||
val clicksPerRegion: KTable[String, Long] =
|
||||
userClicksStream
|
||||
.leftJoin(userRegionsTable)((clicks, region) => (if (region == null) "UNKNOWN" else region, clicks))
|
||||
|
@ -3731,15 +3731,15 @@ val clicksPerRegion: KTable[String, Long] =
|
|||
clicksPerRegion.toStream.to(outputTopic)</code></pre>
|
||||
<p>Quite a few things are going on in the above code snippet that may warrant a few lines of elaboration:</p>
|
||||
<ol>
|
||||
<li>The code snippet does not depend on any config defined SerDes. In fact any SerDes defined as part of the config will be ignored.</li>
|
||||
<li>All SerDes are picked up from the implicits in scope. And <code class="docutils literal"><span class="pre">import Serdes._</span></code> brings all necessary SerDes in scope.</li>
|
||||
<li>The code snippet does not depend on any config defined Serdes. In fact any Serdes defined as part of the config will be ignored.</li>
|
||||
<li>All Serdes are picked up from the implicits in scope. And <code class="docutils literal"><span class="pre">import Serdes._</span></code> brings all necessary Serdes in scope.</li>
|
||||
<li>This is an example of compile time type safety that we don't have in the Java APIs.</li>
|
||||
<li>The code looks less verbose and more focused towards the actual transformation that it does on the data stream.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="scala-dsl-user-defined-serdes">
|
||||
<span id="streams-developer-guide-dsl-scala-dsl-user-defined-serdes"></span><h3><a class="toc-backref" href="#id30">User-Defined SerDes</a><a class="headerlink" href="#scala-dsl-user-defined-serdes" title="Permalink to this headline"></a></h3>
|
||||
<p>When the default primitive SerDes are not enough and we need to define custom SerDes, the usage is exactly the same as above. Just define the implicit SerDes and start building the stream transformation. Here's an example with <code class="docutils literal"><span class="pre">AvroSerde</span></code>:</p>
|
||||
<span id="streams-developer-guide-dsl-scala-dsl-user-defined-serdes"></span><h3><a class="toc-backref" href="#id30">User-Defined Serdes</a><a class="headerlink" href="#scala-dsl-user-defined-serdes" title="Permalink to this headline"></a></h3>
|
||||
<p>When the default primitive Serdes are not enough and we need to define custom Serdes, the usage is exactly the same as above. Just define the implicit Serdes and start building the stream transformation. Here's an example with <code class="docutils literal"><span class="pre">AvroSerde</span></code>:</p>
|
||||
<pre class="line-numbers"><code class="language-scala">// domain object as a case class
|
||||
case class UserClicks(clicks: Long)
|
||||
|
||||
|
@ -3747,7 +3747,7 @@ case class UserClicks(clicks: Long)
|
|||
// serialize as avro
|
||||
implicit val userClicksSerde: Serde[UserClicks] = new AvroSerde
|
||||
|
||||
// Primitive SerDes
|
||||
// Primitive Serdes
|
||||
import Serdes._
|
||||
|
||||
// And then business as usual ..
|
||||
|
@ -3772,7 +3772,7 @@ val clicksPerRegion: KTable[String, Long] =
|
|||
|
||||
// Write the (continuously updating) results to the output topic.
|
||||
clicksPerRegion.toStream.to(outputTopic)</code></pre>
|
||||
<p>A complete example of user-defined SerDes can be found in a test class within the library.</p>
|
||||
<p>A complete example of user-defined Serdes can be found in a test class within the library.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -777,7 +777,7 @@
|
|||
Kafka Streams DSL for Scala is a new Kafka Streams client library available for developers authoring Kafka Streams applications in Scala. It wraps core Kafka Streams DSL types to make it easier to call when
|
||||
interoperating with Scala code. For example, it includes higher order functions as parameters for transformations avoiding the need anonymous classes in Java 7 or experimental SAM type conversions in Scala 2.11,
|
||||
automatic conversion between Java and Scala collection types, a way
|
||||
to implicitly provide SerDes to reduce boilerplate from your application and make it more typesafe, and more! For more information see the
|
||||
to implicitly provide Serdes to reduce boilerplate from your application and make it more typesafe, and more! For more information see the
|
||||
<a href="/{{version}}/documentation/streams/developer-guide/dsl-api.html#scala-dsl">Kafka Streams DSL for Scala documentation</a> and
|
||||
<a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-270+-+A+Scala+Wrapper+Library+for+Kafka+Streams">KIP-270</a>.
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue