@InterfaceStability.Evolving public class Stores extends java.lang.Object
When using the high-level DSL, i.e., StreamsBuilder, users create
StoreSuppliers that can be further customized via
Materialized.
For example, a topic read as KTable can be materialized into an
in-memory store with custom key/value serdes and caching disabled:
StreamsBuilder builder = new StreamsBuilder();
KeyValueBytesStoreSupplier storeSupplier = Stores.inMemoryKeyValueStore("queryable-store-name");
KTable<Long,String> table = builder.table(
"topicName",
Materialized.as(storeSupplier)
.withKeySerde(Serdes.Long())
.withValueSerde(Serdes.String())
.withCachingDisabled());
When using the Processor API, i.e., Topology, users create
StoreBuilders that can be attached to Processors.
For example, you can create a windowed RocksDB store with custom
changelog topic configuration like:
Topology topology = new Topology();
topology.addProcessor("processorName", ...);
Map<String,String> topicConfig = new HashMap<>();
StoreBuilder<WindowStore<Integer, Long>> storeBuilder = Stores
.windowStoreBuilder(
Stores.persistentWindowStore("queryable-store-name", ...),
Serdes.Integer(),
Serdes.Long())
.withLoggingEnabled(topicConfig);
topology.addStateStore(storeBuilder, "processorName");
| Modifier and Type | Class and Description |
|---|---|
static interface |
Stores.InMemoryKeyValueFactory<K,V>
Deprecated.
|
static interface |
Stores.KeyValueFactory<K,V> |
static interface |
Stores.PersistentKeyValueFactory<K,V>
Deprecated.
|
static class |
Stores.StoreFactory |
static class |
Stores.ValueFactory<K>
The factory for creating off-heap key-value stores.
|
| Constructor and Description |
|---|
Stores() |
| Modifier and Type | Method and Description |
|---|---|
static Stores.StoreFactory |
create(java.lang.String name)
|
static KeyValueBytesStoreSupplier |
inMemoryKeyValueStore(java.lang.String name)
Create an in-memory
KeyValueBytesStoreSupplier. |
static <K,V> StoreBuilder<KeyValueStore<K,V>> |
keyValueStoreBuilder(KeyValueBytesStoreSupplier supplier,
Serde<K> keySerde,
Serde<V> valueSerde)
Creates a
StoreBuilder than can be used to build a KeyValueStore. |
static KeyValueBytesStoreSupplier |
lruMap(java.lang.String name,
int maxCacheSize)
Create a LRU Map
KeyValueBytesStoreSupplier. |
static KeyValueBytesStoreSupplier |
persistentKeyValueStore(java.lang.String name)
Create a persistent
KeyValueBytesStoreSupplier. |
static SessionBytesStoreSupplier |
persistentSessionStore(java.lang.String name,
long retentionPeriod)
Create a persistent
SessionBytesStoreSupplier. |
static WindowBytesStoreSupplier |
persistentWindowStore(java.lang.String name,
long retentionPeriod,
int numSegments,
long windowSize,
boolean retainDuplicates)
Create a persistent
WindowBytesStoreSupplier. |
static <K,V> StoreBuilder<SessionStore<K,V>> |
sessionStoreBuilder(SessionBytesStoreSupplier supplier,
Serde<K> keySerde,
Serde<V> valueSerde)
Creates a
StoreBuilder that can be used to build a SessionStore. |
static <K,V> StoreBuilder<WindowStore<K,V>> |
windowStoreBuilder(WindowBytesStoreSupplier supplier,
Serde<K> keySerde,
Serde<V> valueSerde)
Creates a
StoreBuilder that can be used to build a WindowStore. |
public static KeyValueBytesStoreSupplier persistentKeyValueStore(java.lang.String name)
KeyValueBytesStoreSupplier.name - name of the storeKeyValueBytesStoreSupplier that can be used
to build a persistent storepublic static KeyValueBytesStoreSupplier inMemoryKeyValueStore(java.lang.String name)
KeyValueBytesStoreSupplier.name - name of the storeKeyValueBytesStoreSupplier than can be used to
build an in-memory storepublic static KeyValueBytesStoreSupplier lruMap(java.lang.String name, int maxCacheSize)
KeyValueBytesStoreSupplier.name - name of the storemaxCacheSize - maximum number of items in the LRUKeyValueBytesStoreSupplier that can be used to build
an LRU Map based storepublic static WindowBytesStoreSupplier persistentWindowStore(java.lang.String name, long retentionPeriod, int numSegments, long windowSize, boolean retainDuplicates)
WindowBytesStoreSupplier.name - name of the storeretentionPeriod - length of time to retain data in the storenumSegments - number of db segmentswindowSize - size of the windowsretainDuplicates - whether or not to retain duplicates.WindowBytesStoreSupplierpublic static SessionBytesStoreSupplier persistentSessionStore(java.lang.String name, long retentionPeriod)
SessionBytesStoreSupplier.name - name of the storeretentionPeriod - length ot time to retain data in the storeSessionBytesStoreSupplierpublic static <K,V> StoreBuilder<WindowStore<K,V>> windowStoreBuilder(WindowBytesStoreSupplier supplier, Serde<K> keySerde, Serde<V> valueSerde)
StoreBuilder that can be used to build a WindowStore.K - key typeV - value typesupplier - a WindowBytesStoreSupplierkeySerde - the key serde to usevalueSerde - the value serde to useStoreBuilder than can build a WindowStorepublic static <K,V> StoreBuilder<KeyValueStore<K,V>> keyValueStoreBuilder(KeyValueBytesStoreSupplier supplier, Serde<K> keySerde, Serde<V> valueSerde)
StoreBuilder than can be used to build a KeyValueStore.K - key typeV - value typesupplier - a KeyValueBytesStoreSupplierkeySerde - the key serde to usevalueSerde - the value serde to useStoreBuilder that can build a KeyValueStorepublic static <K,V> StoreBuilder<SessionStore<K,V>> sessionStoreBuilder(SessionBytesStoreSupplier supplier, Serde<K> keySerde, Serde<V> valueSerde)
StoreBuilder that can be used to build a SessionStore.K - key typeV - value typesupplier - a SessionBytesStoreSupplierkeySerde - the key serde to usevalueSerde - the value serde to useStoreBuilder than can build a SessionStore@Deprecated public static Stores.StoreFactory create(java.lang.String name)
persistentKeyValueStore(String), persistentWindowStore(String, long, int, long, boolean)
persistentSessionStore(String, long), lruMap(String, int), or inMemoryKeyValueStore(String)StateStoreSupplier instance.name - the name of the store