Re: [PATCHES] hashlittle(), hashbig(), hashword() and endianness

2007-11-19 Thread Marko Kreen
On 11/16/07, Alex Vinokur <[EMAIL PROTECTED]> wrote:
> I would like to use both hashlittle() and hashword() (or
> hashword_little) on little-endian and big-endian machine and to get
> identical hashValues.

Whats wrong with hashlittle()?  It does use the same optimized
reading on LE platform that hashword() does.  Or you could wrap
the read values with some int2le() macro that is NOP on LE cpu.
Although I suspect the performance wont be better than using
hashlittle() directly.

-- 
marko

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [PATCHES] hashlittle(), hashbig(), hashword() and endianness

2007-11-16 Thread Kenneth Marshall
On Fri, Nov 16, 2007 at 01:19:13AM -0800, Alex Vinokur wrote:
> On Nov 15, 1:23 pm, [EMAIL PROTECTED] (Heikki Linnakangas)
> wrote:
> > Alex Vinokurwrote:
> > > On Nov 15, 10:40 am,Alex Vinokur<[EMAIL PROTECTED]>
> > > wrote:
> > > [snip]
> > >> 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
> > >> machines.
> > >>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
> > >>?
> >
> > > Sorry, it should be as follows:
> >
> > > Is it possible to create two new hash functions on basis of
> > > hashword():
> > >i)  hashword_little () that produces L1 on Little-Endian and Big-
> > > Endian machines;
> > >ii) hashword_big ()that produces B1 on Little-Endian and Big-
> > > Endian machines
> > >?
> >
> > Why?
> >
> [snip]
> 
> Suppose:
> uint8_t chBuf[SIZE32 * 4];  // ((size_t)&chBuf[0] & 3) == 0
> 
> Function
> hashlittle(chBuf, SIZE32 * 4, 0)
> produces the same hashValue (let this value be L1) on little-endian
> and big-endian machines. So, hashlittle() is endianness-indepent.
> 
> On other hand, function
> hashword ((uint32_t)chBuf, SIZE32, 0)
> produces hashValue == L1 on little-endian machine and hashValue != L1
> on big-endian machine. So, hashword() is endianness-dependent.
> 
> I would like to use both hashlittle() and hashword() (or
> hashword_little) on little-endian and big-endian machine and to get
> identical hashValues.
> 
> 
> Alex Vinokur
>  email: alex DOT vinokur AT gmail DOT com
>  http://mathforum.org/library/view/10978.html
>  http://sourceforge.net/users/alexvn
> 
> 
Alex,

As I suspected, you want a hash function that is independent of the
machine endian-ness. You will need to design, develop, and test such
a function yourself. As you start to look at how overflow, rot's, and
shifts are handled at the boundaries you may find it difficult to
get a fast hash function with those properties. Good luck.

Regards,
Ken

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [PATCHES] hashlittle(), hashbig(), hashword() and endianness

2007-11-16 Thread Alex Vinokur
On Nov 15, 1:23 pm, [EMAIL PROTECTED] (Heikki Linnakangas)
wrote:
> Alex Vinokurwrote:
> > On Nov 15, 10:40 am,Alex Vinokur<[EMAIL PROTECTED]>
> > wrote:
> > [snip]
> >> 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
> >> machines.
> >>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
> >>?
>
> > Sorry, it should be as follows:
>
> > Is it possible to create two new hash functions on basis of
> > hashword():
> >i)  hashword_little () that produces L1 on Little-Endian and Big-
> > Endian machines;
> >ii) hashword_big ()that produces B1 on Little-Endian and Big-
> > Endian machines
> >?
>
> Why?
>
[snip]

Suppose:
uint8_t chBuf[SIZE32 * 4];  // ((size_t)&chBuf[0] & 3) == 0

Function
hashlittle(chBuf, SIZE32 * 4, 0)
produces the same hashValue (let this value be L1) on little-endian
and big-endian machines. So, hashlittle() is endianness-indepent.

On other hand, function
hashword ((uint32_t)chBuf, SIZE32, 0)
produces hashValue == L1 on little-endian machine and hashValue != L1
on big-endian machine. So, hashword() is endianness-dependent.

I would like to use both hashlittle() and hashword() (or
hashword_little) on little-endian and big-endian machine and to get
identical hashValues.


Alex Vinokur
 email: alex DOT vinokur AT gmail DOT com
 http://mathforum.org/library/view/10978.html
 http://sourceforge.net/users/alexvn




---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [PATCHES] hashlittle(), hashbig(), hashword() and endianness

2007-11-15 Thread Alex Vinokur
On Nov 15, 10:40 am, Alex Vinokur <[EMAIL PROTECTED]>
wrote:
[snip]
> 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
> machines.
>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
>?

Sorry, it should be as follows:

Is it possible to create two new hash functions on basis of
hashword():
   i)  hashword_little () that produces L1 on Little-Endian and Big-
Endian machines;
   ii) hashword_big ()that produces B1 on Little-Endian and Big-
Endian machines
   ?



Thanks.

Alex Vinokur
 email: alex DOT vinokur AT gmail DOT com
 http://mathforum.org/library/view/10978.html
 http://sourceforge.net/users/alexvn


---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate


Re: [PATCHES] hashlittle(), hashbig(), hashword() and endianness

2007-11-15 Thread Heikki Linnakangas

Alex Vinokur wrote:

On Nov 15, 10:40 am, Alex Vinokur <[EMAIL PROTECTED]>
wrote:
[snip]

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
machines.
   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
   ?


Sorry, it should be as follows:

Is it possible to create two new hash functions on basis of
hashword():
   i)  hashword_little () that produces L1 on Little-Endian and Big-
Endian machines;
   ii) hashword_big ()that produces B1 on Little-Endian and Big-
Endian machines
   ?


Why?

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[PATCHES] hashlittle(), hashbig(), hashword() and endianness

2007-11-15 Thread Alex Vinokur
On Oct 27, 10:15 pm, [EMAIL PROTECTED] (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.
[snip]

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
machines.
   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
   ?

Thanks.

Alex Vinokur
 email: alex DOT vinokur AT gmail DOT com
 http://mathforum.org/library/view/10978.html
 http://sourceforge.net/users/alexvn






---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq