[elephant-devel] how to rebuild a class index ?

Pierre-François Gomez pef.gomez at gmail.com
Sat Apr 29 18:40:39 UTC 2006


Hello,

I'd like to rely on the class indexing feature and the get-instances-by...
methods so that I don't need to manually store my persistent objects
in the root (or in any other explicit collection) to get hold of them.

I don't know if it is a good idea, but it seems to work fine... well,
as long as I don't quit lisp, anyway :)

But after I restart it, I can't get hold of them anymore, as you can
see from this transcript (with an empty store) :


CORE> (open-store *notebook-store*)
#<SLEEPYCAT::BDB-STORE-CONTROLLER {BD7BC71}>
CORE> (enable-class-indexing 'notebook-object nil)
; Evaluation aborted
CORE> (enable-class-indexing (find-class 'notebook-object) nil)
#<SLEEPYCAT::BDB-INDEXED-BTREE {C5BB2B9}>
CORE> (make-instance 'notebook-object)
#<NOTEBOOK-OBJECT {BAD2BD9}>
CORE> (make-instance 'notebook-object)
#<NOTEBOOK-OBJECT {BB31481}>
CORE> (make-instance 'notebook-object)
#<NOTEBOOK-OBJECT {BB34461}>
CORE> (get-instances-by-class 'notebook-object)
(#<NOTEBOOK-OBJECT {BB34461}> #<NOTEBOOK-OBJECT {BB31481}>
 #<NOTEBOOK-OBJECT {BAD2BD9}>)
CORE> (close-store)
NIL
CORE> (open-store *notebook-store*)
#<SLEEPYCAT::BDB-STORE-CONTROLLER {BD910C1}>
CORE> (get-instances-by-class 'notebook-object)
(#<NOTEBOOK-OBJECT {BDA5C01}> #<NOTEBOOK-OBJECT {BDA4C49}>
 #<NOTEBOOK-OBJECT {BDA39D9}>)
CORE> (close-store)
NIL

;; ... ,sayoonara ...
;; restart

CORE> (open-store *notebook-store*)
#<SLEEPYCAT::BDB-STORE-CONTROLLER {BF31809}>
CORE> (get-instances-by-class 'notebook-object)
; Evaluation aborted

fails with :
Class #<PERSISTENT-METACLASS NOTEBOOK-OBJECT> is not an indexed class
   [Condition of type SIMPLE-ERROR]

So I :

CORE> (enable-class-indexing (find-class 'notebook-object) nil)
; Evaluation aborted

fails with :
Class is already enabled for indexing!  Run disable class indexing to clean up.
   [Condition of type SIMPLE-ERROR]

My toy class is defined with :

(defclass notebook-object ()
  ((name)
   (creation-time)
   (last-modified-time))
  (:metaclass persistent-metaclass))

I guess this has to do with caching and the fact that only new
instances are indexed, but I haven't found (yet) how to manually
rebuild the class index from the stored objects.

Also, I wonder if they're actually stored or not, but I think they
are, judging from :
http://common-lisp.net/pipermail/elephant-devel/2006-March/000370.html

For information, I'm now using sbcl 0.9.12, still on linux, and with
a cvs head elephant from about 8 hours ago.

-- Pierre-François



More information about the elephant-devel mailing list