Currently we use the following in our Kafka Streams application:
streamsBuilder.table(inputTopic)
.join(...)
.mapValues(valueMapper) // <-- this causes another state store
.groupBy(...)
.aggregate(...)
.mapValues(...)
[...]
.toStream()
.to(outputTopic)
and I just realized, that the mapValues after the join creates an additional state store.
If the calculation in valueMapper is somehow trivial (e.g. remove a field in an object etc), would it not be better to avoid the additional statestore? Do I need to convert to a KStream and use KStream.mapValues to avoid a stateStore, i.e.
streamsBuilder.table(inputTopic)
.join(...)
.toStream
.mapValues(valueMapper) // <-- no more additional statestore
.groupBy(...)
.aggregate(...)
.mapValues(...)
[...]
.toStream()
.to(outputTopic)
or is there a better alternative to apply additonal mapping after a join?