PostgreSQL Source Code: contrib/bloom/blutils.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

15

25

26

27#define GETWORD(x,i) ( *( (BloomSignatureWord *)(x) + ( (i) / SIGNWORDBITS ) ) )

28#define CLRBIT(x,i) GETWORD(x,i) &= ~( 0x01 << ( (i) % SIGNWORDBITS ) )

29#define SETBIT(x,i) GETWORD(x,i) |= ( 0x01 << ( (i) % SIGNWORDBITS ) )

30#define GETBIT(x,i) ( (GETWORD(x,i) >> ( (i) % SIGNWORDBITS )) & 0x01 )

31

33

34

36

37

39

42

43

44

45

46

47

48void

50{

51 int i;

52 char buf[16];

53

55

56

58 "Length of signature in bits",

64

65

67 {

70 "Number of bits generated for each index column",

77 }

78}

79

80

81

82

85{

87 int i;

88

90

96}

97

98

99

100

101

104{

106

131

158

160}

161

162

163

164

165void

167{

168 int i;

169

170 state->nColumns = index->rd_att->natts;

171

172

173 for (i = 0; i < index->rd_att->natts; i++)

174 {

178 state->collations[i] = index->rd_indcollation[i];

179 }

180

181

182 if (index->rd_amcache)

183 {

188

190

193

195

197 elog(ERROR, "Relation is not a bloom index");

199

201 elog(ERROR, "Relation is not a bloom index");

202

204

206

208 }

209

210 memcpy(&state->opts, index->rd_amcache, sizeof(state->opts));

213}

214

215

216

217

218

219

220

221

222

223

225

228{

229

230

231

232

233

234

235

236

237

239 lo,

240 x;

241

242

243 hi = next / 127773;

244 lo = next % 127773;

245 x = 16807 * lo - 2836 * hi;

246 if (x < 0)

247 x += 0x7fffffff;

249

250 return (x - 1);

251}

252

253static void

255{

257

258 next = (next % 0x7ffffffe) + 1;

259}

260

261

262

263

264void

266{

268 int nBit,

269 j;

270

271

272

273

274

275

277

278

279

280

281

282

285

286 for (j = 0; j < state->opts.bitSize[attno]; j++)

287 {

288

291 }

292}

293

294

295

296

299{

300 int i;

302

304

305

306 for (i = 0; i < state->nColumns; i++)

307 {

308

309 if (isnull[i])

310 continue;

311

313 }

314

315 return res;

316}

317

318

319

320

321

322bool

324{

327 char *ptr;

328

329

331

332

334 return false;

335

336

339 memcpy(itup, tuple, state->sizeOfBloomTuple);

340

341

344 ((PageHeader) page)->pd_lower = ptr - page;

345

346

348

349 return true;

350}

351

352

353

354

355

356

359{

361

362

363 for (;;)

364 {

366

368 break;

369

371

372

373

374

375

377 {

379

381 return buffer;

382

384 return buffer;

385

387 }

388

389

391 }

392

393

396

397 return buffer;

398}

399

400

401

402

403void

405{

407

409

411 opaque->flags = flags;

413}

414

415

416

417

418void

420{

423

424

425

426

427

431

432

433

434

435

442

443

445}

446

447

448

449

450void

452{

454 Page metaPage;

456

457

458

459

460

461

465

466

472

474}

475

476

477

478

481{

483

484

490

491

492 if (rdopts)

494

495 return (bytea *) rdopts;

496}

static bool validate(Port *port, const char *auth)

void blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)

void blbuildempty(Relation index)

IndexBuildResult * blbuild(Relation heap, Relation index, IndexInfo *indexInfo)

bool blinsert(Relation index, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, IndexInfo *indexInfo)

#define InvalidBlockNumber

#define BloomPageGetOpaque(page)

#define BloomPageGetFreeSpace(state, page)

bool blvalidate(Oid opclassoid)

int64 blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)

#define BloomPageGetMeta(page)

IndexScanDesc blbeginscan(Relation r, int nkeys, int norderbys)

#define DEFAULT_BLOOM_BITS

struct BloomMetaPageData BloomMetaPageData

#define BLOOM_MAGICK_NUMBER

IndexBulkDeleteResult * blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)

#define BloomPageGetTuple(state, page, offset)

#define BLOOM_NSTRATEGIES

IndexBulkDeleteResult * blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)

#define BLOOM_OPTIONS_PROC

uint16 BloomSignatureWord

#define BloomPageIsDeleted(page)

#define DEFAULT_BLOOM_LENGTH

void blendscan(IndexScanDesc scan)

#define BLOOM_METAPAGE_BLKNO

#define BloomPageIsMeta(page)

void blrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)

static int32 myRand(void)

void BloomInitPage(Page page, uint16 flags)

Datum blhandler(PG_FUNCTION_ARGS)

BloomTuple * BloomFormTuple(BloomState *state, ItemPointer iptr, Datum *values, bool *isnull)

PG_FUNCTION_INFO_V1(blhandler)

static BloomOptions * makeDefaultBloomOptions(void)

bool BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)

static relopt_kind bl_relopt_kind

Buffer BloomNewBuffer(Relation index)

void BloomFillMetapage(Relation index, Page metaPage)

void BloomInitMetapage(Relation index, ForkNumber forknum)

bytea * bloptions(Datum reloptions, bool validate)

void signValue(BloomState *state, BloomSignatureWord *sign, Datum value, int attno)

static void mySrand(uint32 seed)

void initBloomState(BloomState *state, Relation index)

static relopt_parse_elt bl_relopt_tab[INDEX_MAX_KEYS+1]

static Datum values[MAXATTR]

BlockNumber BufferGetBlockNumber(Buffer buffer)

void LockBuffer(Buffer buffer, BufferLockMode mode)

Buffer ExtendBufferedRel(BufferManagerRelation bmr, ForkNumber forkNum, BufferAccessStrategy strategy, uint32 flags)

bool ConditionalLockBuffer(Buffer buffer)

void ReleaseBuffer(Buffer buffer)

void UnlockReleaseBuffer(Buffer buffer)

Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)

Buffer ReadBuffer(Relation reln, BlockNumber blockNum)

static Page BufferGetPage(Buffer buffer)

void PageInit(Page page, Size pageSize, Size specialSize)

PageHeaderData * PageHeader

static bool PageIsNew(const PageData *page)

#define palloc0_object(type)

Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)

void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, MemoryContext destcxt)

#define PG_RETURN_POINTER(x)

Page GenericXLogRegisterBuffer(GenericXLogState *state, Buffer buffer, int flags)

GenericXLogState * GenericXLogStart(Relation relation)

XLogRecPtr GenericXLogFinish(GenericXLogState *state)

#define GENERIC_XLOG_FULL_IMAGE

Assert(PointerIsAligned(start, uint64))

FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)

BlockNumber GetFreeIndexPage(Relation rel)

if(TABLE==NULL||TABLE_index==NULL)

#define AccessExclusiveLock

char * MemoryContextStrdup(MemoryContext context, const char *string)

void * MemoryContextAlloc(MemoryContext context, Size size)

void * palloc0(Size size)

MemoryContext TopMemoryContext

MemoryContext CurrentMemoryContext

static AmcheckOptions opts

static char buf[DEFAULT_XLOG_SEG_SIZE]

static int32 DatumGetInt32(Datum X)

void add_int_reloption(bits32 kinds, const char *name, const char *desc, int default_val, int min_val, int max_val, LOCKMODE lockmode)

void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)

relopt_kind add_reloption_kind(void)

BloomSignatureWord sign[FLEXIBLE_ARRAY_MEMBER]

ambuildphasename_function ambuildphasename

ambuildempty_function ambuildempty

amvacuumcleanup_function amvacuumcleanup

amoptions_function amoptions

amestimateparallelscan_function amestimateparallelscan

amrestrpos_function amrestrpos

aminsert_function aminsert

amendscan_function amendscan

amtranslate_strategy_function amtranslatestrategy

amparallelrescan_function amparallelrescan

bool amconsistentordering

amtranslate_cmptype_function amtranslatecmptype

amcostestimate_function amcostestimate

amadjustmembers_function amadjustmembers

amgettuple_function amgettuple

amcanreturn_function amcanreturn

amgetbitmap_function amgetbitmap

amproperty_function amproperty

ambulkdelete_function ambulkdelete

amvalidate_function amvalidate

ammarkpos_function ammarkpos

bool amusemaintenanceworkmem

ambeginscan_function ambeginscan

amrescan_function amrescan

aminitparallelscan_function aminitparallelscan

uint8 amparallelvacuumoptions

aminsertcleanup_function aminsertcleanup

amgettreeheight_function amgettreeheight

bool amconsistentequality

#define VACUUM_OPTION_PARALLEL_CLEANUP

#define VACUUM_OPTION_PARALLEL_BULKDEL

static void SET_VARSIZE(void *PTR, Size len)