temp commit
parent
1ce7d71f8d
commit
b3a50358ab
3
TODO.md
3
TODO.md
|
@ -1,9 +1,10 @@
|
||||||
- Warning when indexes overlap (data add or update)
|
- Warning when indexes overlap (data add or update)
|
||||||
- Data integrity on update (create temporary file with new data, rename old data file, move temporary file, remove old data file)
|
- Data integrity on update (create temporary file with new data, rename old data file, move temporary file, remove old data file)
|
||||||
- Handle errors (such as permissions) in an explicit way
|
- Handle errors (such as permissions) in an explicit way
|
||||||
- Grooming (create a consistent and convenient API)
|
- Grooming (create a consistent and convenient API, comments)
|
||||||
- Improve data search
|
- Improve data search
|
||||||
- Check for TODOs
|
- Check for TODOs
|
||||||
- For indexes and partitions: check that the structure attribute exists.
|
- For indexes and partitions: check that the structure attribute exists.
|
||||||
- Verify names of indexes and partitions: names are directly related to directory paths.
|
- Verify names of indexes and partitions: names are directly related to directory paths.
|
||||||
- db/data-filepath instead of get-filepath.
|
- db/data-filepath instead of get-filepath.
|
||||||
|
- database -> db-path
|
||||||
|
|
|
@ -77,13 +77,13 @@
|
||||||
(t (format nil "~A" object-attribute)))))
|
(t (format nil "~A" object-attribute)))))
|
||||||
(concatenate 'string dbpath "/partitions/by_" name "/" value "/")))
|
(concatenate 'string dbpath "/partitions/by_" name "/" value "/")))
|
||||||
|
|
||||||
; Example: database "name" object -> "./storage/cars/indexes/by_name/Corvet".
|
; Example: dbpath "name" #'vehicle-name object -> "./storage/cars/indexes/by_name/Corvet".
|
||||||
(defun db/index/get-symlink-path (dbpath index-name fsymbol object)
|
(defun db/index/get-symlink-path (dbpath index-name fsymbol object)
|
||||||
(concatenate 'string
|
(concatenate 'string
|
||||||
(db/index/get-directory-path dbpath index-name)
|
(db/index/get-directory-path dbpath index-name)
|
||||||
(funcall fsymbol object)))
|
(funcall fsymbol object)))
|
||||||
|
|
||||||
; Example: database "name" object "0000000015"
|
; Example: dbpath "name" #'vehicle-name object "0000000015"
|
||||||
; -> (osicat:make-link "./storage/cars/indexes/by_name/Corvet"
|
; -> (osicat:make-link "./storage/cars/indexes/by_name/Corvet"
|
||||||
; :target "../../data/0000000015"
|
; :target "../../data/0000000015"
|
||||||
; :hard nil)
|
; :hard nil)
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
(defun db/index/del (dbpath index-name fsymbol object)
|
(defun db/index/del (dbpath index-name fsymbol object)
|
||||||
(delete-file (db/index/get-symlink-path dbpath index-name fsymbol object)))
|
(delete-file (db/index/get-symlink-path dbpath index-name fsymbol object)))
|
||||||
|
|
||||||
; Example: database "color" object
|
; Example: dbpath "color" #'vehicle-color object
|
||||||
; -> "./storage/cars/partitions/by_color/Red/0000000015".
|
; -> "./storage/cars/partitions/by_color/Red/0000000015".
|
||||||
(defun db/partition/get-symlink-path (dbpath partition-name fsymbol object file-name)
|
(defun db/partition/get-symlink-path (dbpath partition-name fsymbol object file-name)
|
||||||
(concatenate 'string
|
(concatenate 'string
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
; example: "0000000015"
|
; example: "0000000015"
|
||||||
file-name))
|
file-name))
|
||||||
|
|
||||||
; Example: database "color" object "0000000015"
|
; Example: dbpath "color" #'vehicle-color object "0000000015"
|
||||||
; -> (osicat:make-link "./storage/cars/partitions/by_color/Red/0000000015"
|
; -> (osicat:make-link "./storage/cars/partitions/by_color/Red/0000000015"
|
||||||
; :target "../../../data/0000000015"
|
; :target "../../../data/0000000015"
|
||||||
; :hard nil)
|
; :hard nil)
|
||||||
|
@ -126,21 +126,22 @@
|
||||||
(defun db/partition/del (dbpath partition-name fsymbol object file-basename)
|
(defun db/partition/del (dbpath partition-name fsymbol object file-basename)
|
||||||
(delete-file (db/partition/get-symlink-path dbpath partition-name fsymbol object file-basename)))
|
(delete-file (db/partition/get-symlink-path dbpath partition-name fsymbol object file-basename)))
|
||||||
|
|
||||||
; example: db-path/indexes/by_name/
|
; Example: db-path/indexes/by_name/
|
||||||
(defun db/new-index (database attribute-name fsymbol)
|
(defun db/new-index (database attribute-name fsymbol)
|
||||||
; Create a directory for the indexes.
|
(let ((dbpath (db-path database)))
|
||||||
|
; create a directory for the indexes
|
||||||
(ensure-directories-exist
|
(ensure-directories-exist
|
||||||
(concatenate 'string (db-path database) "/indexes/by_" attribute-name "/"))
|
(concatenate 'string dbpath "/indexes/by_" attribute-name "/"))
|
||||||
|
|
||||||
; Add this new index to the list.
|
; add this new index to the list
|
||||||
(setf (gethash attribute-name (db-indexes database)) fsymbol)
|
(setf (gethash attribute-name (db-indexes database)) fsymbol)
|
||||||
|
|
||||||
; Generate index for all DB elements.
|
; generate index for all DB elements
|
||||||
(maphash #'(lambda (number element)
|
(maphash #'(lambda (number object)
|
||||||
(handler-case (db/index/new (db-path database) attribute-name fsymbol element (number->filename number))
|
(handler-case (db/index/new dbpath attribute-name fsymbol object (number->filename number))
|
||||||
(OSICAT-POSIX:EEXIST ()
|
(OSICAT-POSIX:EEXIST ()
|
||||||
(format t "db/new-index: symlink already exists, ignoring.~&"))))
|
(format t "db/new-index: symlink already exists, ignoring.~&"))))
|
||||||
(db-data database)))
|
(db-data database))))
|
||||||
|
|
||||||
(defun db/partition/update (dbpath partition-name fsymbol object file-name old-object)
|
(defun db/partition/update (dbpath partition-name fsymbol object file-name old-object)
|
||||||
(let ((new-value (funcall fsymbol object))
|
(let ((new-value (funcall fsymbol object))
|
||||||
|
@ -152,7 +153,7 @@
|
||||||
; create new partition
|
; create new partition
|
||||||
(db/partition/new dbpath partition-name fsymbol object file-name)))))
|
(db/partition/new dbpath partition-name fsymbol object file-name)))))
|
||||||
|
|
||||||
; example: db-path/partitions/by_color/
|
; Example: db-path/partitions/by_color/
|
||||||
(defun db/new-partition (database attribute-name fsymbol)
|
(defun db/new-partition (database attribute-name fsymbol)
|
||||||
(let (dbpath (db-path database))
|
(let (dbpath (db-path database))
|
||||||
; create a directory for the partitions
|
; create a directory for the partitions
|
||||||
|
@ -173,7 +174,7 @@
|
||||||
(defun db/add/new-data-basename (database)
|
(defun db/add/new-data-basename (database)
|
||||||
(number->filename (db-current-index database)))
|
(number->filename (db-current-index database)))
|
||||||
|
|
||||||
; Example: {db-path}/data/000000000000018
|
; Example: {db-path}/data/000000000000018.
|
||||||
(defun get-filepath (dbpath file-name)
|
(defun get-filepath (dbpath file-name)
|
||||||
(concatenate 'string dbpath "/data/" file-name))
|
(concatenate 'string dbpath "/data/" file-name))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue