Persisting IdentityDictionary

Elliot Finley efinley.lists at gmail.com
Wed Apr 20 05:31:09 UTC 2011


On Tue, Apr 19, 2011 at 6:23 PM, Chris Muller <asqueaker at gmail.com> wrote:
> On Mon, Apr 18, 2011 at 9:29 PM, Elliot Finley <efinley.lists at gmail.com> wrote:
>>
>> Aida/Web keeps two dictionaries:
>>
>> URL -> Object (Dictionary)
>> Object -> URL (IdentityDictionary)
>>
>> If these aren't persisted in an external database, then they'll keep a
>> reference to every object used in the web application in your image,
>> thus negating the benefits of using an external database in the first
>> place.
>
> I do not care for the particular design choice of several frameworks
> using global variable.  That's just my taste, it's not a big problem
> for Magma; you can just put your root object as a key in the global
> dictionary.  Given these axioms:

In Aida's (Janko's) defense, these are not true global variables.
They are instance variables in a Class called URLResolver that is used
by the WebRouter.  But they do end up holding a reference to every
object in the model.

>  - if the model is small, it'll fit into memory; ACID db properties
> are retained.
>  - that if the model is large, you might be using large-capable
> objects like MagmaCollections, which page out objects.

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.

>  - if your model is large and rich (e.g., not using MagmaCollections)
> then you have #stubOut: to trim off the branches.
>
> Beyond that, the idea of Squeak is that it's a modifiable system.
> This particular aspect of Aida would be easy to improve on if none of
> the above is satisfactory.  For example, instead of a global
> Dictionary, a intermediate Broker or Listener could solve this issue.
> Contribute it back to Janko.

Would you be kind enough to expand on the intermediate Broker/Listener approach?

>>  The Dictionary is easy.  The IdentityDictionary is using the
>> Object's identityHash as the key and I don't see any easy way to make
>> that work.
>
> There's nothing you need to do.  IdentityDictionary's work fine.
> Magma maintains its own identity "oid" for each object that is totally
> independent of the Squeak-image identity, which is what
> IdentityDictionary is based on.
>
> If you're curious, just look at the "*ma object serialization" methods
> of Dictionary, you'll understand why it works; it simply uses #at:put:
> to materialize the IdentityDictionary.

This is good to know.  I appreciate you taking the time to explain it.

Thanks,
Elliot


More information about the Magma mailing list