Persisting IdentityDictionary

Elliot Finley efinley.lists at gmail.com
Mon Apr 25 20:48:57 UTC 2011


On Wed, Apr 20, 2011 at 10:28 AM, Chris Muller <asqueaker at gmail.com> wrote:
>> So my next question is:  Do you have any plans for a MagmaIdentityDictionary? :)
>>
>> Basically I need a MagmaCollection where I can use the object as the
>> key so I don't have to keep everything in memory.
>
> Well, MagmaCollections themselves are already identity-based; as in,
> #includes: anObject.
>
> But you should explain the larger picture of what you're trying to
> solve.  What do you need a huge IdentityDictionary for?

Aida/Web uses a huge IdentityDictionary to keep a stable obj -> url
relationship and a huge Dictionary to keep a stable url -> obj
relationship.  This is how it accomplishes one of it's nicest features
- simple obj to obj refs in code translate to urls in the webpage.

so when I say:

e addLinkTo: address text: address lastName.

it checks the IdentityDictionary to see what URL was used for
'address' last time, and it uses it again.  If this is the first time,
then it creates the entries in the dictionaries.  There are also some
checks to make sure duplicate URLs aren't used, etc... but that's the
jest of it.

If I were to subclass MagmaPreallocatedDictionary and change:

MagmaPreallocatedDictionary>>keyHash: key
     ^ (key hash \\ maxBuckets) + 1

to this:

MagmaPreallocatedDictionary>>keyHash: key
     ^ (key aSelectorThatAnswersMagmaOID \\ maxBuckets) + 1

I would essentially have a MagmaPreallocatedIdentityDictionary, would
I not?  The only problem is, looking through the Magma code, it's not
immediately obvious how to implement aSelectorThatAnswersMagmaOID.  Is
there a simple way to get that?

Thanks,
Elliot


More information about the Magma mailing list