(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@common-lisp.net
http://common-lisp.net/mailman/listinfo/elephant-devel

Reply via email to