Skip to content

PFMERGE wrong behavior #4750

@Niennienzz

Description

@Niennienzz

Describe the Bug

  • PFMERGE accumulates the cardinality of destination.
  • If the destination HyperLogLog exists, it should be treated as one of the sources.
  • But since HyperLogLog counts unique values, the cardinality should not accumulate (see examples below).

To Reproduce

$> PFADD hll_01 1 2 3
(integer) 1
$> PFADD hll_02 4 5
(integer) 1
$> PFMERGE destination hll_01 hll_02
OK
$> PFCOUNT destination
(integer) 5

# No new unique member added.
# Repeat the previous two commands.
$> PFMERGE destination hll_01 hll_02
OK
$> PFCOUNT destination
(integer) 10                           # This is wrong.
$> PFMERGE destination hll_01 hll_02
OK
$> PFCOUNT destination
(integer) 15                           # This is wrong.

Expected Behavior

  • There's no new unique member added in hll_01, hll_02, and destination.
  • The merged destination HyperLogLog should have the same value onwards.
$> PFADD hll_01 1 2 3
(integer) 1
$> PFADD hll_02 4 5
(integer) 1
$> PFMERGE destination hll_01 hll_02
OK
$> PFCOUNT destination
(integer) 5

# No new unique member added.
# Repeat the previous two commands.
$> PFMERGE destination hll_01 hll_02
OK
$> PFCOUNT destination
(integer) 5
$> PFMERGE destination hll_01 hll_02
OK
$> PFCOUNT destination
(integer) 5

Environment

  • OS: MacOS
  • Kernel: Darwin Kernel Version 23.5.0: Wed May 1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64
  • Containerized: Docker
  • Dragonfly Version: v1.27.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions