[elephant-cvs] CVS elephant/src/contrib/eslick/db-lisp
ieslick
ieslick at common-lisp.net
Thu Feb 8 23:05:46 UTC 2007
Update of /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp
In directory clnet:/tmp/cvs-serv2282/contrib/eslick/db-lisp
Modified Files:
btree.lisp package.lisp pages.lisp
Log Message:
Removing vestigial directory
--- /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp/btree.lisp 2007/02/08 15:57:19 1.2
+++ /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp/btree.lisp 2007/02/08 23:05:46 1.3
@@ -7,7 +7,8 @@
'((0 . :unknown)
(1 . :index)
(2 . :leaf)
- (3 . :blob)))
+ (3 . :overflow)
+ (#xFF . :root)))
(defun get-type (byte)
(assert (<= byte (car (last *type-table*))))
@@ -41,9 +42,27 @@
;; Indexes:
;;
+type = root
+endian-tag = 0xDAF00F00 (32-bit)
+db_version = 0-6-1 (48 bit)
+free-data-block = page-ptr (32-bits)
+num-keys - int32
+
+type = index
+num-keys - int32
+serialized-key - buffer-stream
+page-pointer (int32-page)
+serialized-key - buffer-stream
+page-pointer (int32-page)
+...
+type - leaf
+num-elts -
;; User Operations:
+;; btree-open
+(defun open-btree-file (path &key page-size (create t))
+
;; btree-create
;; btree-search
--- /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp/package.lisp 2007/02/08 15:57:19 1.2
+++ /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp/package.lisp 2007/02/08 23:05:46 1.3
@@ -3,9 +3,3 @@
(defpackage :db-lisp
(:use :cl :elephant :elephant-backend :elephant-memutil))
-;; file - open/close binary files
-;; octet-stream - read/write binary buffers
-;; binary-fields - macro package for reading/writing lisp arrays
-;; pages - binary pages read/written to and from stream; simple metadata
-;; includes a simple LRU page-caching scheme using linked-lists
-;; btree - btrees implemented on top of pages
--- /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp/pages.lisp 2007/02/08 15:57:19 1.1
+++ /project/elephant/cvsroot/elephant/src/contrib/eslick/db-lisp/pages.lisp 2007/02/08 23:05:46 1.2
@@ -1,6 +1,31 @@
(in-package :db-lisp)
;;
+;; Utilities
+;;
+
+(defun copy-slots (obj1 obj2 slotnames)
+ (loop for slotname in slotnames do
+ (setf (slot-value obj2 slotname) (slot-value obj1 slotname))))
+
+(defun write-integer-to-array (integer array offset &optional (bytes 4))
+ (declare (type fixnum offset bytes)
+ (type integer integer)
+ (type (array (unsigned-byte 8)) array))
+ (loop for i fixnum from 0 below bytes do
+ (setf (aref array (+ offset i))
+ (ldb (byte 8 (* i 8)) integer))))
+
+(defun read-integer-from-array (array offset &optional (bytes 4))
+ (declare (type fixnum offset bytes)
+ (type (array (unsigned-byte 8)) array))
+ (let ((value 0))
+ (loop for i fixnum from 0 below bytes do
+ (setf value (dpb (aref array (+ i offset)) (byte 8 (* i 8)) value)))
+ value))
+
+
+;;
;; Mixins
;;
@@ -53,14 +78,15 @@
;; Primitive read-write of buffer-pages
;;
-;;
;; Read/Write fixnums
-;;
-(defun write-fixnum (page offset fix &optional (bytes 4))
- (loop for i from 0 below bytes do
- (setf (aref (page-buffer page) (+ offset i))
- (ldb (byte 8 (* i 8)) fix))))
+(defmethod write-integer (fixnum page offset &optional (bytes 4))
+ (declare (type fixnum fixnum offset bytes))
+ (write-fixnum-to-array fixnum (page-buffer page) offset bytes))
+
+(defmethod read-integer (page offset &optional (bytes 4))
+ (declare (type fixnum offset bytes))
+ (read-integer-from-array (page-buffer page) offset bytes))
;; NOTE: Redo memutil/serializer primitives here?
@@ -182,9 +208,11 @@
(defmethod cache-page ((pool buffer-pool) page)
(push page (gethash (page-position page) (pool-hash pool))))
+;; ------------------------------------------------------------------------
;;
;; User cache operations
;;
+;; ------------------------------------------------------------------------
(defmethod get-page ((pool buffer-pool) stream position)
(touch-page
More information about the Elephant-cvs
mailing list