title: Kafka stream - how to group by twice?
body: <p>I want to create a bar graph showing how many pixel colors there are in an image; the image gets updated every 3 seconds, hence my bar graph updates too.</p>
  
  <p>I have a topic which collects JSON objects which has it's key as the image creation date, and the value is the hex value (e.g #FFF).</p>
  
  <p>I want to group by the key, so it's group by images, and then group by hex values for each of the group and do a .count().</p>
  
  <p>How do you do that?</p>
  
  <p>I was thinking streams.groupByKey()... then groupBy by hex value but I need to convert the KTable to KStream...</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Sorry at my lack of explanation as I was typing it on my phone.
  I'm going to try and explain again.</p>
  
  <p>By the way I change some stuff. Here is my github if you want to read what I am doing: <a href="https://github.com/Lilmortal" rel="nofollow noreferrer">https://github.com/Lilmortal</a>.</p>
  
  <ul>
  <li>My project "HexGraph-source-connector" picks up any images in a
  specified directory and push the image path to a topic.</li>
  <li>"HexGraph" project picks it up, and using Akka, the actors will get
  all the pixel hex codes individually and start to push the messages
  to another topic.</li>
  <li>"HexGraph-stream" is my kafka stream part.</li>
  </ul>
  
  <p>But it's quite long, I doubt you will read it lol.</p>
  
  <p>Anyways I read from a topic, I get messages like this {imagePath: {hexCode: #fff}}.
  The image path is the key, the hexCode is the value. I can have one to many imagePaths, so my idea is that my front end will have a websocket that will pick it up. It will display an image, and there is a bar graph on top of it which have the amount of pixel color codes. e.g. there are 4 #fff, 28 #fef, etc.</p>
  
  <p>Hence I want to group by the imagePath, and then I want to count each pixels for that imagePath.</p>
  
  <p>For example:</p>
  
  <ul>
  <li>{imagePath1: {hexCode: #fff, count: 47}}</li>
  <li>{imagePath1: {hexCode: #fef, count: 61}}</li>
  <li>{imagePath2: {hexCode: #fff, count: 23}}</li>
  <li>{imagePath2: {hexCode: #fef, count: 55}}</li>
  </ul>
  
  <p>So here imagePath1 have 47 #fff, and imagePath2 have 23 #fff.</p>
  
  <p>That's what I am trying to do atm.</p>