The function hyperLogLogMerge() is faulty [1]. It has no current
callers, though. I propose that we rip it out, as in the attached
patch.

[1] 
http://www.postgresql.org/message-id/CAM3SWZT-i6R9JU5YXa8MJUou2_r3LfGJZpQ9tYa1BYxfkj0=c...@mail.gmail.com
-- 
Peter Geoghegan
From 3b1e6db08412bdadd3ad0d5a62a87c71a83e4e04 Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <p...@bowt.ie>
Date: Mon, 25 Apr 2016 19:24:43 -0700
Subject: [PATCH] Remove faulty hyperLogLog merge function

The approach taken is not valid with the "sparse" HLL states that
Postgres supports.  Fortunately, there were no callers of the faulty
function, so the impact of this bug was quite limited.

Author: Peter Geoghegan
Discussion: CAM3SWZT-i6R9JU5YXa8MJUou2_r3LfGJZpQ9tYa1BYxfkj0=c...@mail.gmail.com
Backpatch: 9.5, where the hyperLogLog infrastructure was introduced
---
 src/backend/lib/hyperloglog.c | 22 ----------------------
 src/include/lib/hyperloglog.h |  1 -
 2 files changed, 23 deletions(-)

diff --git a/src/backend/lib/hyperloglog.c b/src/backend/lib/hyperloglog.c
index fa7f05a..6d246ce 100644
--- a/src/backend/lib/hyperloglog.c
+++ b/src/backend/lib/hyperloglog.c
@@ -221,28 +221,6 @@ estimateHyperLogLog(hyperLogLogState *cState)
 }
 
 /*
- * Merges the estimate from one HyperLogLog state to another, returning the
- * estimate of their union.
- *
- * The number of registers in each must match.
- */
-void
-mergeHyperLogLog(hyperLogLogState *cState, const hyperLogLogState *oState)
-{
-	int			r;
-
-	if (cState->nRegisters != oState->nRegisters)
-		elog(ERROR, "number of registers mismatch: %zu != %zu",
-			 cState->nRegisters, oState->nRegisters);
-
-	for (r = 0; r < cState->nRegisters; ++r)
-	{
-		cState->hashesArr[r] = Max(cState->hashesArr[r], oState->hashesArr[r]);
-	}
-}
-
-
-/*
  * Worker for addHyperLogLog().
  *
  * Calculates the position of the first set bit in first b bits of x argument
diff --git a/src/include/lib/hyperloglog.h b/src/include/lib/hyperloglog.h
index b999b30..ee88f8f 100644
--- a/src/include/lib/hyperloglog.h
+++ b/src/include/lib/hyperloglog.h
@@ -63,7 +63,6 @@ extern void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth);
 extern void initHyperLogLogError(hyperLogLogState *cState, double error);
 extern void addHyperLogLog(hyperLogLogState *cState, uint32 hash);
 extern double estimateHyperLogLog(hyperLogLogState *cState);
-extern void mergeHyperLogLog(hyperLogLogState *cState, const hyperLogLogState *oState);
 extern void freeHyperLogLog(hyperLogLogState *cState);
 
 #endif   /* HYPERLOGLOG_H */
-- 
2.7.4

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to