Coverage report: /development/source/library/org/datagraph/spocq-shard/src/core/repository-classes.lisp

KindCoveredAll%
expression1654 29.6
branch24 50.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; -*- Mode: lisp; Syntax: ansi-common-lisp; Base: 10; Package: org.datagraph.spocq.implementation; -*-
2
 
3
 (in-package :org.datagraph.spocq.implementation)
4
 
5
 (:documentation "SPOCQ abstract repository definition"
6
                 "Define the abstract variants based on REPOSITORY and REVISIONED-REPOSITORY
7
 
8
  - QUAD-REPOSITORY : This is the root abstract class.
9
  - TEMPORAL-REPOSITORY : This augments a QUAD-REPOSITORY with indices for
10
    temporal object terms.
11
  - BITEMPORAL-REPOSITORY : TEMPORAL-REPOSITORY and QUAD-REPOSITORY with
12
    REVISIONED-REPOSITORY combine application- and transaction-time indices.
13
  - TIME-SERIES-REPOSITORY : Augments indices with those for transaction
14
    identifiers.
15
  - BITEMPORAL-TIME-SERIES-REPOSITORY : Combines BITEMPORAL-REPOSITORY and
16
    TIME-SERIES-REPOSITORY to support matches which constrain/collate
17
    transaction to stream solutions in combination with solutions constrained by
18
    revision and/or object timeline location
19
  - REPLICABLE-REPOSITORY : Extend a QUAD- and REVISIONED-REPOSITORY with
20
    means to replicate the state among peers.
21
  ")
22
 
23
 
24
 ;;; abstract classes relative to the root REPOSITORY class:
25
 
26
 (defclass quad-repository (repository)
27
   ())
28
 
29
 ;; nb. these two overlap but do not coincide, as time series repositories describe their
30
 ;; transactions, but may not be revisioned
31
 (defclass revision-metadata-repository (repository)
32
   ()
33
   (:documentation "The protocol class for repositories which store revision metadata"))
34
 (defclass revisioned-repository ()
35
   ()
36
   (:documentation "The protocol class for revisioned/archive repository implementations."))
37
 
38
 (defclass temporal-repository (quad-repository)
39
   ((predicates
40
     :initarg :predicates :initform nil
41
     ;reader repository-temporal-predicates
42
     :writer setf-repository-temporal-predicates))
43
   (:documentation
44
    "A temporal object repository introduces indices with an additional field which
45
     contains the timeline location of the respective temporal object term from the
46
     respective statement.
47
     The quad terms are also present as those contribute to algebra operations,
48
     while the timeline location figures in the index only.
49
     These temporal statements are characterized by a declared set of predicates.
50
     Whenever such a statement is added, the timeline location computed for the
51
     respective temporal object term, an extended tquad record is created to
52
     incorporate that time value, and the extended record is added to the
53
     temporal indices in addition to quad record the spog indices.
54
     Independent of record serving as the key, the statement's keyed value can be
55
     null or a revision linear index.
56
     a TEMPORAL-OBJECT-REPOSITORY stores the former content while a
57
     BITEMPORAL-REPOSITORY stores the latter to support models of the
58
     (application-time x transaction-time) pattern."))
59
 
60
 (defclass bitemporal-repository (revisioned-repository temporal-repository)
61
   ()
62
   (:documentation
63
    "A bitemporal repository combines the schematic storage of a revisioned
64
     repository with that of a temporal repository."))
65
 
66
 (defclass time-series-repository (repository)
67
   ((predicates
68
     :initarg :predicates :initform nil
69
     ;reader repository-time-series-predicates
70
     :writer setf-repository-time-series-predicates))
71
   (:documentation
72
    "A time-series repository introduces an index with an additional field
73
     which holds the revision ordinal. This facilitates queries which specify
74
     specific temporal samples and/or stream samples."))
75
 
76
 
77
 (defclass replicable-repository ()
78
   ((replicas
79
     :initform (make-registry)
80
     :reader repository-replicas
81
     :documentation "Retains information for requests to be used to propagate versions.
82
  Keyed by client replication endpoint.")
83
    (replica-location
84
     :accessor repository-replica-location
85
     :documentation "This URL is sent with all porpagation requests to locate
86
  the repository as a replication target. it is analogous to the sparql endpoint location,
87
  but ends with 'replica'.")))
88
 
89
 
90
 (defgeneric quad-repository-p (repository)
91
   (:method ((object t))
92
     nil)
93
   (:method ((repository quad-repository))
94
     t))
95
 
96
 (defgeneric temporal-repository-p (repository)
97
   (:method ((object t))
98
     nil)
99
   (:method ((repository temporal-repository))
100
     t))
101
 (defun repository-is-temporal (designator)
102
   (temporal-repository-p designator))
103
 
104
 (defgeneric repository-temporal-predicate-p (repository predicate)
105
   (:method ((repository repository) (predicate t))
106
     nil))
107
 
108
 (defgeneric repository-time-series-predicate-p (repository predicate)
109
   (:method ((repository repository) (predicate t))
110
     nil))
111
 
112
 
113
 (defgeneric bitemporal-repository-p (repository)
114
   (:method ((object t))
115
     nil)
116
   (:method ((repository bitemporal-repository))
117
     t))
118
 
119
 (defgeneric time-series-repository-p (repository)
120
   (:method ((object t))
121
     nil)
122
   (:method ((repository time-series-repository))
123
     t))
124
 
125
 (defgeneric replicable-repository-p (repository)
126
   (:method ((object t))
127
     nil)
128
   (:method ((repository replicable-repository))
129
     t)
130
   (:method ((repository-id string))
131
     (replicable-repository-p (repository-pathname repository-id))))
132
 
133
 (defun repository-is-replicable (designator)
134
   (replicable-repository-p designator))
135
 
136
 
137
 (defgeneric revisioned-repository-p (repository)
138
   (:documentation "Return true iff the repository maintains a revision history.")
139
   (:method ((object t))
140
     nil)
141
   (:method ((repository revisioned-repository))
142
     t)
143
   (:method ((repository-id string))
144
     (let ((id-type (repository-id-type repository-id)))
145
       (if (and id-type (subtypep id-type *class.revisioned-repository*))
146
           t
147
           (repository-is-revisioned (repository-pathname repository-id))))))
148
 
149
 (defun repository-is-revisioned (designator)
150
   (revisioned-repository-p designator))
151
 
152
 (defgeneric repository-is-view (repository)
153
   (:method ((metadata list))
154
     (loop for property in '("source-repository" "source-view")
155
       ;; if both are present, the the repository is a view
156
       unless (assoc property metadata :test #'string-equal)
157
       return nil
158
       finally (return t))))
159
 
160
 (defclass quad-revision (repository-revision) ())
161
 (defclass revisioned-revision (quad-revision) ())
162
 (defclass temporal-revision (quad-revision) ())
163
 (defclass bitemporal-revision (revisioned-revision temporal-revision) ())
164
 (defclass time-series-revision (repository-revision) ())
165
 (defclass bitemporal-time-series-revision (bitemporal-revision temporal-revision) ())
166
 
167
 (defclass quad-transaction (transaction) ())
168
 (defclass revisioned-transaction (quad-transaction) ())
169
 (defclass temporal-transaction (quad-transaction) ())
170
 (defclass bitemporal-transaction (revisioned-transaction temporal-transaction) ())
171
 (defclass time-series-transaction (transaction) ())
172
 (defclass bitemporal-time-series-transaction (bitemporal-transaction time-series-transaction) ())
173
 
174
 
175
 
176