[elephant-cvs] CVS elephant/src/db-bdb

ieslick ieslick at common-lisp.net
Thu Feb 1 15:19:50 UTC 2007


Update of /project/elephant/cvsroot/elephant/src/db-bdb
In directory clnet:/tmp/cvs-serv18919/src/db-bdb

Modified Files:
	bdb-collections.lisp 
Log Message:
Finish 64-bit update; clean up memutil; fix array flag type error in SBCL; more efficient and correct hash serialization in new serializer

--- /project/elephant/cvsroot/elephant/src/db-bdb/bdb-collections.lisp	2007/01/31 20:05:37	1.12
+++ /project/elephant/cvsroot/elephant/src/db-bdb/bdb-collections.lisp	2007/02/01 15:19:49	1.13
@@ -36,7 +36,7 @@
 (defmethod get-value (key (bt bdb-btree))
   (let ((sc (get-con bt)))
     (with-buffer-streams (key-buf value-buf)
-      (buffer-write-int (oid bt) key-buf)
+      (buffer-write-oid (oid bt) key-buf)
       (serialize key key-buf sc)
       (let ((buf (db-get-key-buffered (controller-btrees sc)
 				      key-buf value-buf)))
@@ -45,7 +45,7 @@
 
 (defmethod existsp (key (bt bdb-btree))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (oid bt) key-buf)
+    (buffer-write-oid (oid bt) key-buf)
     (serialize key key-buf (get-con bt))
     (let ((buf (db-get-key-buffered 
 		(controller-btrees (get-con bt)) 
@@ -58,7 +58,7 @@
 ;;  (with-transaction ()
     (let ((sc (get-con bt)))
       (with-buffer-streams (key-buf value-buf)
-	(buffer-write-int (oid bt) key-buf)
+	(buffer-write-oid (oid bt) key-buf)
 	(serialize key key-buf sc)
 	(serialize value value-buf sc)
 	(db-put-buffered (controller-btrees sc)
@@ -69,7 +69,7 @@
 ;;   (labels ((write-value ()
 ;; 	     (let ((sc (get-con bt)))
 ;; 	       (with-buffer-streams (key-buf value-buf)
-;; 		 (buffer-write-int (oid bt) key-buf)
+;; 		 (buffer-write-oid (oid bt) key-buf)
 ;; 		 (serialize key key-buf sc)
 ;; 		 (serialize value value-buf sc)
 ;; 		 (db-put-buffered (controller-btrees sc)
@@ -85,7 +85,7 @@
 ;;  (with-transaction (:store-controller (get-con bt))
   (let ((sc (get-con bt)) )
     (with-buffer-streams (key-buf)
-      (buffer-write-int (oid bt) key-buf)
+      (buffer-write-oid (oid bt) key-buf)
       (serialize key key-buf sc)
       (db-delete-buffered (controller-btrees sc)
 			  key-buf))))
@@ -135,9 +135,9 @@
   (let ((sc (get-con bt)))
     (with-buffer-streams (primary-buf secondary-buf)
       (flet ((index (key skey)
-	       (buffer-write-int (oid bt) primary-buf)
+	       (buffer-write-oid (oid bt) primary-buf)
 	       (serialize key primary-buf sc)
-	       (buffer-write-int (oid index) secondary-buf)
+	       (buffer-write-oid (oid index) secondary-buf)
 	       (serialize skey secondary-buf sc)
 	       ;; should silently do nothing if
 	       ;; the key/value already exists
@@ -187,7 +187,7 @@
   (let ((sc (get-con bt)))
     (let ((indices (indices-cache bt)))
       (with-buffer-streams (key-buf value-buf secondary-buf)
-	(buffer-write-int (oid bt) key-buf)
+	(buffer-write-oid (oid bt) key-buf)
 	(serialize key key-buf sc)
 	(serialize value value-buf sc)
 	(with-transaction (:store-controller sc)
@@ -199,7 +199,7 @@
 		 (funcall (key-fn index) index key value)
 	       (when index?
 		 ;; Manually write value into secondary index
-		 (buffer-write-int (oid index) secondary-buf)
+		 (buffer-write-oid (oid index) secondary-buf)
 		 (serialize secondary-key secondary-buf sc)
 		 ;; should silently do nothing if the key/value already
 		 ;; exists
@@ -213,7 +213,7 @@
   "Remove a key / value pair, and update secondary indices."
   (let ((sc (get-con bt)))
       (with-buffer-streams (key-buf secondary-buf)
-	(buffer-write-int (oid bt) key-buf)
+	(buffer-write-oid (oid bt) key-buf)
 	(serialize key key-buf sc)
 	(with-transaction (:store-controller sc)
 	  (let ((value (get-value key bt)))
@@ -225,7 +225,7 @@
 		   (multiple-value-bind (index? secondary-key)
 		       (funcall (key-fn index) index key value)
 		     (when index?
-		       (buffer-write-int (oid index) secondary-buf)
+		       (buffer-write-oid (oid index) secondary-buf)
 		       (serialize secondary-key secondary-buf sc)
 		       ;; need to remove kv pairs with a cursor! --
 		       ;; this is a C performance hack
@@ -247,7 +247,7 @@
 (defmethod get-value (key (bt bdb-btree-index))
   "Get the value in the primary DB from a secondary key."
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (oid bt) key-buf)
+    (buffer-write-oid (oid bt) key-buf)
     (serialize key key-buf (get-con bt))
     (let ((buf (db-get-key-buffered 
 		(controller-indices-assoc (get-con bt)) 
@@ -258,13 +258,13 @@
 (defmethod get-primary-key (key (bt btree-index))
   (let ((sc (get-con bt)))
     (with-buffer-streams (key-buf value-buf)
-      (buffer-write-int (oid bt) key-buf)
+      (buffer-write-oid (oid bt) key-buf)
       (serialize key key-buf sc)
       (let ((buf (db-get-key-buffered 
 		  (controller-indices sc)
 		  key-buf value-buf)))
 	(if buf 
-	    (let ((oid (buffer-read-fixnum buf)))
+	    (let ((oid (buffer-read-oid buf)))
 	      (values (deserialize buf sc) oid))
 	    (values nil nil))))))
 
@@ -298,7 +298,7 @@
 	(multiple-value-bind (key val)
 	    (db-cursor-move-buffered (cursor-handle cursor) key-buf value-buf
 				     :current t)
-	  (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	  (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	      (progn (setf (cursor-initialized-p cursor) t)
 		     (values t (deserialize key sc)
 			     (deserialize val sc)))
@@ -307,11 +307,11 @@
 (defmethod cursor-first ((cursor bdb-cursor))
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (cursor-oid cursor) key-buf)
+    (buffer-write-oid (cursor-oid cursor) key-buf)
     (multiple-value-bind (key val)
 	(db-cursor-set-buffered (cursor-handle cursor) 
 				key-buf value-buf :set-range t)
-      (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+      (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	  (progn (setf (cursor-initialized-p cursor) t)
 		 (values t 
 			 (deserialize key sc)
@@ -322,7 +322,7 @@
 (defmethod cursor-last ((cursor bdb-cursor))
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (+ (cursor-oid cursor) 1) key-buf)
+    (buffer-write-oid (+ (cursor-oid cursor) 1) key-buf)
     (if (db-cursor-set-buffered (cursor-handle cursor) 
 				key-buf value-buf :set-range t)    
 	(progn (reset-buffer-stream key-buf)
@@ -330,7 +330,7 @@
 	       (multiple-value-bind (key val)
 		   (db-cursor-move-buffered (cursor-handle cursor) 
 					    key-buf value-buf :prev t)
-		 (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+		 (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 		     (progn
 		       (setf (cursor-initialized-p cursor) t)
 		       (values t (deserialize key sc)
@@ -339,7 +339,7 @@
 	(multiple-value-bind (key val)
 	    (db-cursor-move-buffered (cursor-handle cursor) key-buf
 				     value-buf :last t)
-	  (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	  (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	      (progn
 		(setf (cursor-initialized-p cursor) t)
 		(values t (deserialize key sc)
@@ -353,7 +353,7 @@
 	  (multiple-value-bind (key val)
 	      (db-cursor-move-buffered (cursor-handle cursor) 
 				       key-buf value-buf :next t)
-	    (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	    (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 		(values t (deserialize key sc)
 			(deserialize val sc))
 		(setf (cursor-initialized-p cursor) nil)))))
@@ -366,7 +366,7 @@
 	  (multiple-value-bind (key val)
 	      (db-cursor-move-buffered (cursor-handle cursor)
 				       key-buf value-buf :prev t)
-	    (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	    (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 		(values t (deserialize key sc)
 			(deserialize val sc))
 		(setf (cursor-initialized-p cursor) nil))))
@@ -375,7 +375,7 @@
 (defmethod cursor-set ((cursor bdb-cursor) key)
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (cursor-oid cursor) key-buf)
+    (buffer-write-oid (cursor-oid cursor) key-buf)
     (serialize key key-buf sc)
     (multiple-value-bind (k val)
 	(db-cursor-set-buffered (cursor-handle cursor)
@@ -389,12 +389,12 @@
 (defmethod cursor-set-range ((cursor bdb-cursor) key)
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (cursor-oid cursor) key-buf)
+    (buffer-write-oid (cursor-oid cursor) key-buf)
     (serialize key key-buf sc)
     (multiple-value-bind (k val)
 	(db-cursor-set-buffered (cursor-handle cursor)
 				key-buf value-buf :set-range t)
-      (if (and k (= (buffer-read-int k) (cursor-oid cursor)))
+      (if (and k (= (buffer-read-oid k) (cursor-oid cursor)))
 	  (progn (setf (cursor-initialized-p cursor) t)
 		 (values t (deserialize k sc)
 			 (deserialize val sc)))
@@ -403,7 +403,7 @@
 (defmethod cursor-get-both ((cursor bdb-cursor) key value)
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (cursor-oid cursor) key-buf)
+    (buffer-write-oid (cursor-oid cursor) key-buf)
     (serialize key key-buf sc)
     (serialize value value-buf sc)
     (multiple-value-bind (k v)
@@ -418,7 +418,7 @@
 (defmethod cursor-get-both-range ((cursor bdb-cursor) key value)
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf value-buf)
-    (buffer-write-int (cursor-oid cursor) key-buf)
+    (buffer-write-oid (cursor-oid cursor) key-buf)
     (serialize key key-buf sc)
     (serialize value value-buf sc)
     (multiple-value-bind (k v)
@@ -436,7 +436,7 @@
 	    (db-cursor-move-buffered (cursor-handle cursor) key-buf value-buf
 				     :current t)
 	  (declare (ignore val))
-	  (when (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	  (when (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	    ;; in case of a secondary index this should delete everything
 	    ;; as specified by the BDB docs.
 	    (remove-kv (deserialize key (get-con (cursor-btree cursor)))
@@ -456,7 +456,7 @@
 		(db-cursor-move-buffered (cursor-handle cursor) key-buf 
 					 value-buf :current t)
 	      (declare (ignore v))
-	      (if (and k (= (buffer-read-int k) (cursor-oid cursor)))
+	      (if (and k (= (buffer-read-oid k) (cursor-oid cursor)))
 		  (setf (get-value 
 			 (deserialize k (get-con (cursor-btree cursor))) 
 			 (cursor-btree cursor)) 
@@ -485,35 +485,35 @@
 	  (db-cursor-pmove-buffered (cursor-handle cursor) 
 				    key-buf pkey-buf value-buf
 				    :current t)
-	(if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	(if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	    (progn (setf (cursor-initialized-p cursor) t)
 		   (let ((sc (get-con (cursor-btree cursor))))
 		     (values t 
 			     (deserialize key sc)
 			     (deserialize val sc)
-			     (progn (buffer-read-int pkey) (deserialize pkey sc)))))
+			     (progn (buffer-read-oid pkey) (deserialize pkey sc)))))
 	    (setf (cursor-initialized-p cursor) nil))))))
 
 (defmethod cursor-pfirst ((cursor bdb-secondary-cursor))
   (with-buffer-streams (key-buf pkey-buf value-buf)
-    (buffer-write-int (cursor-oid cursor) key-buf)
+    (buffer-write-oid (cursor-oid cursor) key-buf)
     (multiple-value-bind (key pkey val)
 	(db-cursor-pset-buffered (cursor-handle cursor) 
 				 key-buf pkey-buf value-buf :set-range t)
-      (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+      (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	  (progn (setf (cursor-initialized-p cursor) t)
 		 (let ((sc (get-con (cursor-btree cursor))))
 		 (values t 
 			 (deserialize key sc)
 			 (deserialize val sc)
-			 (progn (buffer-read-int pkey) (deserialize pkey sc)))))
+			 (progn (buffer-read-oid pkey) (deserialize pkey sc)))))
 	  (setf (cursor-initialized-p cursor) nil)))))
 		 
 ;;A bit of a hack.....
 (defmethod cursor-plast ((cursor bdb-secondary-cursor))
   (let ((sc (get-con (cursor-btree cursor))))
   (with-buffer-streams (key-buf pkey-buf value-buf)
-    (buffer-write-int (+ (cursor-oid cursor) 1) key-buf)
+    (buffer-write-oid (+ (cursor-oid cursor) 1) key-buf)
     (if (db-cursor-set-buffered (cursor-handle cursor) 
 				key-buf value-buf :set-range t)    
 	(progn (reset-buffer-stream key-buf)
@@ -521,24 +521,24 @@
 	       (multiple-value-bind (key pkey val)
 		   (db-cursor-pmove-buffered (cursor-handle cursor) key-buf 
 					     pkey-buf value-buf :prev t)
-		 (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+		 (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 		     (progn
 		       (setf (cursor-initialized-p cursor) t)
 		       (values t 
 			       (deserialize key sc)
 			       (deserialize val sc)
-			       (progn (buffer-read-int pkey) 
+			       (progn (buffer-read-oid pkey) 
 				      (deserialize pkey sc))))
 		     (setf (cursor-initialized-p cursor) nil))))
 	(multiple-value-bind (key pkey val)
 	    (db-cursor-pmove-buffered (cursor-handle cursor) key-buf
 				      pkey-buf value-buf :last t)
-	  (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	  (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	      (progn
 		(setf (cursor-initialized-p cursor) t)
 		(values t (deserialize key sc)
 			(deserialize val sc)
-			(progn (buffer-read-int pkey) (deserialize pkey sc))))
+			(progn (buffer-read-oid pkey) (deserialize pkey sc))))
 	      (setf (cursor-initialized-p cursor) nil)))))))
 
 (defmethod cursor-pnext ((cursor bdb-secondary-cursor))
@@ -547,11 +547,11 @@
 	(multiple-value-bind (key pkey val)
 	    (db-cursor-pmove-buffered (cursor-handle cursor) 
 				     key-buf pkey-buf value-buf :next t)
-	  (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	  (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	      (let ((sc (get-con (cursor-btree cursor))))
 		(values t (deserialize key sc)
 			(deserialize val sc)
-			(progn (buffer-read-int pkey) (deserialize pkey sc))))
+			(progn (buffer-read-oid pkey) (deserialize pkey sc))))
 	      (setf (cursor-initialized-p cursor) nil))))
       (cursor-pfirst cursor)))
 	  
@@ -561,18 +561,18 @@
 	(multiple-value-bind (key pkey val)
 	    (db-cursor-pmove-buffered (cursor-handle cursor)
 				      key-buf pkey-buf value-buf :prev t)
-	  (if (and key (= (buffer-read-int key) (cursor-oid cursor)))
+	  (if (and key (= (buffer-read-oid key) (cursor-oid cursor)))
 	      (let ((sc (get-con (cursor-btree cursor))))
 		(values t (deserialize key sc)
 			(deserialize val sc)
-			(progn (buffer-read-int pkey) (deserialize pkey sc))))
+			(progn (buffer-read-oid pkey) (deserialize pkey sc))))
 	      (setf (cursor-initialized-p cursor) nil))))
       (cursor-plast cursor)))
 
 (defmethod cursor-pset ((cursor bdb-secondary-cursor) key)
   (let ((sc (get-con (cursor-btree cursor))))
     (with-buffer-streams (key-buf pkey-buf value-buf)
-      (buffer-write-int (cursor-oid cursor) key-buf)
+      (buffer-write-oid (cursor-oid cursor) key-buf)
       (serialize key key-buf sc)
       (multiple-value-bind (k pkey val)
 	  (db-cursor-pset-buffered (cursor-handle cursor)
@@ -581,32 +581,32 @@
 	    (progn
 	      (setf (cursor-initialized-p cursor) t)
 	      (values t key (deserialize val sc)
-		      (progn (buffer-read-int pkey) 
+		      (progn (buffer-read-oid pkey) 
 			     (deserialize pkey sc))))
 	    (setf (cursor-initialized-p cursor) nil))))))
 
 (defmethod cursor-pset-range ((cursor bdb-secondary-cursor) key)
   (let ((sc (get-con (cursor-btree cursor))))
     (with-buffer-streams (key-buf pkey-buf value-buf)
-      (buffer-write-int (cursor-oid cursor) key-buf)
+      (buffer-write-oid (cursor-oid cursor) key-buf)
       (serialize key key-buf sc)
       (multiple-value-bind (k pkey val)
 	  (db-cursor-pset-buffered (cursor-handle cursor)
 				   key-buf pkey-buf value-buf :set-range t)
-	(if (and k (= (buffer-read-int k) (cursor-oid cursor)))
+	(if (and k (= (buffer-read-oid k) (cursor-oid cursor)))
 	    (progn (setf (cursor-initialized-p cursor) t)
 		   (values t (deserialize k sc)
 			   (deserialize val sc)
-			   (progn (buffer-read-int pkey) (deserialize pkey sc))))
+			   (progn (buffer-read-oid pkey) (deserialize pkey sc))))
 	    (setf (cursor-initialized-p cursor) nil))))))
 
 (defmethod cursor-pget-both ((cursor bdb-secondary-cursor) key pkey)
   (with-buffer-streams (key-buf pkey-buf value-buf)
     (let ((primary-oid (oid (primary (cursor-btree cursor))))
 	  (sc (get-con (cursor-btree cursor))))
-      (buffer-write-int (cursor-oid cursor) key-buf)
+      (buffer-write-oid (cursor-oid cursor) key-buf)
       (serialize key key-buf sc)
-      (buffer-write-int primary-oid pkey-buf)
+      (buffer-write-oid primary-oid pkey-buf)
       (serialize pkey pkey-buf sc)
       (multiple-value-bind (k p val)
 	  (db-cursor-pget-both-buffered (cursor-handle cursor)
@@ -621,9 +621,9 @@
   (with-buffer-streams (key-buf pkey-buf value-buf)
     (let ((primary-oid (oid (primary (cursor-btree cursor))))
 	  (sc (get-con (cursor-btree cursor))))
-      (buffer-write-int (cursor-oid cursor) key-buf)
+      (buffer-write-oid (cursor-oid cursor) key-buf)

[92 lines skipped]




More information about the Elephant-cvs mailing list