7

Let's say that i have a hyperloglog in redis which counts messages is there any provisions whereby I can to some degree account for delete messages?

jbapple
  • 3,297
  • 1
  • 24
  • 38
Jack
  • 1,901
  • 1
  • 19
  • 32
  • Would it be reasonable to create two hyperloglog sets? `messages.created` and `messages.deleted` and just assert the decrement? – Jack Feb 15 '17 at 14:15
  • The two hyperloglog sets way **MIGHT** be a solution. It depends on your scenario. For example, it cannot solve the following scenario: add an element, delete the element, and then add the same element again. Can you give us more details on your scenario? – for_stack Feb 15 '17 at 14:55
  • @for_stack Yeah i mean that'd make sense. Although not sure i'd ever create the _same_ element again - as recreating a previously deleted message would have a new UUID. – Jack Feb 15 '17 at 15:28
  • Another solution might be to just recreate the HLL and `PFADD` the entire dataset. But that becomes less and less feasible with the size of the HLL :( – Jack Feb 15 '17 at 15:32

1 Answers1

11

No, the HyperLogLog doesn't support the concept of deletion. Instead, use a different counter (could be an integer, Set or HyperLogLog) and subtract the totals.

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117