From: | Ildus Kurbangaliev <i(dot)kurbangaliev(at)postgrespro(dot)ru> |
---|---|
To: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Cc: | Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Review: GiST support for UUIDs |
Date: | 2015-12-25 11:23:40 |
Message-ID: | 20151225142340.46e577dd@lp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 25 Dec 2015 13:34:25 +0300
Teodor Sigaev <teodor(at)sigaev(dot)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 | Content-Type | Size |
---|---|---|
btree_gist_uuid_5.patch | text/x-patch | 122.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-12-25 11:32:40 | Re: Commit fest status for 2015-11 |
Previous Message | Teodor Sigaev | 2015-12-25 10:34:25 | Re: Review: GiST support for UUIDs |