[elephant-cvs] CVS elephant/src/db-bdb
ieslick
ieslick at common-lisp.net
Sun Feb 19 20:06:03 UTC 2006
Update of /project/elephant/cvsroot/elephant/src/db-bdb
In directory common-lisp:/tmp/cvs-serv14267/src/db-bdb
Modified Files:
bdb-collections.lisp bdb-controller.lisp sleepycat.lisp
Log Message:
Includes most SQL fixes - works under SBCL/ACL. Two problems remain in indexing under SQL for both SBCL/ACL
--- /project/elephant/cvsroot/elephant/src/db-bdb/bdb-collections.lisp 2006/02/19 04:53:00 1.1
+++ /project/elephant/cvsroot/elephant/src/db-bdb/bdb-collections.lisp 2006/02/19 20:06:03 1.2
@@ -76,11 +76,9 @@
;; Secondary indices
(defclass bdb-indexed-btree (indexed-btree bdb-btree)
- (
- (indices :accessor indices :initform (make-hash-table))
+ ((indices :accessor indices :initform (make-hash-table))
(indices-cache :accessor indices-cache :initform (make-hash-table)
- :transient t)
- )
+ :transient t))
(:metaclass persistent-metaclass)
(:documentation "A BDB-based BTree supports secondary indices."))
@@ -90,20 +88,10 @@
(setf (indices-cache instance) (indices instance)))
(defmethod build-indexed-btree ((sc bdb-store-controller))
- (let ((bt (make-instance 'bdb-indexed-btree :sc sc)))
-;; (setf (:dbcn-spc-pst bt) (controller-path sc))
-;; I must be confused with multipler inheritance, because the above
-;;; initforms in bdb-indexed-btree should be working, but aren't.
-;; (setf (indices bt) (make-hash-table))
-;; (setf (indices-cache bt) (make-hash-table))
- bt))
+ (make-instance 'bdb-indexed-btree :sc sc))
(defmethod build-btree-index ((sc bdb-store-controller) &key primary key-form)
- (let ((bt (make-instance 'bdb-btree-index :primary primary :key-form key-form :sc sc)))
-;; (setf (:dbcn-spc-pst bt) (controller-path sc))
-;; I must be confused with multipler inheritance, because the above
-;;; initforms in bdb-indexed-btree should be working, but aren't.
- bt))
+ (make-instance 'bdb-btree-index :primary primary :key-form key-form :sc sc))
(defmethod add-index ((bt bdb-indexed-btree) &key index-name key-form populate)
(let ((sc (get-con bt)))
@@ -221,8 +209,6 @@
(:metaclass persistent-metaclass)
(:documentation "A BDB-based BTree supports secondary indices."))
-;; I now think this code should be split out into a separate
-;; class...
(defmethod get-value (key (bt bdb-btree-index))
"Get the value in the primary DB from a secondary key."
(declare (optimize (speed 3)))
@@ -248,13 +234,6 @@
(values (deserialize buf :sc (get-con bt)) oid))
(values nil nil)))))
-
-;; Cursor operations
-;; Node that I have not created a bdb-cursor, but have
-;; created a sql-currsor. This is almost certainly wrong
-;; and furthermore will badly screw things up when we get to
-;; secondary cursors.
-
(defclass bdb-cursor (cursor)
((handle :accessor cursor-handle :initarg :handle))
(:documentation "A cursor for traversing (primary) BDB-BTrees."))
@@ -507,8 +486,8 @@
(if (and key (= (buffer-read-int key) (cursor-oid cursor)))
(progn (setf (cursor-initialized-p cursor) t)
(values t
-(deserialize key :sc (get-con (cursor-btree cursor)))
-(deserialize val :sc (get-con (cursor-btree cursor)))
+ (deserialize key :sc (get-con (cursor-btree cursor)))
+ (deserialize val :sc (get-con (cursor-btree cursor)))
(progn (buffer-read-int pkey) (deserialize pkey))))
(setf (cursor-initialized-p cursor) nil)))))
--- /project/elephant/cvsroot/elephant/src/db-bdb/bdb-controller.lisp 2006/02/19 04:53:00 1.1
+++ /project/elephant/cvsroot/elephant/src/db-bdb/bdb-controller.lisp 2006/02/19 20:06:03 1.2
@@ -38,14 +38,14 @@
;; Backend Registry Support
;;
-(eval-when (:compile-toplevel :load-toplevel)
- (register-backend-con-init :bdb 'bdb-test-and-construct))
-
(defun bdb-test-and-construct (spec)
(if (bdb-store-spec-p spec)
- (open-store-bdb spec)
+ (make-instance 'bdb-store-controller :spec spec)
(error (format nil "uninterpretable spec specifier: ~A" spec))))
+(eval-when (:compile-toplevel :load-toplevel)
+ (register-backend-con-init :bdb 'bdb-test-and-construct))
+
(defun bdb-store-spec-p (spec)
(and (eq (first spec) :bdb)
(typecase (second spec)
@@ -53,13 +53,6 @@
(string t)
(otherwise nil))))
-(defmethod next-oid ((sc bdb-store-controller))
- "Get the next OID."
- (declare (type bdb-store-controller sc))
- (db-sequence-get-fixnum (controller-oid-seq sc) 1 :transaction +NULL-VOID+
- :auto-commit t :txn-nosync t))
-
-
;; Open/close
(defmethod open-controller ((sc bdb-store-controller) &key (recover t)
(recover-fatal nil) (thread t))
@@ -144,12 +137,12 @@
;; Delete connection spec so object ops on cached db info fail
(remhash (controller-spec *store-controller*) *dbconnection-spec*))
-(defun open-store-bdb (spec &key (recover nil) (recover-fatal nil) (thread t))
- "Conveniently open a store controller."
- (setq *store-controller*
- (make-instance 'bdb-store-controller :spec spec))
- (open-controller *store-controller* :recover recover
- :recover-fatal recover-fatal :thread thread))
+
+(defmethod next-oid ((sc bdb-store-controller))
+ "Get the next OID."
+ (declare (type bdb-store-controller sc))
+ (db-sequence-get-fixnum (controller-oid-seq sc) 1 :transaction +NULL-VOID+
+ :auto-commit t :txn-nosync t))
;;
--- /project/elephant/cvsroot/elephant/src/db-bdb/sleepycat.lisp 2006/02/19 17:25:53 1.2
+++ /project/elephant/cvsroot/elephant/src/db-bdb/sleepycat.lisp 2006/02/19 20:06:03 1.3
@@ -78,7 +78,7 @@
(uffi:load-foreign-library
(merge-pathnames
(make-pathname :name "libsleepycat" :type *c-library-extension*)
- (merge-pathnames (make-pathname :directory "src/db-bdb")
+ (merge-pathnames "src/db-bdb/"
(asdf:component-pathname (asdf:find-system 'elephant))))
:module "libsleepycat")
(error "Couldn't load src/db-bdb/libsleepycat.~A!" elephant-memutil::*c-library-extension*))
More information about the Elephant-cvs
mailing list