mapValues
mapValues is an operation that transforms values associated with keys while preserving those keys.
Kafka Streams in Action, Second Edition
KStream.mapValues is a Kafka Streams operation that maps each record value to a new value while retaining the record key.
- How it is used
- Transforms incoming record values as a processing node between a KStream source and downstream operations.
- How deep it goes
- Defines mapper interfaces, key-preservation behavior, and topology placement, while deferring lambda-expression instruction to external documentation.
- Examples
- Demonstrates uppercasing text, masking RetailPurchase credit-card numbers, and converting proximity readings from feet to meters.
- What you can do after
- Apply it via Kafka Streams to transform each record value while retaining its existing key.
Read how Kafka Streams in Action, Second Edition explains mapValues →
Apache Kafka in Action
mapValues is a stream-processing function that transforms record values while preserving their keys.
- How it is used
- Transforms stream values for conversion, masking, and reshaping while preserving record keys.
- How deep it goes
- Defines value-only transformation, demonstrates price conversion, and explains repartitioning consequences without detailing processor internals.
- Examples
- Demonstrates converting prices from dollars to cents and projecting averages from aggregate state.
- What you can do after
- Apply via Kafka Streams to transform values without changing keys or unnecessarily causing repartitioning.
Related concepts
- processing nodeproduces · A processing node is a stream-processing component in a topology that processes records using logic such as filtering, aggregation, or transformation.
- mapalternative to · An operation that applies a function to values in a collection or computational context, producing corresponding results while preserving the collection or context’s structure.
- Mapuses · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

