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