[elephant-devel] standard routine or idiom to clear BDB from within Lisp?

Andrew Philpot philpot at ISI.EDU
Wed Jan 18 18:22:43 UTC 2006


The following tends to hang.

(defun clear-from-root (&key (store-path *dbpath*)
                             (verbose t))
  (let ((remcount 0)
	(errcount 0))
    (with-open-store (store-path)
      (let ((btree (controller-root *store-controller*)))
	(with-btree-cursor (cursor btree)
	  (loop (multiple-value-bind (more k v)
		    (ignore-errors (cursor-next cursor))
		  (declare (ignorable v))
		  (if (typep k 'error)
		      (progn
			(incf errcount)
			(when verbose
			  (warn "Error was ~A" k)))
		    (progn
		      (unless more (return nil))
		      (when verbose
			(format *debug-io* "~%Dropped ~S -> ~S" k v))
		      (remove-kv k btree)
		      (incf remcount))))))))
    (values remcount
	    errcount)))



More information about the elephant-devel mailing list