Re: Review: GiST support for UUIDs - Mailing list pgsql-hackers

From Ildus Kurbangaliev
Subject Re: Review: GiST support for UUIDs
Date
Msg-id 20151225142340.46e577dd@lp
Whole thread Raw
In response to Re: Review: GiST support for UUIDs  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: Review: GiST support for UUIDs
List pgsql-hackers
On Fri, 25 Dec 2015 13:34:25 +0300
Teodor Sigaev <teodor@sigaev.ru> wrote:

> Thank you, but I have some notices about
> static float
> uuid_parts_distance(pg_uuid_t *a, pg_uuid_t *b)
> {
>      pg_uuid_t ua, ub;
>      const double mp = pow(2, -64);
>
>      uuid_cnv(a, &ua);
>      uuid_cnv(b, &ub);
>
>      Assert(ua.v64[0] > ub.v64[0]);
>      uint64 high = ua.v64[0] - ub.v64[0];
>      uint64 low = ua.v64[1] - ub.v64[1];
>      if (low > ua.v64[1])
>          high--;
>
>      return (float) (ldexp(high, 64) + (double) low * mp);
> }
>
> First, variables (high and low) should not be declared in the middle
> of code. Second, assert will fail if ua.v64[0] == ub.v64[0] and
> ua.v64[1] > ub.v64[1] although it's a possible and allowed case.
> Third, actually you multiply high value by 2^64 anf low by 2^-64.
> Seems, it's needed to do only one multiplication.

Thank you for review. Fixed.

--
Ildus Kurbangaliev
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment

pgsql-hackers by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: Review: GiST support for UUIDs
Next
From: Michael Paquier
Date:
Subject: Re: Commit fest status for 2015-11