[rucksack-devel] indexing issue?
Arthur Lemmens
alemmens at xs4all.nl
Thu Nov 30 18:43:17 UTC 2006
Cyrus Harmon wrote:
> What is the intended behavior of a unique slot?
If a class has a unique slot, you (the programmer) promise that there
won't be two instances of that class which have a 'similar' value
for that slot. The definition of 'similar' depends on the kind of
index you create (see the predefined index specs in index.lisp for
some examples).
> I'm able to make-instance new instances of a persistent class with
> a duplicate slot value
Yes, I think that Rucksack doesn't check for this at the moment.
But it should have signalled an error, I think.
> which seems fine
I don't think so ;-)
> I'm even able to add-rucksack-root these instances.
All class and slot indexes are automatically added to the root set.
So if you create an instance of a class that has an indexed slot,
that instance will automatically be reachable from the roots and it
won't be removed by Rucksack's garbage collector.
So in this case it doesn't really matter that you called ADD-RUCKSACK-ROOT.
> I try to rucksack-map-slot over the index with the uniqueness
> constraint, I get a subset of the objects, containing unique slots.
Yes. I'd guess that you get those objects that were created most
recently. But that's just an accident: you're not supposed to create
two instances of the same class with the same value for a unique slot.
> Should the add-rucksack-root be failing in this case
No, I think that the second MAKE-INSTANCE (where you try to 'create'
the duplicate slot value) should fail already. I'll add a check for
that as soon as I have time.
(My guess is that this should be pretty easy, and you may want to try
this yourself. Probably adding an :ERROR keyword argument to the right
call to BTREE-INSERT will do the trick.)
Arthur
More information about the rucksack-devel
mailing list