[elephant-devel] Storing objects in the root when don't care about the key / add same key to root more than once
Joubert Nel
joubert at joubster.com
Mon May 28 13:26:30 UTC 2007
On Mon, 2007-05-28 at 08:51, Ian Eslick wrote:
> A few clarifications:
>
> Standard persistent classes are not saved by default. To get access
Ian, when are objects that are instanced from persistent classes saved?
I simply call (make-instance) on the following class definition:
(defclass risk ()
((title :accessor title :initarg :title :initform ""))
(:metaclass elephant:persistent-metaclass)
(:index t))
the resulting object is immediately saved/persisted by Elephant...
> to a class via the map-class operator the class or a slot of the
> class must be declared as :indexed. If a slot is indexed, then that
> value can be used as a key for the object via the get-instances-by-
> value interface. Moreover, you can have duplicate slot values and
> get-instances-by-value will return all the objects having that slot
> value.
Understood - this is what I got from the documentation as well.
>
> Think of the root more like a hash table (single key-value pair)
> instead of a set or collection. The simple get-value interface would
> be more complex if it could return multiple values.
My impression until I saw how persistent objects behave was that
everything you want to store via Elephant had to be "rooted".
>
> 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 of 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)
Thanks for this insight. Many-to-many maps and sets are exactly what I'm
trying to achieve.
I found a newly released UUID package for Lisp -
http://www.cl-user.net/asp/libs/uuid
I'm going to explore using this instead of OIDs.
Joubert
More information about the elephant-devel
mailing list