concept custom partitioner 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.
Why would you want to write a custom partitioner? Of the several possible reasons, we’ll look at one simple case here—the use of composite keys.
Suppose you have purchase data flowing into Kafka, and the keys contain two values: a customer ID and a transaction date. But you need to group values by customer ID, so taking a hash of the customer ID and the purchase date won’t work. In this case, you’ll need to write a custom partitioner that knows which part of the composite key determines which partition to use. For example, the composite key found in src/main/java/bbejeck/model/PurchaseKey.java (source code can be found on the book’s website here: https://manning.com/books/kafka-streams-in-action) is shown in the following listing.