concept Purchase object in category kafka

This is an excerpt from Manning's book Kafka Streams in Action: Real-time apps and microservices with the Kafka Streams API.
The next processor to create is one that can capture information necessary for determining purchase patterns in different regions of the country (figure 1.12). To do this, you’ll add a child-processing node to the first processor (KStream) you created. The first processor produces Purchase objects with the credit card number masked.
Figure 1.12. The purchase-pattern processor takes Purchase objects and converts them into PurchasePattern objects containing the items purchased and the ZIP code where the transaction took place. A new processor takes records from the patterns processor and writes them out to a Kafka topic.
![]()
The purchase-patterns processor receives a Purchase object from its parent node and maps the object to a new PurchasePattern object. The mapping process extracts the item purchased (toothpaste, for example) and the ZIP code it was bought in and uses that information to create the PurchasePattern object. We’ll go over exactly how this mapping process occurs in chapter 3.
The updated rules for the purchase program are simple. The customer earns a point per dollar, and transaction totals are rounded down to the nearest dollar. The overall structure of the topology won’t change, but the rewards-processing node will change from using the KStream.mapValues() method to using KStream.transformValues(). Semantically, these two methods operate the same way, in that you still map the Purchase object into a RewardAccumulator object. The difference lies in the ability to use local state to perform the transformation.
Now that you’ve initialized the processor, you can move on to transforming a Purchase object using state. A few simple steps for performing the transformation are as follows: