Skip site navigation (1) Skip section navigation (2)

hashlittle(), hashbig(), hashword() and endianness

From: Alex Vinokur <alexvn(at)users(dot)sourceforge(dot)net>
To: pgsql-patches(at)postgresql(dot)org
Subject: hashlittle(), hashbig(), hashword() and endianness
Date: 2007-11-15 08:40:19
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
On Oct 27, 10:15 pm, k(dot)(dot)(dot)(at)rice(dot)edu (Kenneth Marshall) wrote:
> Dear PostgreSQL Developers,
> This patch is a "diff -c" against the hashfunc.c from postgresql-8.3beta1.
> It implements the 2006 version of the hash function by Bob Jenkins. Its
> features include a better and faster hash function. I have included the
> versions supporting big-endian and little-endian machines that will be
> selected based on the machine configuration.

I have some question concerning Bob Jenkins' functions
hashword(uint32_t*, size_t), hashlittle(uint8_t*, size_t) and
hashbig(uint8_t*, size_t) in lookup3.c.

Let k1 by a key: uint8_t* k1; strlen(k1)%sizeof(uint32_t) == 0.

1. hashlittle(k1) produces the same value on Little-Endian and Big-
Endian machines.
   Let hashlittle(k1) be == L1.

2. hashbig(k1) produces the same value on Little-Endian and Big-Endian
   Let hashbig(k1) be == B1.

  L1 != B1

3. hashword((uint32_t*)k1) produces
    * L1 on LittleEndian machine and
    * B1 on BigEndian machine.

The question is: is it possible to change hashword() to get
    * L1 on Little-Endian machine and
    * B1 on Big-Endian machine


Alex Vinokur
     email: alex DOT vinokur AT gmail DOT com

In response to


pgsql-patches by date

Next:From: Alex VinokurDate: 2007-11-15 10:56:21
Subject: Re: hashlittle(), hashbig(), hashword() and endianness
Previous:From: Tom LaneDate: 2007-11-14 23:49:35
Subject: Re: Doc patch to clarify text search example

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group