mapValues transforms each stream record’s value while preserving its key. Use it to convert, mask, or otherwise reshape values without triggering the key-changing behavior of map(). section 12.2.1
Convert prices without changing keys
A price stream can apply mapValues((key, value) -> value.price * 100) to convert dollars to cents. Each record keeps its original key while its price value becomes cents. section 12.2.1
Choose mapValues when the value changes but the record identity represented by the key should remain stable:
- Prefer it over map() when only the value changes; changing keys can require repartitioning and cause performance losses. section 12.2.1
- After an average aggregation, use it to expose the calculated average instead of retaining the internal sum and count state. section 12.4.2

