PostgreSQL Source Code git master
|
#include "postgres.h"
#include <math.h>
#include "access/brin.h"
#include "access/brin_internal.h"
#include "access/brin_page.h"
#include "access/brin_tuple.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/reloptions.h"
#include "catalog/pg_am.h"
#include "catalog/pg_type.h"
#include "common/hashfn.h"
#include "utils/fmgrprotos.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | BloomOptions |
struct | BloomFilter |
struct | BloomOpaque |
Macros | |
#define | BloomEqualStrategyNumber 1 |
#define | BLOOM_MAX_PROCNUMS 1 /* maximum support procs we need */ |
#define | PROCNUM_HASH 11 /* required */ |
#define | PROCNUM_BASE 11 |
#define | BLOOM_MIN_NDISTINCT_PER_RANGE 16 |
#define | BLOOM_DEFAULT_NDISTINCT_PER_RANGE -0.1 /* 10% of values */ |
#define | BLOOM_MIN_FALSE_POSITIVE_RATE 0.0001 /* 0.01% fp rate */ |
#define | BLOOM_MAX_FALSE_POSITIVE_RATE 0.25 /* 25% fp rate */ |
#define | BLOOM_DEFAULT_FALSE_POSITIVE_RATE 0.01 /* 1% fp rate */ |
#define | BloomGetNDistinctPerRange(opts) |
#define | BloomGetFalsePositiveRate(opts) |
#define | BloomMaxFilterSize |
#define | BLOOM_SEED_1 0x71d924af |
#define | BLOOM_SEED_2 0xba48b314 |
Typedefs | |
typedef struct BloomOptions | BloomOptions |
typedef struct BloomFilter | BloomFilter |
typedef struct BloomOpaque | BloomOpaque |
Functions | |
static void | bloom_filter_size (int ndistinct, double false_positive_rate, int *nbytesp, int *nbitsp, int *nhashesp) |
static BloomFilter * | bloom_init (int ndistinct, double false_positive_rate) |
static BloomFilter * | bloom_add_value (BloomFilter *filter, uint32 value, bool *updated) |
static bool | bloom_contains_value (BloomFilter *filter, uint32 value) |
static FmgrInfo * | bloom_get_procinfo (BrinDesc *bdesc, uint16 attno, uint16 procnum) |
Datum | brin_bloom_opcinfo (PG_FUNCTION_ARGS) |
static int | brin_bloom_get_ndistinct (BrinDesc *bdesc, BloomOptions *opts) |
Datum | brin_bloom_add_value (PG_FUNCTION_ARGS) |
Datum | brin_bloom_consistent (PG_FUNCTION_ARGS) |
Datum | brin_bloom_union (PG_FUNCTION_ARGS) |
Datum | brin_bloom_options (PG_FUNCTION_ARGS) |
Datum | brin_bloom_summary_in (PG_FUNCTION_ARGS) |
Datum | brin_bloom_summary_out (PG_FUNCTION_ARGS) |
Datum | brin_bloom_summary_recv (PG_FUNCTION_ARGS) |
Datum | brin_bloom_summary_send (PG_FUNCTION_ARGS) |
#define BLOOM_DEFAULT_FALSE_POSITIVE_RATE 0.01 /* 1% fp rate */ |
Definition at line 193 of file brin_bloom.c.
#define BLOOM_DEFAULT_NDISTINCT_PER_RANGE -0.1 /* 10% of values */ |
Definition at line 175 of file brin_bloom.c.
#define BLOOM_MAX_FALSE_POSITIVE_RATE 0.25 /* 25% fp rate */ |
Definition at line 192 of file brin_bloom.c.
#define BLOOM_MAX_PROCNUMS 1 /* maximum support procs we need */ |
Definition at line 141 of file brin_bloom.c.
#define BLOOM_MIN_FALSE_POSITIVE_RATE 0.0001 /* 0.01% fp rate */ |
Definition at line 191 of file brin_bloom.c.
#define BLOOM_MIN_NDISTINCT_PER_RANGE 16 |
Definition at line 168 of file brin_bloom.c.
#define BLOOM_SEED_1 0x71d924af |
Definition at line 221 of file brin_bloom.c.
#define BLOOM_SEED_2 0xba48b314 |
Definition at line 222 of file brin_bloom.c.
#define BloomEqualStrategyNumber 1 |
Definition at line 132 of file brin_bloom.c.
#define BloomGetFalsePositiveRate | ( | opts | ) |
Definition at line 200 of file brin_bloom.c.
#define BloomGetNDistinctPerRange | ( | opts | ) |
Definition at line 195 of file brin_bloom.c.
#define BloomMaxFilterSize |
Definition at line 210 of file brin_bloom.c.
#define PROCNUM_BASE 11 |
Definition at line 148 of file brin_bloom.c.
#define PROCNUM_HASH 11 /* required */ |
Definition at line 142 of file brin_bloom.c.
typedef struct BloomFilter BloomFilter |
typedef struct BloomOpaque BloomOpaque |
typedef struct BloomOptions BloomOptions |
|
static |
Definition at line 369 of file brin_bloom.c.
References bit(), BLOOM_SEED_1, BLOOM_SEED_2, BloomFilter::data, hash_bytes_uint32_extended(), i, BloomFilter::nbits, BloomFilter::nbits_set, BloomFilter::nhashes, and value.
Referenced by brin_bloom_add_value().
|
static |
Definition at line 406 of file brin_bloom.c.
References bit(), BLOOM_SEED_1, BLOOM_SEED_2, BloomFilter::data, hash_bytes_uint32_extended(), i, BloomFilter::nbits, BloomFilter::nhashes, and value.
Referenced by brin_bloom_consistent().
|
static |
Definition at line 270 of file brin_bloom.c.
Referenced by bloom_init().
Definition at line 706 of file brin_bloom.c.
References BrinDesc::bd_context, BrinDesc::bd_index, BrinDesc::bd_info, BloomOpaque::extra_proc_missing, BloomOpaque::extra_procinfos, fmgr_info_copy(), FmgrInfo::fn_oid, if(), index_getprocid(), index_getprocinfo(), InvalidOid, BrinOpcInfo::oi_opaque, PROCNUM_BASE, and RegProcedureIsValid.
Referenced by brin_bloom_add_value(), and brin_bloom_consistent().
|
static |
Definition at line 309 of file brin_bloom.c.
References Assert, bloom_filter_size(), BloomMaxFilterSize, data, elog, ERROR, BloomFilter::flags, len, BloomFilter::nbits, BloomFilter::nhashes, palloc0(), and SET_VARSIZE.
Referenced by brin_bloom_add_value().
Datum brin_bloom_add_value | ( | PG_FUNCTION_ARGS | ) |
Definition at line 539 of file brin_bloom.c.
References Assert, bloom_add_value(), bloom_get_procinfo(), bloom_init(), BloomGetFalsePositiveRate, brin_bloom_get_ndistinct(), BrinValues::bv_allnulls, BrinValues::bv_attno, BrinValues::bv_values, DatumGetUInt32(), FunctionCall1Coll(), newval, opts, PG_DETOAST_DATUM, PG_GET_COLLATION, PG_GET_OPCLASS_OPTIONS, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_BOOL, PG_USED_FOR_ASSERTS_ONLY, PointerGetDatum(), and PROCNUM_HASH.
Datum brin_bloom_consistent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 594 of file brin_bloom.c.
References Assert, bloom_contains_value(), bloom_get_procinfo(), BloomEqualStrategyNumber, BrinValues::bv_values, DatumGetUInt32(), elog, ERROR, FunctionCall1Coll(), sort-test::key, PG_DETOAST_DATUM, PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_POINTER, PG_RETURN_BOOL, PROCNUM_HASH, SK_ISNULL, and value.
|
static |
Definition at line 496 of file brin_bloom.c.
References Assert, BrinDesc::bd_index, BlockNumberIsValid(), BLOOM_MIN_NDISTINCT_PER_RANGE, BloomGetNDistinctPerRange, BrinGetPagesPerRange, Max, MaxHeapTuplesPerPage, Min, and opts.
Referenced by brin_bloom_add_value().
Datum brin_bloom_opcinfo | ( | PG_FUNCTION_ARGS | ) |
Definition at line 449 of file brin_bloom.c.
References lookup_type_cache(), MAXALIGN, BrinOpcInfo::oi_nstored, BrinOpcInfo::oi_opaque, BrinOpcInfo::oi_regular_nulls, BrinOpcInfo::oi_typcache, palloc0(), PG_RETURN_POINTER, and SizeofBrinOpcInfo.
Datum brin_bloom_options | ( | PG_FUNCTION_ARGS | ) |
Definition at line 744 of file brin_bloom.c.
References add_local_real_reloption(), BLOOM_DEFAULT_FALSE_POSITIVE_RATE, BLOOM_DEFAULT_NDISTINCT_PER_RANGE, BLOOM_MAX_FALSE_POSITIVE_RATE, BLOOM_MIN_FALSE_POSITIVE_RATE, init_local_reloptions(), PG_GETARG_POINTER, and PG_RETURN_VOID.
Datum brin_bloom_summary_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 774 of file brin_bloom.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum brin_bloom_summary_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 796 of file brin_bloom.c.
References appendStringInfo(), appendStringInfoChar(), initStringInfo(), BloomFilter::nbits, BloomFilter::nbits_set, BloomFilter::nhashes, PG_DETOAST_DATUM, PG_GETARG_DATUM, PG_RETURN_CSTRING, and str.
Datum brin_bloom_summary_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 820 of file brin_bloom.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum brin_bloom_summary_send | ( | PG_FUNCTION_ARGS | ) |
Datum brin_bloom_union | ( | PG_FUNCTION_ARGS | ) |
Definition at line 666 of file brin_bloom.c.
References Assert, BrinValues::bv_allnulls, BrinValues::bv_attno, BrinValues::bv_values, BloomFilter::data, i, BloomFilter::nbits, BloomFilter::nbits_set, BloomFilter::nhashes, PG_DETOAST_DATUM, PG_GETARG_POINTER, pg_popcount(), and PG_RETURN_VOID.