pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Add Bloom filter implementation.
4+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2018-04-03 2b3031559a Fix GCC 7 snprintf() compiler warning.
* pgsql: Add Bloom filter implementation.
@ 2018-04-01 01:36 Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 4+ messages in thread
From: Andres Freund @ 2018-04-01 01:36 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Add Bloom filter implementation.
A Bloom filter is a space-efficient, probabilistic data structure that
can be used to test set membership. Callers will sometimes incur false
positives, but never false negatives. The rate of false positives is a
function of the total number of elements and the amount of memory
available for the Bloom filter.
Two classic applications of Bloom filters are cache filtering, and data
synchronization testing. Any user of Bloom filters must accept the
possibility of false positives as a cost worth paying for the benefit in
space efficiency.
This commit adds a test harness extension module, test_bloomfilter. It
can be used to get a sense of how the Bloom filter implementation
performs under varying conditions.
This is infrastructure for the upcoming "heapallindexed" amcheck patch,
which verifies the consistency of a heap relation against one of its
indexes.
Author: Peter Geoghegan
Reviewed-By: Andrey Borodin, Michael Paquier, Thomas Munro, Andres Freund
Discussion: https://postgr.es/m/CAH2-Wzm5VmG7cu1N-H=nnS57wZThoSDQU+F5dewx3o84M+jY=g@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/51bc271790eb234a1ba4d14d3e6530f70de92ab5
Modified Files
--------------
src/backend/lib/Makefile | 4 +-
src/backend/lib/README | 2 +
src/backend/lib/bloomfilter.c | 305 +++++++++++++++++++++
src/include/lib/bloomfilter.h | 27 ++
src/test/modules/Makefile | 1 +
src/test/modules/test_bloomfilter/.gitignore | 4 +
src/test/modules/test_bloomfilter/Makefile | 21 ++
src/test/modules/test_bloomfilter/README | 68 +++++
.../test_bloomfilter/expected/test_bloomfilter.out | 22 ++
.../test_bloomfilter/sql/test_bloomfilter.sql | 19 ++
.../test_bloomfilter/test_bloomfilter--1.0.sql | 11 +
.../modules/test_bloomfilter/test_bloomfilter.c | 138 ++++++++++
.../test_bloomfilter/test_bloomfilter.control | 4 +
src/tools/pgindent/typedefs.list | 1 +
14 files changed, 625 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Add Bloom filter implementation.
@ 2018-04-03 15:39 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Eisentraut @ 2018-04-03 15:39 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; pgsql-committers@lists.postgresql.org
On 3/31/18 21:36, Andres Freund wrote:
> Add Bloom filter implementation.
There is a compiler warning in the tests, with gcc-7:
test_bloomfilter.c: In function 'test_bloomfilter':
test_bloomfilter.c:40:38: error: '__builtin_snprintf' output may be
truncated before the last format character [-Werror=format-truncation=]
snprintf(element, sizeof(element), "i" INT64_FORMAT, i);
^
This can be fixed by allocating one more byte for the possible sign, or
doing the whole thing in unsigned.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Add Bloom filter implementation.
@ 2018-04-03 17:38 Peter Geoghegan <pg@bowt.ie>
parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Geoghegan @ 2018-04-03 17:38 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Tue, Apr 3, 2018 at 8:39 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> There is a compiler warning in the tests, with gcc-7:
>
> test_bloomfilter.c: In function 'test_bloomfilter':
> test_bloomfilter.c:40:38: error: '__builtin_snprintf' output may be
> truncated before the last format character [-Werror=format-truncation=]
> snprintf(element, sizeof(element), "i" INT64_FORMAT, i);
> ^
>
> This can be fixed by allocating one more byte for the possible sign, or
> doing the whole thing in unsigned.
I don't want to do the whole thing in unsigned, because this ties back
fairly directly to an int8 argument from the test_bloomfilter() SQL
function interface.
I proposed the attached, which makes the buffer one byte larger, per
your suggestion.
Thanks
--
Peter Geoghegan
Attachments:
0001-Fix-GCC-7-snprintf-compiler-warning.patch (text/x-patch, 1.3K) download
From 4464e134eae415c47c437393073411c26d64bd4a Mon Sep 17 00:00:00 2001
From: Peter Geoghegan <pg@bowt.ie>
Date: Tue, 3 Apr 2018 10:25:41 -0700
Subject: [PATCH] Fix GCC 7 snprintf() compiler warning.
Make buffer 1 byte larger to fit a sign. It's actually impossible for
there to be a sign in practice, but this is still required to keep GCC 7
happy.
Cleanup from commit 51bc271790eb234a1ba4d14d3e6530f70de92ab5.
Based on a suggestion from Peter Eisentraut.
Author: Peter Geoghegan
Reported-By: Peter Eisentraut
Discussion: https://postgr.es/m/d1cc82ed-d07d-cef2-7c00-2e987f121648@2ndquadrant.com
---
src/test/modules/test_bloomfilter/test_bloomfilter.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/modules/test_bloomfilter/test_bloomfilter.c b/src/test/modules/test_bloomfilter/test_bloomfilter.c
index 1691b0f..358afbe 100644
--- a/src/test/modules/test_bloomfilter/test_bloomfilter.c
+++ b/src/test/modules/test_bloomfilter/test_bloomfilter.c
@@ -18,8 +18,8 @@
PG_MODULE_MAGIC;
-/* Must fit decimal representation of PG_INT64_MAX + 2 bytes: */
-#define MAX_ELEMENT_BYTES 20
+/* Fits decimal representation of PG_INT64_MIN + 2 bytes: */
+#define MAX_ELEMENT_BYTES 21
/* False positive rate WARNING threshold (1%): */
#define FPOSITIVE_THRESHOLD 0.01
--
2.7.4
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Add Bloom filter implementation.
@ 2018-04-03 21:13 Andres Freund <andres@anarazel.de>
parent: Peter Geoghegan <pg@bowt.ie>
0 siblings, 0 replies; 4+ messages in thread
From: Andres Freund @ 2018-04-03 21:13 UTC (permalink / raw)
To: Peter Geoghegan <pg@bowt.ie>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On 2018-04-03 10:38:57 -0700, Peter Geoghegan wrote:
> I proposed the attached, which makes the buffer one byte larger, per
> your suggestion.
Pushed, thanks.
- Andres
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2018-04-03 21:13 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-01 01:36 pgsql: Add Bloom filter implementation. Andres Freund <andres@anarazel.de>
2018-04-03 15:39 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-04-03 17:38 ` Peter Geoghegan <pg@bowt.ie>
2018-04-03 21:13 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox