[rucksack-devel] Re: Error when deleting indexed objects
Brad Beveridge
brad.beveridge at gmail.com
Tue Jan 22 06:08:21 UTC 2008
On 20/01/2008, Brad Beveridge <brad.beveridge at gmail.com> wrote:
> I've run into an error when deleting classes that have slots that are
> indexed by string. The problem only occurs when you close & reopen
> the Rucksack before deleting, which makes me suspect it is something
> to do with the proxying. I've tried to debug this, but I'm so far not
> getting much traction :)
> I'm going to keep looking at it, in the meantime here is a repro testcase.
>
> Cheers,
> Brad
>
> (with-rucksack (rs *test-suite* :if-exists :supersede)
> ; Works
> (with-transaction ()
> (defclass broken ()
> ((string-key :initarg :data :accessor string-key
> :index :string-index))
> (:index t)
> (:metaclass persistent-class))
> (make-instance 'broken :data "foo1")
> (make-instance 'broken :data "foo2")
> (rucksack-map-class rs 'broken
> (lambda (obj)
> (format t "Found ~A~%" (string-key obj))))
> (rucksack-map-slot rs 'broken 'string-key
> (lambda (obj)
> (rucksack::rucksack-delete-object rs obj))
> :equal "foo1")
> (rucksack-map-class rs 'broken
> (lambda (obj)
> (format t "Found ~A~%" (string-key obj))))
> ))
>
> (progn
> ; Broken
> (with-rucksack (rs *test-suite* :if-exists :supersede)
> (with-transaction ()
> (defclass broken ()
> ((string-key :initarg :data :accessor string-key
> :index :string-index))
> (:index t)
> (:metaclass persistent-class))
> (make-instance 'broken :data "foo1")
> (make-instance 'broken :data "foo2")
> (rucksack-map-class rs 'broken
> (lambda (obj)
> (format t "Found ~A~%" (string-key obj))))
> ))
>
> (with-rucksack (rs *test-suite*)
> (with-transaction ()
>
> (rucksack-map-slot rs 'broken 'string-key
> (lambda (obj)
> (rucksack::rucksack-delete-object rs obj))
> :equal "foo1")
> (rucksack-map-class rs 'broken
> (lambda (obj)
> (format t "Found ~A~%" (string-key obj))))
> )))
>
I've made some progress. The problem is due to KEY-POSITION using
P-EQL when trying to find the position of a key in the index. It
really should be more like
(defun key-position (btree key node)
(p-position key (btree-node-index node)
:key #'binding-key
:test (btree-key= btree)
:end (btree-node-index-count node)))
However, that doesn't work either because the largest key in the index
will have a key of KEY-IRRELEVENT - clearly a special case.
Am I making sense here? I guess the correct place to handle the
special case is in BTREE-KEY=
Cheers
Brad
More information about the rucksack-devel
mailing list