Re: GiST penalty functions [PoC] - Mailing list pgsql-hackers

From Andrew Borodin
Subject Re: GiST penalty functions [PoC]
Date
Msg-id CAJEAwVHP_oQg39cZYbix7F5-Ubx4WS+eoFY-2UhKu3_7=gTPhA@mail.gmail.com
Whole thread Raw
In response to Re: GiST penalty functions [PoC]  (Andrew Borodin <borodin@octonica.com>)
Responses Re: GiST penalty functions [PoC]  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
Well, arithmetics is too fragile.

This version of float packing with arithmetical packaging
static float
pack_float(float actualValue, int realm)
{
double max,min;
max = FLT_MAX / ( 8 >> realm );
min = FLT_MAX / ( 16 >> realm );
if( realm == 0 )
min = 0;
/* squeeze the actual value between min and max */
return ( min + (actualValue * ( max - min ) / FLT_MAX));
}

Inserts are the same as of bithacked pack_float, but selects are 5 times slower.
When we are trying to pack value linearly into range we loose too much bits.
Here is how it happens: in floats addition of small values to big
values causes loss of small values.
Applied to Heikki's algorithm this means that nV, nE and dV can all be
in different mantissa ranges. (Please note that dV ca be many times
more than nV and many times smaller that nV)

Integer bitshift of a float have no arithmetical meaning. It would be
hard to describe in formulas what carring of mantissa bit to
significant field mean. But this bitshift preserves an order among
almost all float values (except 2 controllably lost bits and some
values become sNaN ). Entire idea of the advanced GiST penalty stands
on this.

The other way is to add to API optional handler which executes all of
choose subtree algorithm inside cube (or other extension).

Best regards, Andrey Borodin, Octonica & Ural Federal University.



pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: Re: Hash Indexes
Next
From: Peter Geoghegan
Date:
Subject: Re: amcheck (B-Tree integrity checking tool)