Thank you for the explanation. I was mostly looking to see how to GC the group. Looks like a future feture. <br>
<br>
William<br><br><div><span class="gmail_quote">On 3/3/06, <b class="gmail_sendername">Robert L. Read</b> <<a href="mailto:read@robertlread.net">read@robertlread.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;">
Dear William,<br>
Welcome.<br>
<br>
Are you using 0.5 or the latest version from CVS (which has not quite been formally released yet)? <br>
I think this changes slightly based on which version you are using.<br>
<br>
Under the 0.5:<br>
<br>
I think the "Tutorial" on the section Persistent Classes <br>
<a href="http://common-lisp.net/project/elephant/doc/Persistent-Classes.html#Persistent-Classes" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://common-lisp.net/project/elephant/doc/Persistent-Classes.html#Persistent-Classes
</a><br>
shows how to do what you want; I'm pretty sure that it is accurate, but haven't actually done it.<br>
It shows placing the whole object into the root; I honestly would have to go back to 0.5 to <br>
say whether this is really necessary or not. You can try my code snippet below under 0.5 <br>
and see if it works. (We have been working on what will be 0.6 for quite a while.)<br>
<br>
Under the most recent CVS version:<br>
<br>
Yes, each time you make-instance a class with a metaclass of :persistent-metaclass, the instance<br>
is placed in the database with a unique OID. If you store the OID (for example in the root), you<br>
can can then close the store-controller, exit lisp, restart LISP, reopen the store-controller, and <br>
then either do (make-instance 'my-persistent-class :from-oid OID), or, if you have indexed a slot<br>
of enables class indexing on the class, you could you (get-instance-by-class 'my-persistent-class)<br>
<br>
ELE-TESTS> (defclass my-persistent-class ()<br>
((slot1 :accessor slot1)<br>
(slot2 :accessor slot2))<br>
(:metaclass persistent-metaclass))<br>
<br>
#<PERSISTENT-METACLASS MY-PERSISTENT-CLASS><br>
ELE-TESTS> (setq x (make-instance 'my-persistent-class))<br>
; loading system definition from /usr/local/share/lisp/ele-bdb.asd into<br>
; #<PACKAGE "ASDF1474"><br>
; registering #<SYSTEM ELE-BDB {AA32BE1}> as ELE-BDB<br>
STYLE-WARNING: implicitly creating new generic function BUILD-BTREE-INDEX<br>
#<SLEEPYCAT::BDB-STORE-CONTROLLER {B6C1941}><br>
ELE-TESTS> (setq x (make-instance 'my-persistent-class))<br>
#<MY-PERSISTENT-CLASS {B8BA3C1}><br>
ELE-TESTS> (elephant::oid x)<br>
14700<br>
ELE-TESTS> (close-store)<br>
NIL<br>
ELE-TESTS> (open-store *default-spec*)<br>
#<SLEEPYCAT::BDB-STORE-CONTROLLER {A97B6B1}><br>
ELE-TESTS> (make-instance 'my-persistent-class :from-oid 14700)<br>
#<MY-PERSISTENT-CLASS {A9FEE69}><br>
ELE-TESTS> <br>
<br>
In the file classindex.lisp, you can find:<br>
<br>
(defgeneric get-instances-by-class (persistent-metaclass))<br>
(defgeneric get-instances-by-value (persistent-metaclass slot-name value))<br>
(defgeneric get-instances-by-range (persistent-metaclass slot-name start end))<br>
<br>
which are very useful for this, and may mean you don't have to store the OID in the root if <br>
you "enable-class-indexing" on the class.</div><div style="direction: ltr;"><span class="e" id="q_109c09f58d7bf8b8_1"><br>
<br>
<br>
<br>
<br>
<br>
On Thu, 2006-03-02 at 17:11 -0500, William Halliburton wrote:<br>
</span></div><div style="direction: ltr;"><blockquote type="CITE"></blockquote></div><div style="direction: ltr;"><span class="e" id="q_109c09f58d7bf8b8_3">
<br>
<font color="#000000">Starting to use elephant with bdb backend. </font><br>
<br>
<font color="#000000">Please tell me if the following explanation is correct.</font><br>
<br>
<font color="#000000">Each
time I make-instance a class with a metaclass of :persistent-metaclass
the class is placed into the database with a unique OID. I can retrieve
this back with (make-instance 'class :with-oid OID). Now this object in
not in the root. Must I place it into the root? How do I remove old
objects?</font><br>
<br>
<font color="#000000">Thank you,</font><br>
<font color="#000000">William Halliburton</font>
</span></div><div style="direction: ltr;"><pre><font color="#000000">_______________________________________________</font><br><font color="#000000">elephant-devel site list</font><br><font color="#000000"><a href="mailto:elephant-devel@common-lisp.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
elephant-devel@common-lisp.net</a></font><br><font color="#000000"><a href="http://common-lisp.net/mailman/listinfo/elephant-devel" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://common-lisp.net/mailman/listinfo/elephant-devel
</a></font>
</pre>
</div><br>_______________________________________________<br>elephant-devel site list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:elephant-devel@common-lisp.net">elephant-devel@common-lisp.net
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://common-lisp.net/mailman/listinfo/elephant-devel" target="_blank">http://common-lisp.net/mailman/listinfo/elephant-devel</a><br><br></blockquote>
</div><br>