Deletion works.
parent
47a50e981a
commit
b29badbad0
31
src/dodb.cl
31
src/dodb.cl
|
@ -108,6 +108,9 @@
|
|||
:hard nil)
|
||||
))
|
||||
|
||||
(defun db/index/del (database index-name object)
|
||||
(delete-file (db/index/get-symlink-path database index-name object)))
|
||||
|
||||
; Example: database "color" object
|
||||
; -> "./storage/cars/partitions/by_color/Red/0000000015".
|
||||
(defun db/partition/get-symlink-path (database partition-name object file-name)
|
||||
|
@ -133,6 +136,9 @@
|
|||
:target (concatenate 'string "../../../data/" file-name)
|
||||
:hard nil)))
|
||||
|
||||
(defun db/partition/del (database partition-name object file-basename)
|
||||
(delete-file (db/partition/get-symlink-path database partition-name object file-basename)))
|
||||
|
||||
; example: db-path/indexes/by_name/
|
||||
(defun db/new-index (database attribute-name)
|
||||
; Create a directory for the indexes.
|
||||
|
@ -170,7 +176,7 @@
|
|||
(number->filename (db-current-index database)))
|
||||
|
||||
; Example: {db-path}/data/000000000000018
|
||||
(defun db/add/new-data-filepath (database file-name)
|
||||
(defun get-filepath (database file-name)
|
||||
(concatenate 'string (db-path database) "/data/" file-name))
|
||||
|
||||
(defun db/add (database object)
|
||||
|
@ -180,7 +186,7 @@
|
|||
; write object to file
|
||||
(util:write-object-to-file
|
||||
object
|
||||
(db/add/new-data-filepath database file-name))
|
||||
(get-filepath database file-name))
|
||||
|
||||
; handle indexes
|
||||
(loop for index in (db-indexes database)
|
||||
|
@ -194,6 +200,25 @@
|
|||
; database.data[database.current-index] = object
|
||||
(setf (gethash (db-current-index database) (db-data database)) object))
|
||||
|
||||
; TODO
|
||||
(defun db/del (database object-index)
|
||||
(let ((file-basename (number->filename object-index))
|
||||
(object (gethash object-index (db-data database))))
|
||||
; remove data file
|
||||
(delete-file (get-filepath database file-basename))
|
||||
|
||||
; handle indexes
|
||||
(loop for index in (db-indexes database)
|
||||
do (db/index/del database index object))
|
||||
|
||||
; TODO
|
||||
; handle partitions
|
||||
(loop for partition in (db-partitions database)
|
||||
do (db/partition/del database partition object file-basename))
|
||||
|
||||
; remove in-memory data
|
||||
(remhash object-index (db-data database))))
|
||||
|
||||
; Search for the data from the FS.
|
||||
; TODO: get the hash index, too.
|
||||
(defun db/search/fs/get-by-index (database index-name value)
|
||||
|
@ -235,6 +260,8 @@
|
|||
;(db/add cars (make-vehicle :name "Corvet" :color "Red"))
|
||||
;(db/add cars (make-vehicle :name "Ferrari" :color "Red"))
|
||||
;(db/add cars (make-vehicle :name "Deudeuch" :color "Beige"))
|
||||
;(db/add cars (make-vehicle :name "BMW" :color "Blue"))
|
||||
;(db/add cars (make-vehicle :name "Suzuki Wagon" :color "Blue"))
|
||||
|
||||
(db/new-index cars "name")
|
||||
(db/new-partition cars "color")
|
||||
|
|
Loading…
Reference in New Issue