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.
Ildus Kurbangaliev wrote:
> On Wed, 23 Dec 2015 16:36:23 -0800
> Paul Jungwirth <pj@illuminatedcomputing.com> wrote:
>
>> On 12/23/2015 08:10 AM, Ildus Kurbangaliev wrote:
>>> There is a more improved version of the patch. Main idea is to
>>> present uuid as two uint64 values, and make comparisons and penalty
>>> calculation based on these values. This approach is much faster
>>> than using memcmp for uuid comparisons.
>>
>> Thank you for picking this up! I'm sorry I was not able to work on it
>> the last few months. I'm very glad to see someone wrapping it up. I'm
>> not a reviewer, but personally it looks like a good change to me.
>>
>> Happy holidays,
>>
>> Paul
>>
>>
>>
>>
>
> Thanks! The patch was almost done and ready. I attached new version of
> the patch with compability changes.
>
--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/