am new to this topic and I am trying to learn so my question might have been a bit confusing. What my question actually is: I have a stream of data coming in the form of tuple [Country, state, person]. now on this stream of data, I want to perform the operation of calculating the average number of people in the state. I though of doing it by taking the Key as [Country, State]. for every unique tuple, a hash function updates a bucket which contains the count.
For Eg: If I have a tuple [USA, Ohio, person1], then when this comes in bucket 2 is updated, and every time the tuple with USA and Ohio comes in, this count keeps increasing. this would give me the total number of people who are from USA-Ohio, but I am confused on how to find the average of it i.e the average number of people who belong to [USA,Ohio]. I hope this cleared up things a bit.