Re: Allow simplehash to use already-calculated hash values - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Allow simplehash to use already-calculated hash values
Date
Msg-id 20190717185940.jlxe5ksci6g7ttl2@alap3.anarazel.de
Whole thread Raw
In response to Re: Allow simplehash to use already-calculated hash values  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Allow simplehash to use already-calculated hash values
List pgsql-hackers
Hi,

On 2019-07-17 11:17:46 -0700, Jeff Davis wrote:
> From a6aba8e53f7a36a42922add68098682c2c96683e Mon Sep 17 00:00:00 2001
> From: Jeff Davis <jdavis@postgresql.org>
> Date: Wed, 17 Jul 2019 10:52:15 -0700
> Subject: [PATCH] Allow simplehash to use already-calculated hash values.
> 
> Add _lookup_hash and _insert_hash functions for callers that have
> already calculated the hash value of the key.

I've not tested it, but this looks reasonable to me. Do you actually
need the lookup variant, or is that more for completeness?


> This is intended for use with hash algorithms that write to disk in
> partitions. The hash value can be calculated once, used to perform a
> lookup, used to select the partition, then written to the partition
> along with the tuple. When the tuple is read back, the hash value does
> not need to be recalculated.

nitpick^3: I'd s/This is intended for use/The immediate use-case is/


> +static inline    SH_ELEMENT_TYPE *
> +SH_INSERT_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)

I'd perhaps add a comment here along the lines of:

/*
 * This is a separate static inline function, so it can be reliably be inlined
 * into its wrapper functions even if SH_SCOPE is extern.
 */

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Darafei "Komяpa" Praliaskouski
Date:
Subject: Unwanted expression simplification in PG12b2
Next
From: Tom Lane
Date:
Subject: Re: Change ereport level for QueuePartitionConstraintValidation