Indexes (draft).
parent
20fec34dcc
commit
fe41a86eb8
42
src/dodb.cl
42
src/dodb.cl
|
@ -1,7 +1,7 @@
|
|||
#!/usr/local/bin/clisp
|
||||
|
||||
; (load "~/.quicklisp/setup.lisp")
|
||||
; (ql:quickload "osicat")
|
||||
(load "~/.quicklisp/setup.lisp")
|
||||
(ql:quickload "osicat")
|
||||
|
||||
(load "./util.cl")
|
||||
(defpackage :dodb
|
||||
|
@ -45,16 +45,42 @@
|
|||
; Add this new index to the list.
|
||||
(push attribute-name (db-indexes database)))
|
||||
|
||||
(defun db/add (database object)
|
||||
; (osicat:make-link "lien-symbolique" :target "data.dat" :hard nil)
|
||||
(incf (db-current-index database))
|
||||
(util:write-object-to-file object (concatenate 'string
|
||||
(defun to-upper-case (some-string)
|
||||
(format nil "~@:(~a~)" some-string))
|
||||
|
||||
; Returns "Corvet".
|
||||
(defun db/index/get-filename (database index-name object)
|
||||
(funcall ; example: call function "VEHICLE-NAME"
|
||||
(find-symbol (to-upper-case
|
||||
(concatenate 'string (db-struct-name database) "-" index-name)))
|
||||
object))
|
||||
|
||||
(defun db/add/new-link (database index-name object file-name)
|
||||
(let ((symlink-path
|
||||
(concatenate 'string
|
||||
(db-path database)
|
||||
"/data/"
|
||||
(format nil "~15,'0D.data" (db-current-index database))))
|
||||
"/by_" index-name "/"
|
||||
(db/index/get-filename database index-name object))))
|
||||
|
||||
; Works even when the database directory is moved.
|
||||
(osicat:make-link symlink-path
|
||||
:target (concatenate 'string "../data/" file-name)
|
||||
:hard nil)
|
||||
))
|
||||
|
||||
(defun db/add (database object)
|
||||
(incf (db-current-index database))
|
||||
(let ((file-name (format nil "~15,'0D.data" (db-current-index database))))
|
||||
(util:write-object-to-file object (concatenate 'string
|
||||
(db-path database) "/data/" file-name))
|
||||
|
||||
; TODO: handle indexes
|
||||
(loop for index in (db-indexes database)
|
||||
do (db/add/new-link database index object file-name))
|
||||
|
||||
; TODO: handle partitions
|
||||
)
|
||||
)
|
||||
|
||||
; test structure
|
||||
(defstruct vehicle name color)
|
||||
|
|
Loading…
Reference in New Issue