src/backend/access/hash/hashsort.c
HSpool *
_h_spoolinit(Relation heap, Relation index, uint32 num_buckets)
{
	HSpool	   *hspool = (HSpool *) palloc0(sizeof(HSpool));

	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.
	 */
	hspool->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,
												   hspool->hash_mask,
												   maintenance_work_mem,
												   false);

	return hspool;
}
/*
 * create and initialize a spool structure
 */
create and initialize a spool structure
create and initialize a spool structure
HSpool *
_h_spoolinit(Relation heap, Relation index, uint32 num_buckets)
{
	HSpool	   *hspool = (HSpool *) palloc0(sizeof(HSpool));
	hspool->index = index;
	hspool->hash_mask = (((uint32) 1) << _hash_log2(num_buckets)) - 1;
	hspool->sortstate = tuplesort_begin_index_hash(heap,
												   index,
												   hspool->hash_mask,
												   maintenance_work_mem,
												   false);
	return hspool;
}
HSpool * _h_spoolinit ( Relation heap , Relation index , uint32 num_buckets ) { HSpool * hspool = ( HSpool * ) palloc0 ( sizeof ( HSpool ) ) ; hspool -> index = index ; hspool -> hash_mask = ( ( ( uint32 ) 1 ) << _hash_log2 ( num_buckets ) ) - 1 ; hspool -> sortstate = tuplesort_begin_index_hash ( heap , index , hspool -> hash_mask , maintenance_work_mem , false ) ; return hspool ; }
create and initialize a spool structure
create and initialize a spool structure
/*
	 * 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.
	 */ /*
	 * 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.
	 */