value->string
parent
32155d7690
commit
9c110610ae
|
@ -24,6 +24,12 @@
|
|||
(defun number->filename (number)
|
||||
(format nil "~15,'0D" number))
|
||||
|
||||
(defun value->string (value)
|
||||
(typecase value
|
||||
(string value)
|
||||
(symbol (symbol-name value))
|
||||
(t (format nil "~A" value))))
|
||||
|
||||
; index = 1-1
|
||||
; partition = 1-n
|
||||
(defstruct db
|
||||
|
@ -66,19 +72,13 @@
|
|||
|
||||
; Example: returns "./storage/cars/partitions/by_color/Red/".
|
||||
(defun db/partition/get-directory-path (dbpath name object-attribute)
|
||||
(let ((value (typecase object-attribute
|
||||
(string object-attribute)
|
||||
(symbol (symbol-name object-attribute))
|
||||
(t (format nil "~A" object-attribute)))))
|
||||
(let ((value (value->string object-attribute)))
|
||||
(concatenate 'string dbpath "/partitions/by_" name "/" value "/")))
|
||||
|
||||
; Example: "./storage/cars/" "name" #'vehicle-name object -> "./storage/cars/indexes/by_name/Corvet".
|
||||
(defun db/index/get-symlink-path (dbpath index-name fsymbol object)
|
||||
(let* ((value (funcall fsymbol object))
|
||||
(symlink-basename (typecase value
|
||||
(string value)
|
||||
(symbol (symbol-name value))
|
||||
(t (format nil "~A" value)))))
|
||||
(symlink-basename (value->string value)))
|
||||
(concatenate 'string
|
||||
(db/index/get-directory-path dbpath index-name)
|
||||
symlink-basename)))
|
||||
|
@ -225,10 +225,7 @@
|
|||
|
||||
; Search for the data from the FS.
|
||||
(defun db/get-by-index (database index-name attribute-value)
|
||||
(let ((value (typecase attribute-value
|
||||
(string attribute-value)
|
||||
(symbol (symbol-name attribute-value))
|
||||
(t (format nil "~A" attribute-value)))))
|
||||
(let ((value (value->string attribute-value)))
|
||||
(filename->integer
|
||||
(osicat:read-link
|
||||
(concatenate 'string
|
||||
|
@ -236,10 +233,7 @@
|
|||
|
||||
; Search for the data from the FS.
|
||||
(defun db/get-by-partition (database name attribute-value)
|
||||
(let ((value (typecase attribute-value
|
||||
(string attribute-value)
|
||||
(symbol (symbol-name attribute-value))
|
||||
(t (format nil "~A" attribute-value))))
|
||||
(let ((value (value->string attribute-value))
|
||||
(dbpath (db-path database)))
|
||||
(loop for filename in (osicat:list-directory (db/partition/get-directory-path dbpath name value))
|
||||
collect (filename->integer filename))))
|
||||
|
|
Loading…
Reference in New Issue