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. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers