Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
About MagmaPreallocatedDictionary
Last updated at 12:16 am UTC on 15 August 2011
A MagmaPreallocatedDictionary is a very special-purpose dictionary where performance is of utmost importance. MagmaPreallocatedDictionary provides O(1) access and the very fastest-possible access for this type of structure in the context of the Magma environment. Very simply, it is a standard Dictionary implementation except substituting a MagmaArray instead of the standard Array.

It is important to understand the nuances of using a MagmaPreallocatedDictionary. Note the adjective, "Preallocated", it means all the hash-slots of the Dictionary are pre-allocated. This dictionary will not grow anymore, meaning there is a cap to how large it will scale before
collisions are inevitable, which would begin to degrade performance.

Thankfully, the size of the support file on disk is actually only as
large as needs to be to accommodate the highest-used hash value.
Still, you will want to assume the highest-possible hash value could
be used.

It's 6-bytes per object-pointer so the file is

6 [highest-used-hash-value]

bytes in size. This makes the file on the server about 200 megabytes
after adding the first object, but it won't grow again until a higher hash is
used.

It is absolutely _essential_ that you do not allow any identityHash to
be part of your hash-calculation. Otherwise, it won't work;
identityHash'es differ between image sessions.