Page 1 of 1

OT4XB - _HDICT_NEW()

Posted: Thu Dec 06, 2018 2:21 am
by unixkd

Code: Select all

static function randomtest()                                                                                                                                                                                        
local nSeconds := Seconds()  
local n, aTest[0], MAX_LOOP := 3000000                                                  
local pHt      := _HDICT_NEW(,MAX_LOOP)                                       

for n := 1 to MAX_LOOP                                                        
   _HDICT_SETPROP(pHt,cBin2Hex(cGenRndStr(8,.T.)), 0)                         
   // cBin2Hex() is needed here as the hash table is case insensitive         
next                                                                          
aadd(aTest,{" Elapsed Time: %i Seconds " , Seconds() - nSeconds})                   
aadd(aTest,{" %i Items  %i Duplicates",MAX_LOOP , MAX_LOOP - _HDICT_COUNT(pHt)} )
DC_Arrayview(aTest)                                                                 
return NIL  
This sample program gives IDSC error when the value of the MAX_LOOP is high eg 5000000

Joe

Re: OT4XB - _HDICT_NEW()

Posted: Thu Dec 06, 2018 7:00 am
by patito
Hi

have asked Pablo and he told me that: Current versions of ot4xb hash table
using malloc/free to alloc the memory that rely on the common process heap,
this works faster that using it's own heap but reduce the number of handles
so the capacity is around the half million items.

With a custom heap the limit will be the 2GB. I was tempted lot of times
to enhance it to support a custom heap like in the _tlist_* functions,
but usually for big recordsets open sqlite ":memory:" and temporary ""
databases working so well so the feature was stucked forever
in the todo list as never needed in production scenaries

Best Regard
Héctor