Persisting IdentityDictionary

Chris Muller asqueaker at gmail.com
Wed Apr 20 00:23:17 UTC 2011


On Mon, Apr 18, 2011 at 9:29 PM, Elliot Finley <efinley.lists at gmail.com> wrote:
> Chris or whoever may be able to answer,
>
> I'm in the process of evaluating Aida/Web.  Part of the evaluation is
> obviously the different persistence strategies.  Its default strategy
> is to use the image and just take a snapshot every hour.  That works
> for some people but I really don't feel comfortable with that strategy
> for many reasons I won't go into.
>
> I would really like to use Magma to persist my object graph.  At first
> glance it looks simple, just use Magma like normal and persist the
> graph.  But upon closer inspection, it turns out that one of the
> features that makes Aida/Web so appealing and so easy to use also
> makes it difficult (I think, I hope I'm wrong) to persist with
> anything other than the image or Gemstone.
>
> 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:

  - 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.
  - 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.

>  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.

 - Chris


More information about the Magma mailing list