-
Notifications
You must be signed in to change notification settings - Fork 6
/
data-types.lisp
45 lines (36 loc) · 1.11 KB
/
data-types.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(in-package #:vivace-graph-v2)
;;; UUIDs
(defun make-uuid ()
"Create a new UUID."
(uuid:make-v1-uuid))
(defun sxhash-uuid (uuid) (sxhash (uuid:print-bytes nil uuid)))
(sb-ext:define-hash-table-test uuid:uuid-eql sxhash-uuid)
(defun make-uuid-table (&key synchronized)
(make-hash-table :test 'uuid:uuid-eql :synchronized synchronized))
;;; Dates
;;; timestamps provided by local-time lib
(defgeneric timestamp? (thing)
(:method ((thing timestamp)) t)
(:method (thing) nil))
;;; Triple structure
(defparameter *print-triple-details* nil)
(defun print-triple (triple stream depth)
(declare (ignore depth))
(if *print-triple-details*
(format stream "<'~A' '~A' '~A' {~F:~A:~A}>"
(subject triple) (predicate triple) (object triple)
(cf triple) (graph triple) (id triple))
(format stream "<'~A' '~A' '~A'>"
(subject triple) (predicate triple) (object triple))))
(defstruct (triple
(:print-function print-triple)
(:conc-name triple-)
(:predicate triple?))
subject
predicate
object
graph
id
(deleted? nil)
(cf +cf-true+)
(persistent? t))