I want grouped messages by groupId and then get all possible combinations in each group. For example for groupId=1 combinations: id:1-id:2, id:1-id:3, id:2-id:3.
I would like to thank you for your books.
They were fascinating to read! Please keep writing.
I don’t quite understand the point about swap key and value.
Initially I get a message with an empty key or with a key by id field.
If I swap key and value, then as a key I have a string representation of message object, and as a key a string value of message ID field:
key: {MessageClass{id=1, groupId: 1}
value: 1
Then I won’t be able to get the groups. Maybe I got something wrong?
If I choose groupId as a key, and then in the aggregate method I add values to a special class, within which the combinatorial logic will be implemented. Will such a method work?
I get what you’re saying here; I didn’t realize before the key was a composite that contained the groupId, but I’d still stick with my original advice with a small twist. When you call the map function, I would extract the groupId for the key and make a new value object containing the original value and the id from the old key.
I guess that’s what you’re saying here:
If I choose groupId as a key, and then in the aggregate method I add values to a special class, within which the combinatorial logic will be implemented.