Indexes (draft).
parent
20fec34dcc
commit
fe41a86eb8
44
src/dodb.cl
44
src/dodb.cl
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/local/bin/clisp
|
#!/usr/local/bin/clisp
|
||||||
|
|
||||||
; (load "~/.quicklisp/setup.lisp")
|
(load "~/.quicklisp/setup.lisp")
|
||||||
; (ql:quickload "osicat")
|
(ql:quickload "osicat")
|
||||||
|
|
||||||
(load "./util.cl")
|
(load "./util.cl")
|
||||||
(defpackage :dodb
|
(defpackage :dodb
|
||||||
|
@ -45,15 +45,41 @@
|
||||||
; Add this new index to the list.
|
; Add this new index to the list.
|
||||||
(push attribute-name (db-indexes database)))
|
(push attribute-name (db-indexes database)))
|
||||||
|
|
||||||
|
(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)
|
||||||
|
"/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)
|
(defun db/add (database object)
|
||||||
; (osicat:make-link "lien-symbolique" :target "data.dat" :hard nil)
|
|
||||||
(incf (db-current-index database))
|
(incf (db-current-index database))
|
||||||
(util:write-object-to-file object (concatenate 'string
|
(let ((file-name (format nil "~15,'0D.data" (db-current-index database))))
|
||||||
(db-path database)
|
(util:write-object-to-file object (concatenate 'string
|
||||||
"/data/"
|
(db-path database) "/data/" file-name))
|
||||||
(format nil "~15,'0D.data" (db-current-index database))))
|
|
||||||
; TODO: handle indexes
|
; TODO: handle indexes
|
||||||
; TODO: handle partitions
|
(loop for index in (db-indexes database)
|
||||||
|
do (db/add/new-link database index object file-name))
|
||||||
|
|
||||||
|
; TODO: handle partitions
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
; test structure
|
; test structure
|
||||||
|
|
Loading…
Reference in New Issue