[elephant-devel] remove-current-kv does not work as advertised!
Ian Eslick
eslick at media.mit.edu
Wed Jun 4 15:18:56 UTC 2008
remove-current-kv assumes a fix to cursor-delete that robert and I
talked about that I forgot to do.
My proposal for this was to change the semantics so that the
consequences of cursor operations that assume the data is valid (i.e.
other than next/prev, etc) are undefined. In this way the cursor is
still valid after a delete, but only certain operations are guaranteed
to work. In a normal map operation, the map function would exit and
be called on the next item in the sequence.
Will these semantics work for postmodern?
Ian
On Jun 4, 2008, at 10:44 AM, Alex Mizrahi wrote:
> (defvar *current-cursor* nil
> "This dynamic variable is referenced only when deleting elements
> using the following function. This allows mapping functions to
> delete elements as they map. This is safe as we don't revisit
> values during maps")
>
> (defun remove-current-kv ()
> (unless *current-cursor*
> (error "Cannot call remove-current-kv outside of a map-btree or
> map-index function argument"))
> (cursor-delete *current-cursor*))
>
> it's supposed that while cursor is iterated in map-btree, we can
> remove current element and then jump to next.
>
> but cursor-delete leaves cursor unitialized, so cursor-next will
> instead jump to first item, and iteration will be restarted.
>
> so, finally it will work (i think), but it's damn slow and painful
> procedure.
>
> i think it's better to remove this functionality, or fix this. if we
> are not going to change cursor-delete
> semantics, a way to delete item without making cursor unintialized
> is something like:
>
> (defun remove-current-kv ()
> (unless *current-cursor* (error "Cannot call remove-current-kv
> outside of a map-btree or map-index function argument"))
> (let ((c (cursor-duplicate *current-cursor*)))
> (cursor-delete c)))
>
> but i dunno if it will work in BDB
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel
More information about the elephant-devel
mailing list