[rucksack-devel] indexing issue?

Arthur Lemmens alemmens at xs4all.nl
Thu Nov 30 20:26:15 UTC 2006


Cyrus Harmon wrote:

>> No.  But if you MAKE-INSTANCE a persistent object that has a slot
>> or a class index (or, to be more precise, if you MAKE-INSTANCE a
>> persistent object that is added to a slot or class index), you can
>> be sure that Rucksack's garbage collector won't remove that object
>> behind your back.
>
> or added with add-rucksack-root, I imagine.

Right.

Or if you add it to any persistent datastructure (e.g. a persistent
cons, or a persistent vector, or a persistent btree) that is reachable
 from the roots.

> Oh? is using the index the only way to find it?

No.

It's really just like in 'normal' Lisp.  You can decide to bypass
the entire indexing structure that Rucksack provides, and just
build your own persistent datastructures.

Maybe you need a persistent queue of incoming messages, for example.
You can build such a queue on top of Rucksack's persistent conses,
persistent vectors or other persistent objects.  You may not need
any indexing for such a queue.  As long as you put the head of the
queue into the root set, you can do whatever you want.

This is not a relational database, it's persistent Lisp objects ;-)

> I view indices as an optimization, rather than the canonical
> interface to the data.

I agree, but maybe not in the way that you think.  In Rucksack, the
canonical interface to the data is other data.

> If I wanted to say, map-slots over a non-indexed slot, I assume
> that would still work, right?

Well... at the moment it wouldn't signal an error, but it wouldn't
find anything either.  Maybe you're right: as long as there is a
class index, it would be possible in principle to iterate over
all instances of the class and do something equivalent to MAP-SLOTS
for an indexed slot.  But it's also possible to define persistent
classes without a class index; in that case, there would be no way
for MAP-SLOTS to find all instances of a class, and it couldn't do
what you expect it to do.

> is map-rucksack-roots not a preferred way to find things?

It's one way.  To find something you have to start with
map-rucksack-roots or with some function that uses the indexing
mechanisms.

> I notice that there is a rucksack-map-objects, which sounds
> reasonable, but that it is #+later'ed out. Can you shed some
> light on this?

My idea was to build some kind of Lisp equivalent to SQL's WHERE.
But I didn't get around to designing or implementing that yet.

> Ok, but if you make-instance something with an index and it gets
> added to the index, surely there's a way to remove it from the index,
> no?

The easiest way is probably to use SLOT-MAKUNBOUND.  This should
sooner or later call RUCKSACK-MAYBE-INDEX-CHANGED-SLOT, which
will call INDEX-DELETE to remove the association between the
old slot value and the object instance from the index.

> Finally, one further question... what does rucksack do about cycles?

Nothing special, really.  I'm not sure that I understand your question.

> Is there a way to break cycles

What kind of cycles would you want to break, and why?

> When I try to add an object that points to itself rucksack seems
> to spin forever.

If it does, that's a bug.  Can you show me the code that does this?

Arthur




More information about the rucksack-devel mailing list