Hi Przemek,

----- Original Message ----- From: "Przemyslaw Czerpak" <[EMAIL PROTECTED]>
To: "Harbour Project Main Developer List." <harbour@harbour-project.org>
Sent: Saturday, January 12, 2008 2:40 PM
Subject: Re: [Harbour] How reduce concatenation size of numeric fields inindex ?


[snip]

CDX will compress such indexes by default but if you want to compress
also single key then you will have to convert numeric value to
binary form.

I have thought to convert numeric decimal values in hex values, but I have
to store same 16 chars for every fields. Or am I in wrong ?

Nearly 16. Let's calculate it more precisely:
  ? log(10^16)/log(2) => 53.15
So you need at least 54 bits to hold such number. In hex encoding
each number holds information about 4 bits it means that you need
at least INT((54+3)/4) => 14 hex digits (it can be also calculated
as log(10^16)/log(16) => 13.29) As you can see you will not save
too much using hex conversion.
If you do not use national collation then you can use binary big
endian form and in such case for each number you will need 7 bytes
(log(10^16)/log(256) => 6.64). You can write your own function
for such conversion:

   HB_FUNC( HASHDEC16 )
   {
LONGLONG llValue = hb_parnll( 1 );
char * buffer[ 8 ];

/* if you are using possitive only number */
HB_PUT_BE_UINT64( buffer, llValue );

hb_retclen( buffer, 7 );
   }

and then create index on HASHDEC16(n1)+HASHDEC16(n2)+HASHDEC16(n3)
You will reduce the key size from 48 to 21.
But if you are using national collation then you should also
convert 'buffer' above to respect modified byte order. You can
create static byte table for such conversion to not reduce speed.
Unfortunately now we do not have an option to mark index as binary.
I'll add such functionality in the future.


Thank you, I will try

Best Regards,
Francesco


_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to