#include "postgres.h"
#include "access/hash.h"
#include "miscadmin.h"
#include "utils/tuplesort.h"
Go to the source code of this file.
Data Structures | |
struct | HSpool |
Functions | |
HSpool * | _h_spoolinit (Relation heap, Relation index, uint32 num_buckets) |
void | _h_spooldestroy (HSpool *hspool) |
void | _h_spool (IndexTuple itup, HSpool *hspool) |
void | _h_indexbuild (HSpool *hspool) |
void _h_indexbuild | ( | HSpool * | hspool | ) |
Definition at line 103 of file hashsort.c.
References _hash_doinsert(), HSpool::index, NULL, pfree(), HSpool::sortstate, tuplesort_getindextuple(), and tuplesort_performsort().
Referenced by hashbuild().
{ IndexTuple itup; bool should_free; tuplesort_performsort(hspool->sortstate); while ((itup = tuplesort_getindextuple(hspool->sortstate, true, &should_free)) != NULL) { _hash_doinsert(hspool->index, itup); if (should_free) pfree(itup); } }
void _h_spool | ( | IndexTuple | itup, | |
HSpool * | hspool | |||
) |
Definition at line 93 of file hashsort.c.
References HSpool::sortstate, and tuplesort_putindextuple().
Referenced by hashbuildCallback().
{ tuplesort_putindextuple(hspool->sortstate, itup); }
void _h_spooldestroy | ( | HSpool * | hspool | ) |
Definition at line 83 of file hashsort.c.
References pfree(), HSpool::sortstate, and tuplesort_end().
Referenced by hashbuild().
{ tuplesort_end(hspool->sortstate); pfree(hspool); }
Definition at line 47 of file hashsort.c.
References _hash_log2(), HSpool::index, maintenance_work_mem, palloc0(), HSpool::sortstate, and tuplesort_begin_index_hash().
Referenced by hashbuild().
{ HSpool *hspool = (HSpool *) palloc0(sizeof(HSpool)); uint32 hash_mask; hspool->index = index; /* * Determine the bitmask for hash code values. Since there are currently * num_buckets buckets in the index, the appropriate mask can be computed * as follows. * * Note: at present, the passed-in num_buckets is always a power of 2, so * we could just compute num_buckets - 1. We prefer not to assume that * here, though. */ hash_mask = (((uint32) 1) << _hash_log2(num_buckets)) - 1; /* * We size the sort area as maintenance_work_mem rather than work_mem to * speed index creation. This should be OK since a single backend can't * run multiple index creations in parallel. */ hspool->sortstate = tuplesort_begin_index_hash(heap, index, hash_mask, maintenance_work_mem, false); return hspool; }