[rucksack-devel] indexing issue?

Arthur Lemmens alemmens at xs4all.nl
Fri Dec 1 21:17:13 UTC 2006


Cyrus Harmon wrote:

> So does this mean that when I have an object of an indexed class I
> don't need to explicitly call add-rucksack-root?

Yes, that's right.  The class index itself is a Rucksack root, and
that index points to all instances of the class, so you don't need
to add it explicitly to the root set.

> Well, for starters there are cyclic lists and it looks like rucksacks
> answer to that is:
>
> Serializing circular lists isn't implemented yet.

Yes.  See my other reply.

>> What kind of cycles would you want to break, and why?
>
> Well, breaking them isn't the right answer, but somehow representing
> them in persistent storage would be nice.

See my other mail: cycles are OK, but only as long as the cycles
'pass through' objects that were explicitly declared to be persistent.

> Working on a test case. What I have is an object that contains a (non-
> persistent) object that points to itself. Which leads me to what is
> probably another fundamental misunderstanding on my part. What does
> rucksack do with objects of non-persistent classes?

It serializes them, assuming that they don't contain cycles.


> (defclass a-non-persistent-class ()
>    ((bogosity :accessor bogosity :initarg :bogosity)))
>
> (eval-when (:compile-toplevel :load-toplevel)
>    (rucksack:with-rucksack (rucksack *test-rucksack* #+nil :if-exists
> #+nil :supersede)
>      (rucksack:with-transaction ()
>
>        (defclass a-persistent-class ()
>          ((name :accessor name :initarg :name :index :string-index)
>           (info :accessor info :initarg :info))
>          (:metaclass persistent-class)
>          (:index t)))))
>
>
> (defun test-not-persistent-data-1 ()
>    (let ((np (make-instance 'a-non-persistent-class :bogosity 412)))
>      (rucksack:with-rucksack (rucksack *test-rucksack*)
>        (rucksack:with-transaction ()
>          (let ((p (make-instance 'a-persistent-class :name
> "moose" :info np)))
>            (print (name p)))))))
>
[SNIP]
>
> (defun test-not-persistent-data-2 ()
>    (let ((np (make-instance 'a-non-persistent-class :bogosity 412)))
>      (setf (bogosity np) np)
>      (rucksack:with-rucksack (rucksack *test-rucksack*)
>        (rucksack:with-transaction ()
>          (let ((p (make-instance 'a-persistent-class :name
> "moose" :info np)))
>            (print (name p)))))))
>
>
>
> test-persistent-data-1 seems to work fine and the slot in a-non-
> persistent-class is even preserved, it seems. yay!

Yes, that's expected.

> but, when you go to run test-not-persistent-data-2 you get stuck on a
> loop.

And this is expected too.

> yes, perhaps this is a contrived situation, but it's the situation I
> find myself when trying to shoe-horn my existing classes into rucksack.

I understand.  But I think that the best approach for you would be to
add (:METACLASS PERSISTENT-CLASS) to your existing DEFCLASS forms.  I
would think that isn't too much work, even if you have lots of class
definitions.

> So, in summary, there are two separate issues it seems, cyclic lists,
> which are not supported but which throw an error

This could be fixed quite easily.  Have a look at serialize.lisp to get
a feeling for how this could be done.

> and persistent objects that contain objects that point to themselves
> which just hang.

Yes.  That's not very likely to change.

Arthur




More information about the rucksack-devel mailing list