Naming convention.

draft
Karchnu 2022-10-11 23:43:01 +02:00
parent fe41a86eb8
commit 774e9bd436
1 changed files with 21 additions and 9 deletions

View File

@ -55,12 +55,15 @@
(concatenate 'string (db-struct-name database) "-" index-name)))
object))
(defun db/add/new-link (database index-name object file-name)
(let ((symlink-path
(defun db/index/get-symlink-path (database index-name object)
(concatenate 'string
(db-path database)
"/by_" index-name "/"
(db/index/get-filename database index-name object))))
(db/index/get-filename database index-name object)))
(defun db/index/new (database index-name object file-name)
(let ((symlink-path
(db/index/get-symlink-path database index-name object)))
; Works even when the database directory is moved.
(osicat:make-link symlink-path
@ -68,15 +71,24 @@
:hard nil)
))
; Example: 000000000000018.data
(defun db/add/new-data-filename (database)
(format nil "~15,'0D.data" (db-current-index database)))
; Example: {db-path}/data/000000000000018.data
(defun db/add/new-data-filepath (database file-name)
(concatenate 'string (db-path database) "/data/" file-name))
(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))
(let ((file-name (db/add/new-data-filename database)))
(util:write-object-to-file
object
(db/add/new-data-filepath database file-name))
; TODO: handle indexes
(loop for index in (db-indexes database)
do (db/add/new-link database index object file-name))
do (db/index/new database index object file-name))
; TODO: handle partitions
)