1.1--- a/lisp/lib/rdb/macs.lisp Wed Sep 25 21:39:39 2024 -0400
1.2+++ b/lisp/lib/rdb/macs.lisp Thu Sep 26 21:16:45 2024 -0400
1.3@@ -14,9 +14,7 @@
1.4 (lambda (c)
1.5 (handle-errptr ,e ,errtyp ,params))))
1.6 (progn ,@body))
1.7- (handle-errptr ,e ,errtyp ,params)
1.8- )))
1.9-
1.10+ (handle-errptr ,e ,errtyp ,params))))
1.11
1.12 ;;; opts
1.13 (defmacro rdb-opt-setter (key)
1.14@@ -88,11 +86,11 @@
1.15 (rocksdb-backup-engine-close ,be-var))))
1.16
1.17 ;;; top-level
1.18+;; TODO 2024-09-26:
1.19 (defmacro do-db ((db opts) accessors &body body)
1.20 "Database Iteration construct. OPTS are used to provide top-level
1.21 options dynamically bound to DB. ACCESSORS is a list of database
1.22- accessors which are available to call in BODY."
1.23- )
1.24+ accessors which are available to call in BODY.")
1.25
1.26 ;;; temp-db
1.27 (defvar *temp-db-path-generator*
1.28@@ -139,3 +137,19 @@
1.29 ,@(when file `((open-sst ,sst ,file)))
1.30 ,@body
1.31 ,@(when destroy `((destroy-sst ,sst)))))
1.32+
1.33+;;; opts
1.34+(defmacro with-latest-opts ((db-var db-path) &body body)
1.35+ `(rocksdb::with-latest-options ,(string db-path) (db-opts cf-names cf-opts)
1.36+ (let ((opts (make-rdb-opts)))
1.37+ (setf (rdb-opts-sap opts) db-opts)
1.38+ (let ((cfs (coerce
1.39+ (loop for name across cf-names
1.40+ for opt across cf-opts
1.41+ collect
1.42+ (let ((cf-opts (make-rdb-opts)))
1.43+ (setf (rdb-opts-sap cf-opts) opt)
1.44+ (make-rdb-cf name :opts cf-opts)))
1.45+ 'vector)))
1.46+ (let ((,db-var (make-rdb ,db-path opts cfs)))
1.47+ ,@body)))))