diff --git a/src/dodb.cl b/src/dodb.cl index 9969437..1d62632 100755 --- a/src/dodb.cl +++ b/src/dodb.cl @@ -55,12 +55,15 @@ (concatenate 'string (db-struct-name database) "-" index-name))) object)) -(defun db/add/new-link (database index-name object file-name) +(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))) + +(defun db/index/new (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)))) + (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 )