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(
scala> :type storeBuilder

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.

Logging is enabled by default.

Creating KeyValueStoreBuilder Instance

KeyValueStoreBuilder takes the following when created:

Building KeyValueStore — build Method

KeyValueStore<K, V> build()
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.

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.

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

results matching ""

    No results matching ""