PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
hash.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * hash.h
4  * header file for postgres hash access method implementation
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/hash.h
11  *
12  * NOTES
13  * modeled after Margo Seltzer's hash implementation for unix.
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef HASH_H
18 #define HASH_H
19 
20 #include "access/amapi.h"
21 #include "access/itup.h"
22 #include "access/sdir.h"
23 #include "fmgr.h"
24 #include "lib/stringinfo.h"
25 #include "storage/bufmgr.h"
26 #include "storage/lockdefs.h"
27 #include "utils/hsearch.h"
28 #include "utils/relcache.h"
29 
30 /*
31  * Mapping from hash bucket number to physical block number of bucket's
32  * starting page. Beware of multiple evaluations of argument!
33  */
34 typedef uint32 Bucket;
35 
36 #define InvalidBucket ((Bucket) 0xFFFFFFFF)
37 
38 #define BUCKET_TO_BLKNO(metap,B) \
39  ((BlockNumber) ((B) + ((B) ? (metap)->hashm_spares[_hash_spareindex((B)+1)-1] : 0)) + 1)
40 
41 /*
42  * Rotate the high 32 bits and the low 32 bits separately. The standard
43  * hash function sometimes rotates the low 32 bits by one bit when
44  * combining elements. We want extended hash functions to be compatible with
45  * that algorithm when the seed is 0, so we can't just do a normal rotation.
46  * This works, though.
47  */
48 #define ROTATE_HIGH_AND_LOW_32BITS(v) \
49  ((((v) << 1) & UINT64CONST(0xfffffffefffffffe)) | \
50  (((v) >> 31) & UINT64CONST(0x100000001)))
51 
52 /*
53  * Special space for hash index pages.
54  *
55  * hasho_flag's LH_PAGE_TYPE bits tell us which type of page we're looking at.
56  * Additional bits in the flag word are used for more transient purposes.
57  *
58  * To test a page's type, do (hasho_flag & LH_PAGE_TYPE) == LH_xxx_PAGE.
59  * However, we ensure that each used page type has a distinct bit so that
60  * we can OR together page types for uses such as the allowable-page-types
61  * argument of _hash_checkpage().
62  */
63 #define LH_UNUSED_PAGE (0)
64 #define LH_OVERFLOW_PAGE (1 << 0)
65 #define LH_BUCKET_PAGE (1 << 1)
66 #define LH_BITMAP_PAGE (1 << 2)
67 #define LH_META_PAGE (1 << 3)
68 #define LH_BUCKET_BEING_POPULATED (1 << 4)
69 #define LH_BUCKET_BEING_SPLIT (1 << 5)
70 #define LH_BUCKET_NEEDS_SPLIT_CLEANUP (1 << 6)
71 #define LH_PAGE_HAS_DEAD_TUPLES (1 << 7)
72 
73 #define LH_PAGE_TYPE \
74  (LH_OVERFLOW_PAGE | LH_BUCKET_PAGE | LH_BITMAP_PAGE | LH_META_PAGE)
75 
76 /*
77  * In an overflow page, hasho_prevblkno stores the block number of the previous
78  * page in the bucket chain; in a bucket page, hasho_prevblkno stores the
79  * hashm_maxbucket value as of the last time the bucket was last split, or
80  * else as of the time the bucket was created. The latter convention is used
81  * to determine whether a cached copy of the metapage is too stale to be used
82  * without needing to lock or pin the metapage.
83  *
84  * hasho_nextblkno is always the block number of the next page in the
85  * bucket chain, or InvalidBlockNumber if there are no more such pages.
86  */
87 typedef struct HashPageOpaqueData
88 {
89  BlockNumber hasho_prevblkno; /* see above */
90  BlockNumber hasho_nextblkno; /* see above */
91  Bucket hasho_bucket; /* bucket number this pg belongs to */
92  uint16 hasho_flag; /* page type code + flag bits, see above */
93  uint16 hasho_page_id; /* for identification of hash indexes */
95 
97 
98 #define H_NEEDS_SPLIT_CLEANUP(opaque) (((opaque)->hasho_flag & LH_BUCKET_NEEDS_SPLIT_CLEANUP) != 0)
99 #define H_BUCKET_BEING_SPLIT(opaque) (((opaque)->hasho_flag & LH_BUCKET_BEING_SPLIT) != 0)
100 #define H_BUCKET_BEING_POPULATED(opaque) (((opaque)->hasho_flag & LH_BUCKET_BEING_POPULATED) != 0)
101 #define H_HAS_DEAD_TUPLES(opaque) (((opaque)->hasho_flag & LH_PAGE_HAS_DEAD_TUPLES) != 0)
102 
103 /*
104  * The page ID is for the convenience of pg_filedump and similar utilities,
105  * which otherwise would have a hard time telling pages of different index
106  * types apart. It should be the last 2 bytes on the page. This is more or
107  * less "free" due to alignment considerations.
108  */
109 #define HASHO_PAGE_ID 0xFF80
110 
111 typedef struct HashScanPosItem /* what we remember about each match */
112 {
113  ItemPointerData heapTid; /* TID of referenced heap item */
114  OffsetNumber indexOffset; /* index item's location within page */
116 
117 typedef struct HashScanPosData
118 {
119  Buffer buf; /* if valid, the buffer is pinned */
120  BlockNumber currPage; /* current hash index page */
121  BlockNumber nextPage; /* next overflow page */
122  BlockNumber prevPage; /* prev overflow or bucket page */
123 
124  /*
125  * The items array is always ordered in index order (ie, increasing
126  * indexoffset). When scanning backwards it is convenient to fill the
127  * array back-to-front, so we start at the last slot and fill downwards.
128  * Hence we need both a first-valid-entry and a last-valid-entry counter.
129  * itemIndex is a cursor showing which entry was last returned to caller.
130  */
131  int firstItem; /* first valid index in items[] */
132  int lastItem; /* last valid index in items[] */
133  int itemIndex; /* current index in items[] */
134 
137 
138 #define HashScanPosIsPinned(scanpos) \
139 ( \
140  AssertMacro(BlockNumberIsValid((scanpos).currPage) || \
141  !BufferIsValid((scanpos).buf)), \
142  BufferIsValid((scanpos).buf) \
143 )
144 
145 #define HashScanPosIsValid(scanpos) \
146 ( \
147  AssertMacro(BlockNumberIsValid((scanpos).currPage) || \
148  !BufferIsValid((scanpos).buf)), \
149  BlockNumberIsValid((scanpos).currPage) \
150 )
151 
152 #define HashScanPosInvalidate(scanpos) \
153  do { \
154  (scanpos).buf = InvalidBuffer; \
155  (scanpos).currPage = InvalidBlockNumber; \
156  (scanpos).nextPage = InvalidBlockNumber; \
157  (scanpos).prevPage = InvalidBlockNumber; \
158  (scanpos).firstItem = 0; \
159  (scanpos).lastItem = 0; \
160  (scanpos).itemIndex = 0; \
161  } while (0);
162 
163 /*
164  * HashScanOpaqueData is private state for a hash index scan.
165  */
166 typedef struct HashScanOpaqueData
167 {
168  /* Hash value of the scan key, ie, the hash key we seek */
170 
171  /* remember the buffer associated with primary bucket */
173 
174  /*
175  * remember the buffer associated with primary bucket page of bucket being
176  * split. it is required during the scan of the bucket which is being
177  * populated during split operation.
178  */
180 
181  /* Whether scan starts on bucket being populated due to split */
183 
184  /*
185  * Whether scanning bucket being split? The value of this parameter is
186  * referred only when hashso_buc_populated is true.
187  */
189  /* info about killed items if any (killedItems is NULL if never used) */
190  int *killedItems; /* currPos.items indexes of killed items */
191  int numKilled; /* number of currently stored items */
192 
193  /*
194  * Identify all the matching items on a page and save them in
195  * HashScanPosData
196  */
197  HashScanPosData currPos; /* current position data */
199 
201 
202 /*
203  * Definitions for metapage.
204  */
205 
206 #define HASH_METAPAGE 0 /* metapage is always block 0 */
207 
208 #define HASH_MAGIC 0x6440640
209 #define HASH_VERSION 4
210 
211 /*
212  * spares[] holds the number of overflow pages currently allocated at or
213  * before a certain splitpoint. For example, if spares[3] = 7 then there are
214  * 7 ovflpages before splitpoint 3 (compare BUCKET_TO_BLKNO macro). The
215  * value in spares[ovflpoint] increases as overflow pages are added at the
216  * end of the index. Once ovflpoint increases (ie, we have actually allocated
217  * the bucket pages belonging to that splitpoint) the number of spares at the
218  * prior splitpoint cannot change anymore.
219  *
220  * ovflpages that have been recycled for reuse can be found by looking at
221  * bitmaps that are stored within ovflpages dedicated for the purpose.
222  * The blknos of these bitmap pages are kept in mapp[]; nmaps is the
223  * number of currently existing bitmaps.
224  *
225  * The limitation on the size of spares[] comes from the fact that there's
226  * no point in having more than 2^32 buckets with only uint32 hashcodes.
227  * (Note: The value of HASH_MAX_SPLITPOINTS which is the size of spares[] is
228  * adjusted in such a way to accommodate multi phased allocation of buckets
229  * after HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE).
230  *
231  * There is no particular upper limit on the size of mapp[], other than
232  * needing to fit into the metapage. (With 8K block size, 1024 bitmaps
233  * limit us to 256 GB of overflow space...)
234  */
235 #define HASH_MAX_BITMAPS 1024
236 
237 #define HASH_SPLITPOINT_PHASE_BITS 2
238 #define HASH_SPLITPOINT_PHASES_PER_GRP (1 << HASH_SPLITPOINT_PHASE_BITS)
239 #define HASH_SPLITPOINT_PHASE_MASK (HASH_SPLITPOINT_PHASES_PER_GRP - 1)
240 #define HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE 10
241 
242 /* defines max number of splitpoit phases a hash index can have */
243 #define HASH_MAX_SPLITPOINT_GROUP 32
244 #define HASH_MAX_SPLITPOINTS \
245  (((HASH_MAX_SPLITPOINT_GROUP - HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE) * \
246  HASH_SPLITPOINT_PHASES_PER_GRP) + \
247  HASH_SPLITPOINT_GROUPS_WITH_ONE_PHASE)
248 
249 typedef struct HashMetaPageData
250 {
251  uint32 hashm_magic; /* magic no. for hash tables */
252  uint32 hashm_version; /* version ID */
253  double hashm_ntuples; /* number of tuples stored in the table */
254  uint16 hashm_ffactor; /* target fill factor (tuples/bucket) */
255  uint16 hashm_bsize; /* index page size (bytes) */
256  uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a power
257  * of 2 */
258  uint16 hashm_bmshift; /* log2(bitmap array size in BITS) */
259  uint32 hashm_maxbucket; /* ID of maximum bucket in use */
260  uint32 hashm_highmask; /* mask to modulo into entire table */
261  uint32 hashm_lowmask; /* mask to modulo into lower half of table */
262  uint32 hashm_ovflpoint; /* splitpoint from which ovflpgs being
263  * allocated */
264  uint32 hashm_firstfree; /* lowest-number free ovflpage (bit#) */
265  uint32 hashm_nmaps; /* number of bitmap pages */
266  RegProcedure hashm_procid; /* hash procedure id from pg_proc */
267  uint32 hashm_spares[HASH_MAX_SPLITPOINTS]; /* spare pages before each
268  * splitpoint */
269  BlockNumber hashm_mapp[HASH_MAX_BITMAPS]; /* blknos of ovfl bitmaps */
271 
273 
274 /*
275  * Maximum size of a hash index item (it's okay to have only one per page)
276  */
277 #define HashMaxItemSize(page) \
278  MAXALIGN_DOWN(PageGetPageSize(page) - \
279  SizeOfPageHeaderData - \
280  sizeof(ItemIdData) - \
281  MAXALIGN(sizeof(HashPageOpaqueData)))
282 
283 #define INDEX_MOVED_BY_SPLIT_MASK 0x2000
284 
285 #define HASH_MIN_FILLFACTOR 10
286 #define HASH_DEFAULT_FILLFACTOR 75
287 
288 /*
289  * Constants
290  */
291 #define BYTE_TO_BIT 3 /* 2^3 bits/byte */
292 #define ALL_SET ((uint32) ~0)
293 
294 /*
295  * Bitmap pages do not contain tuples. They do contain the standard
296  * page headers and trailers; however, everything in between is a
297  * giant bit array. The number of bits that fit on a page obviously
298  * depends on the page size and the header/trailer overhead. We require
299  * the number of bits per page to be a power of 2.
300  */
301 #define BMPGSZ_BYTE(metap) ((metap)->hashm_bmsize)
302 #define BMPGSZ_BIT(metap) ((metap)->hashm_bmsize << BYTE_TO_BIT)
303 #define BMPG_SHIFT(metap) ((metap)->hashm_bmshift)
304 #define BMPG_MASK(metap) (BMPGSZ_BIT(metap) - 1)
305 
306 #define HashPageGetBitmap(page) \
307  ((uint32 *) PageGetContents(page))
308 
309 #define HashGetMaxBitmapSize(page) \
310  (PageGetPageSize((Page) page) - \
311  (MAXALIGN(SizeOfPageHeaderData) + MAXALIGN(sizeof(HashPageOpaqueData))))
312 
313 #define HashPageGetMeta(page) \
314  ((HashMetaPage) PageGetContents(page))
315 
316 /*
317  * The number of bits in an ovflpage bitmap word.
318  */
319 #define BITS_PER_MAP 32 /* Number of bits in uint32 */
320 
321 /* Given the address of the beginning of a bit map, clear/set the nth bit */
322 #define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP)))
323 #define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP)))
324 #define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP)))
325 
326 /*
327  * page-level and high-level locking modes (see README)
328  */
329 #define HASH_READ BUFFER_LOCK_SHARE
330 #define HASH_WRITE BUFFER_LOCK_EXCLUSIVE
331 #define HASH_NOLOCK (-1)
332 
333 /*
334  * Strategy number. There's only one valid strategy for hashing: equality.
335  */
336 #define HTEqualStrategyNumber 1
337 #define HTMaxStrategyNumber 1
338 
339 /*
340  * When a new operator class is declared, we require that the user supply
341  * us with an amproc procudure for hashing a key of the new type, returning
342  * a 32-bit hash value. We call this the "standard" hash procedure. We
343  * also allow an optional "extended" hash procedure which accepts a salt and
344  * returns a 64-bit hash value. This is highly recommended but, for reasons
345  * of backward compatibility, optional.
346  *
347  * When the salt is 0, the low 32 bits of the value returned by the extended
348  * hash procedure should match the value that would have been returned by the
349  * standard hash procedure.
350  */
351 #define HASHSTANDARD_PROC 1
352 #define HASHEXTENDED_PROC 2
353 #define HASHNProcs 2
354 
355 
356 /* public routines */
357 
359  struct IndexInfo *indexInfo);
360 extern void hashbuildempty(Relation index);
361 extern bool hashinsert(Relation rel, Datum *values, bool *isnull,
362  ItemPointer ht_ctid, Relation heapRel,
363  IndexUniqueCheck checkUnique,
364  struct IndexInfo *indexInfo);
365 extern bool hashgettuple(IndexScanDesc scan, ScanDirection dir);
366 extern int64 hashgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
367 extern IndexScanDesc hashbeginscan(Relation rel, int nkeys, int norderbys);
368 extern void hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
369  ScanKey orderbys, int norderbys);
370 extern void hashendscan(IndexScanDesc scan);
372  IndexBulkDeleteResult *stats,
374  void *callback_state);
376  IndexBulkDeleteResult *stats);
377 extern bytea *hashoptions(Datum reloptions, bool validate);
378 extern bool hashvalidate(Oid opclassoid);
379 
380 extern Datum hash_any(register const unsigned char *k, register int keylen);
381 extern Datum hash_any_extended(register const unsigned char *k,
382  register int keylen, uint64 seed);
383 extern Datum hash_uint32(uint32 k);
384 extern Datum hash_uint32_extended(uint32 k, uint64 seed);
385 
386 /* private routines */
387 
388 /* hashinsert.c */
389 extern void _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel);
391  Size itemsize, IndexTuple itup);
392 extern void _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups,
393  OffsetNumber *itup_offsets, uint16 nitups);
394 
395 /* hashovfl.c */
396 extern Buffer _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin);
397 extern BlockNumber _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf,
398  Buffer wbuf, IndexTuple *itups, OffsetNumber *itup_offsets,
399  Size *tups_size, uint16 nitups, BufferAccessStrategy bstrategy);
400 extern void _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage);
401 extern void _hash_squeezebucket(Relation rel,
402  Bucket bucket, BlockNumber bucket_blkno,
403  Buffer bucket_buf,
404  BufferAccessStrategy bstrategy);
406 
407 /* hashpage.c */
408 extern Buffer _hash_getbuf(Relation rel, BlockNumber blkno,
409  int access, int flags);
411  BlockNumber blkno, int flags);
412 extern HashMetaPage _hash_getcachedmetap(Relation rel, Buffer *metabuf,
413  bool force_refresh);
415  int access,
416  HashMetaPage *cachedmetap);
417 extern Buffer _hash_getinitbuf(Relation rel, BlockNumber blkno);
418 extern void _hash_initbuf(Buffer buf, uint32 max_bucket, uint32 num_bucket,
419  uint32 flag, bool initpage);
420 extern Buffer _hash_getnewbuf(Relation rel, BlockNumber blkno,
421  ForkNumber forkNum);
423  int access, int flags,
424  BufferAccessStrategy bstrategy);
425 extern void _hash_relbuf(Relation rel, Buffer buf);
426 extern void _hash_dropbuf(Relation rel, Buffer buf);
427 extern void _hash_dropscanbuf(Relation rel, HashScanOpaque so);
428 extern uint32 _hash_init(Relation rel, double num_tuples,
429  ForkNumber forkNum);
430 extern void _hash_init_metabuffer(Buffer buf, double num_tuples,
431  RegProcedure procid, uint16 ffactor, bool initpage);
432 extern void _hash_pageinit(Page page, Size size);
433 extern void _hash_expandtable(Relation rel, Buffer metabuf);
434 extern void _hash_finish_split(Relation rel, Buffer metabuf, Buffer obuf,
435  Bucket obucket, uint32 maxbucket, uint32 highmask,
436  uint32 lowmask);
437 
438 /* hashsearch.c */
439 extern bool _hash_next(IndexScanDesc scan, ScanDirection dir);
440 extern bool _hash_first(IndexScanDesc scan, ScanDirection dir);
441 
442 /* hashsort.c */
443 typedef struct HSpool HSpool; /* opaque struct in hashsort.c */
444 
445 extern HSpool *_h_spoolinit(Relation heap, Relation index, uint32 num_buckets);
446 extern void _h_spooldestroy(HSpool *hspool);
447 extern void _h_spool(HSpool *hspool, ItemPointer self,
448  Datum *values, bool *isnull);
449 extern void _h_indexbuild(HSpool *hspool, Relation heapRel);
450 
451 /* hashutil.c */
452 extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup);
453 extern uint32 _hash_datum2hashkey(Relation rel, Datum key);
454 extern uint32 _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype);
455 extern Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket,
456  uint32 highmask, uint32 lowmask);
457 extern uint32 _hash_log2(uint32 num);
458 extern uint32 _hash_spareindex(uint32 num_bucket);
459 extern uint32 _hash_get_totalbuckets(uint32 splitpoint_phase);
460 extern void _hash_checkpage(Relation rel, Buffer buf, int flags);
463  Datum *user_values, bool *user_isnull,
464  Datum *index_values, bool *index_isnull);
465 extern OffsetNumber _hash_binsearch(Page page, uint32 hash_value);
466 extern OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value);
470  uint32 lowmask, uint32 maxbucket);
471 extern void _hash_kill_items(IndexScanDesc scan);
472 
473 /* hash.c */
474 extern void hashbucketcleanup(Relation rel, Bucket cur_bucket,
475  Buffer bucket_buf, BlockNumber bucket_blkno,
476  BufferAccessStrategy bstrategy,
477  uint32 maxbucket, uint32 highmask, uint32 lowmask,
478  double *tuples_removed, double *num_index_tuples,
479  bool bucket_has_garbage,
480  IndexBulkDeleteCallback callback, void *callback_state);
481 
482 #endif /* HASH_H */
bool _hash_convert_tuple(Relation index, Datum *user_values, bool *user_isnull, Datum *index_values, bool *index_isnull)
Definition: hashutil.c:326
void hashendscan(IndexScanDesc scan)
Definition: hash.c:416
HashScanOpaqueData * HashScanOpaque
Definition: hash.h:200
uint16 hashm_bmshift
Definition: hash.h:258
uint16 hasho_page_id
Definition: hash.h:93
IndexScanDesc hashbeginscan(Relation rel, int nkeys, int norderbys)
Definition: hash.c:352
Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access, int flags)
Definition: hashpage.c:78
BlockNumber _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf, Buffer wbuf, IndexTuple *itups, OffsetNumber *itup_offsets, Size *tups_size, uint16 nitups, BufferAccessStrategy bstrategy)
Definition: hashovfl.c:488
RegProcedure hashm_procid
Definition: hash.h:266
void _hash_pageinit(Page page, Size size)
Definition: hashpage.c:606
void hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf, BlockNumber bucket_blkno, BufferAccessStrategy bstrategy, uint32 maxbucket, uint32 highmask, uint32 lowmask, double *tuples_removed, double *num_index_tuples, bool bucket_has_garbage, IndexBulkDeleteCallback callback, void *callback_state)
Definition: hash.c:672
bool hashvalidate(Oid opclassoid)
Definition: hashvalidate.c:44
uint32 _hash_log2(uint32 num)
Definition: hashutil.c:141
bytea * hashoptions(Datum reloptions, bool validate)
Definition: hashutil.c:290
int64 hashgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: hash.c:320
Buffer _hash_getbucketbuf_from_hashkey(Relation rel, uint32 hashkey, int access, HashMetaPage *cachedmetap)
Definition: hashpage.c:1560
bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
Definition: hashutil.c:31
Datum hash_any_extended(register const unsigned char *k, register int keylen, uint64 seed)
Definition: hashfunc.c:634
regproc RegProcedure
Definition: c.h:389
uint32 hashm_magic
Definition: hash.h:251
HashMetaPage _hash_getcachedmetap(Relation rel, Buffer *metabuf, bool force_refresh)
Definition: hashpage.c:1502
void hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: hash.c:382
uint16 hashm_ffactor
Definition: hash.h:254
uint32 hashm_highmask
Definition: hash.h:260
HashMetaPageData * HashMetaPage
Definition: hash.h:272
void _hash_init_metabuffer(Buffer buf, double num_tuples, RegProcedure procid, uint16 ffactor, bool initpage)
Definition: hashpage.c:506
struct HashScanPosData HashScanPosData
IndexBuildResult * hashbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: hash.c:103
uint32 BlockNumber
Definition: block.h:31
unsigned int Oid
Definition: postgres_ext.h:31
bool hashgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: hash.c:268
void _hash_squeezebucket(Relation rel, Bucket bucket, BlockNumber bucket_blkno, Buffer bucket_buf, BufferAccessStrategy bstrategy)
Definition: hashovfl.c:804
uint32 hashm_lowmask
Definition: hash.h:261
void _h_spool(HSpool *hspool, ItemPointer self, Datum *values, bool *isnull)
Definition: hashsort.c:104
void _hash_initbuf(Buffer buf, uint32 max_bucket, uint32 num_bucket, uint32 flag, bool initpage)
Definition: hashpage.c:165
void _hash_dropscanbuf(Relation rel, HashScanOpaque so)
Definition: hashpage.c:297
Buffer _hash_getinitbuf(Relation rel, BlockNumber blkno)
Definition: hashpage.c:143
bool hashinsert(Relation rel, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, struct IndexInfo *indexInfo)
Definition: hash.c:237
#define HASH_MAX_SPLITPOINTS
Definition: hash.h:244
uint32 _hash_datum2hashkey_type(Relation rel, Datum key, Oid keytype)
Definition: hashutil.c:102
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:89
uint32 Bucket
Definition: hash.h:34
IndexUniqueCheck
Definition: genam.h:111
int * killedItems
Definition: hash.h:190
bool _hash_next(IndexScanDesc scan, ScanDirection dir)
Definition: hashsearch.c:47
unsigned short uint16
Definition: c.h:257
void _hash_finish_split(Relation rel, Buffer metabuf, Buffer obuf, Bucket obucket, uint32 maxbucket, uint32 highmask, uint32 lowmask)
Definition: hashpage.c:1356
BlockNumber hasho_prevblkno
Definition: hash.h:89
Buffer _hash_getnewbuf(Relation rel, BlockNumber blkno, ForkNumber forkNum)
Definition: hashpage.c:206
uint32 _hash_spareindex(uint32 num_bucket)
Definition: hashutil.c:157
void _hash_checkpage(Relation rel, Buffer buf, int flags)
Definition: hashutil.c:225
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
uint32 hashm_version
Definition: hash.h:252
uint32 hashm_nmaps
Definition: hash.h:265
struct HashMetaPageData HashMetaPageData
Buffer _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf, bool retain_pin)
Definition: hashovfl.c:111
IndexBulkDeleteResult * hashvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: hash.c:633
static char * buf
Definition: pg_test_fsync.c:67
char * flag(int b)
Definition: test-ctype.c:33
void _hash_doinsert(Relation rel, IndexTuple itup, Relation heapRel)
Definition: hashinsert.c:36
ScanDirection
Definition: sdir.h:22
OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, Size itemsize, IndexTuple itup)
Definition: hashinsert.c:266
void _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage)
Definition: hashovfl.c:739
unsigned int uint32
Definition: c.h:258
BlockNumber currPage
Definition: hash.h:120
Buffer hashso_bucket_buf
Definition: hash.h:172
uint32 _hash_get_totalbuckets(uint32 splitpoint_phase)
Definition: hashutil.c:189
ForkNumber
Definition: relpath.h:24
void _hash_relbuf(Relation rel, Buffer buf)
Definition: hashpage.c:274
#define HASH_MAX_BITMAPS
Definition: hash.h:235
void _hash_expandtable(Relation rel, Buffer metabuf)
Definition: hashpage.c:624
bool _hash_first(IndexScanDesc scan, ScanDirection dir)
Definition: hashsearch.c:290
uint32 hashm_ovflpoint
Definition: hash.h:262
uint16 hashm_bsize
Definition: hash.h:255
uint32 _hash_init(Relation rel, double num_tuples, ForkNumber forkNum)
Definition: hashpage.c:335
BlockNumber _hash_get_newblock_from_oldbucket(Relation rel, Bucket old_bucket)
Definition: hashutil.c:469
uintptr_t Datum
Definition: postgres.h:372
BlockNumber _hash_get_oldblock_from_newbucket(Relation rel, Bucket new_bucket)
Definition: hashutil.c:430
double hashm_ntuples
Definition: hash.h:253
bool hashso_buc_populated
Definition: hash.h:182
Buffer buf
Definition: hash.h:119
uint32 hashm_firstfree
Definition: hash.h:264
uint32 hashm_spares[HASH_MAX_SPLITPOINTS]
Definition: hash.h:267
uint32 hashso_sk_hash
Definition: hash.h:169
Datum hash_uint32_extended(uint32 k, uint64 seed)
Definition: hashfunc.c:874
uint32 _hash_get_indextuple_hashkey(IndexTuple itup)
Definition: hashutil.c:299
Bucket _hash_get_newbucket_from_oldbucket(Relation rel, Bucket old_bucket, uint32 lowmask, uint32 maxbucket)
Definition: hashutil.c:502
void hashbuildempty(Relation index)
Definition: hash.c:186
void _h_spooldestroy(HSpool *hspool)
Definition: hashsort.c:94
Bucket hasho_bucket
Definition: hash.h:91
int lastItem
Definition: hash.h:132
struct HashScanPosItem HashScanPosItem
size_t Size
Definition: c.h:350
void _hash_dropbuf(Relation rel, Buffer buf)
Definition: hashpage.c:285
HashPageOpaqueData * HashPageOpaque
Definition: hash.h:96
OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value)
Definition: hashutil.c:396
HSpool * _h_spoolinit(Relation heap, Relation index, uint32 num_buckets)
Definition: hashsort.c:56
Buffer _hash_getbuf_with_condlock_cleanup(Relation rel, BlockNumber blkno, int flags)
Definition: hashpage.c:104
struct HashScanOpaqueData HashScanOpaqueData
uint32 hashm_maxbucket
Definition: hash.h:259
HashScanPosData currPos
Definition: hash.h:197
struct HashPageOpaqueData HashPageOpaqueData
uint16 hasho_flag
Definition: hash.h:92
bool hashso_buc_split
Definition: hash.h:188
static Datum values[MAXATTR]
Definition: bootstrap.c:164
Datum hash_any(register const unsigned char *k, register int keylen)
Definition: hashfunc.c:428
Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket, uint32 highmask, uint32 lowmask)
Definition: hashutil.c:125
#define MaxIndexTuplesPerPage
Definition: itup.h:137
OffsetNumber indexOffset
Definition: hash.h:114
void _h_indexbuild(HSpool *hspool, Relation heapRel)
Definition: hashsort.c:115
void _hash_kill_items(IndexScanDesc scan)
Definition: hashutil.c:544
Buffer hashso_split_bucket_buf
Definition: hash.h:179
Buffer _hash_getbuf_with_strategy(Relation rel, BlockNumber blkno, int access, int flags, BufferAccessStrategy bstrategy)
Definition: hashpage.c:247
BlockNumber nextPage
Definition: hash.h:121
BlockNumber hasho_nextblkno
Definition: hash.h:90
uint16 hashm_bmsize
Definition: hash.h:256
uint32 _hash_datum2hashkey(Relation rel, Datum key)
Definition: hashutil.c:82
Datum hash_uint32(uint32 k)
Definition: hashfunc.c:853
Definition: c.h:433
ItemPointerData heapTid
Definition: hash.h:113
OffsetNumber _hash_binsearch(Page page, uint32 hash_value)
Definition: hashutil.c:358
uint32 _hash_ovflblkno_to_bitno(HashMetaPage metap, BlockNumber ovflblkno)
Definition: hashovfl.c:61
int itemIndex
Definition: hash.h:133
IndexBulkDeleteResult * hashbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: hash.c:447
void _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups, OffsetNumber *itup_offsets, uint16 nitups)
Definition: hashinsert.c:297
int firstItem
Definition: hash.h:131
BlockNumber prevPage
Definition: hash.h:122
BlockNumber hashm_mapp[HASH_MAX_BITMAPS]
Definition: hash.h:269
int Buffer
Definition: buf.h:23
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:83
Pointer Page
Definition: bufpage.h:74
HashScanPosItem items[MaxIndexTuplesPerPage]
Definition: hash.h:135