[elephant-devel] Storing objects in the root when don't care about the key / add same key to root more than once
Ian Eslick
eslick at csail.mit.edu
Mon May 28 22:11:09 UTC 2007
Here is a proposal for approaching this problem. Currently the only
problem with depending on foreign uses of OIDs is migration. There
is an interface of sorts already, although I'm sure it could be
improved or cleaned up with a little bit of work. If future features
(i.e. online GC) add any other limitations on OID use, we can define
the interface to that then.
Today, to support migrating a custom data structure that uses OIDs
instead of persistent object references, you need to write a method
on migrate that ensures the following:
1) Every object referenced by an OID in your data structure has been
copied to the target
(see below for how to do this yourself)
2) Use elephant::retrieve-copied-object to get the new object and
extract its OID
3) Write the new OIDs into your data structure replacing the old.
This can be done cleanly by iterating over your set of OIDs doing
something like this.
(defun copy-and-get-oid (old-store new-store old-oid class)
(let ((old (make-instance class :from-oid old-oid)))
(unless (elephant::object-was-copied-p old)
(migrate new-store old))
(elephant::oid (retrieve-copied-object old-store old))))
This means, however, that your data structure has to know the class
of the target OID apriori. This will be improved in the next release
or two by the addition of an OID->Class map in the store. I want to
make sure the performance impact is not too bad before I implement
this, so it may be some time.
Let me know if you have any questions about this.
Cheers,
Ian
On May 28, 2007, at 3:35 PM, Red Daly wrote:
> Ian Eslick wrote:
>> A few clarifications:
>>
>> It is poor coding practice to use system-assigned OIDs. In future
>> versions of elephant OIDs may change over time due to GC, auto
>> recovery of oid space, etc. It's sort oft like using the physical
>> address of an object in a C++ program. There is a legitimate way
>> to use OIDs outside of elephant, but we haven't yet defined an
>> interface for users to do so (for example you might want to use
>> OIDs to create many-to-many maps or efficient persistent sets)
>
> When can we expect this legitimate interface? And if it is not
> expected soon, do you have a favorite hack? I have wanted foreign
> references to persistent objects in ttaihe past, and I suspect
> other users run into situations, too.
>>
>> Ian
>
> Red
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel
More information about the elephant-devel
mailing list