Hi Rustaceans,
I'm using a HashMap for counting items over a data stream, i.e., every time I see an element, I look up the element in the HashMap and increment the value and after a certain time period I decrement the value with the same procedure. All of this is happening in a single thread.
Currently I'm hashing twice, once for incrementing and once for decrementing counts for elements. As I am using the Entry API anyways, I was wondering, whether I could store an Entry of a counted element and reuse the Entry for decrementing after the timeout.
This would half the requirements in terms of CPU as I do not have to hash each element twice. On the other hand, it requires the Entry to remain stable even if the HashMap is reorganized or the Entry is incremented twice within the time window.
Before reorganizing my code: is this even possible or do you see fundamental problems with this approach?
Kind regards