KeyValueStoreBuilder

KeyValueStoreBuilder is a StoreBuilder (indirectly as a AbstractStoreBuilder) that allows for building KeyValueStores.

KeyValueStoreBuilder can be created using Stores.keyValueStoreBuilder.

import org.apache.kafka.streams.state.Stores
// Using Scala API for Kafka Streams
import org.apache.kafka.streams.scala.Serdes
val storeBuilder = Stores.keyValueStoreBuilder(
  Stores.inMemoryKeyValueStore("store-name"),
  Serdes.Integer,
  Serdes.Long)
scala> :type storeBuilder
org.apache.kafka.streams.state.StoreBuilder[org.apache.kafka.streams.state.KeyValueStore[Int,Long]]

import org.apache.kafka.streams.state.internals.KeyValueStoreBuilder
assert(storeBuilder.isInstanceOf[KeyValueStoreBuilder[_, _]])

When requested for a state store, KeyValueStoreBuilder creates a new MeteredKeyValueBytesStore (with the state store from the KeyValueBytesStoreSupplier).

With caching enabled, build creates a CachingKeyValueStore.

Note
Logging is enabled by default.

Creating KeyValueStoreBuilder Instance

KeyValueStoreBuilder takes the following when created:

Building KeyValueStore — build Method

KeyValueStore<K, V> build()
Note
build is part of the StoreBuilder Contract to build a state store.

build first requests the KeyValueBytesStoreSupplier for a StateStore.

maybeWrapLogging Internal Method

KeyValueStore<Bytes, byte[]> maybeWrapLogging(
  KeyValueStore<Bytes, byte[]> inner)

maybeWrapLogging simply returns the given inner KeyValueStore with logging disabled.

Otherwise, with logging enabled, maybeWrapLogging creates a ChangeLoggingKeyValueBytesStore.

Note
maybeWrapLogging is used exclusively when KeyValueStoreBuilder is requested to build a KeyValueStore.

maybeWrapCaching Internal Method

KeyValueStore<Bytes, byte[]> maybeWrapCaching(
  KeyValueStore<Bytes, byte[]> inner)

maybeWrapCaching simply returns the given inner KeyValueStore with caching disabled.

Otherwise, with caching enabled, maybeWrapCaching creates a CachingKeyValueStore.

Note
maybeWrapCaching is used exclusively when KeyValueStoreBuilder is requested to build a KeyValueStore.

results matching ""

    No results matching ""