Next: , Previous: , Up: SCM Interface   [Contents][Index]

6.6 SCM Multiple Operations

Scheme Procedure: bt:rem* han key1 key2

Removes keys (and their associated values) between (including) key1 and (not including) key2 from bt han. A status code is returned.

Scheme Procedure: bt:scan han op key1 key2 func blklimit

Applies procedure func to a range of keys (and values) and either counts, modifies, or deletes those associations. A list of a status code, the count of records processed, and a new value for key1 is returned.

If op is -1, indicated keys will be deleted; If op is 0, indicated keys will be counted; If op is 1, the value of each key in the range will be changed to be the string returned by func.

Func is called with 2 string arguments, the key and the value. If op is 1 and func returns #f then no change will be made. If op is 1 and func returns a string then that string will replace the value for that key. For the other (count, delete) modes, func should return #f or #t. If func is #t, the association will be counted (and possibly deleted).

Keys from key1 (inclusive) up to key2 (exclusive) are scanned. If blklimit is -1 then the entire range is scanned; otherwise only as many blocks (internal database structures) as specified by blklimit are scanned. The scan can be restarted by using the returned information. For instance, the following expression counts the number of keys between "3" and "4" one block at a time and returns a list of the number of keys and the number of blocks.

(do ((res (bt:scan current-bt 0 "3" "4" (lambda (k v) #t) 1)
          (bt:scan current-bt 0 (caddr res) "4" (lambda (k v) #t) 1))
     (blks 0 (+ 1 blks))
     (cnt 0 (+ cnt (cadr res))))
    ((not (= -1 (car res))) (list (+ cnt (cadr res)) (+ 1 blks))))

It is good to specify a positive blklimit when dealing with large scans. More details on the operation of scan can be found in scan.scm.

Next: , Previous: , Up: SCM Interface   [Contents][Index]