Coverage report: /development/source/library/org/datagraph/spocq-shard/src/core/repository-classes.lisp
| Kind | Covered | All | % |
| expression | 16 | 54 | 29.6 |
| branch | 2 | 4 | 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; -*-
3
(in-package :org.datagraph.spocq.implementation)
5
(:documentation "SPOCQ abstract repository definition"
6
"Define the abstract variants based on REPOSITORY and REVISIONED-REPOSITORY
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
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.
24
;;; abstract classes relative to the root REPOSITORY class:
26
(defclass quad-repository (repository)
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)
33
(:documentation "The protocol class for repositories which store revision metadata"))
34
(defclass revisioned-repository ()
36
(:documentation "The protocol class for revisioned/archive repository implementations."))
38
(defclass temporal-repository (quad-repository)
40
:initarg :predicates :initform nil
41
;reader repository-temporal-predicates
42
:writer setf-repository-temporal-predicates))
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
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."))
60
(defclass bitemporal-repository (revisioned-repository temporal-repository)
63
"A bitemporal repository combines the schematic storage of a revisioned
64
repository with that of a temporal repository."))
66
(defclass time-series-repository (repository)
68
:initarg :predicates :initform nil
69
;reader repository-time-series-predicates
70
:writer setf-repository-time-series-predicates))
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."))
77
(defclass replicable-repository ()
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.")
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'.")))
90
(defgeneric quad-repository-p (repository)
93
(:method ((repository quad-repository))
96
(defgeneric temporal-repository-p (repository)
99
(:method ((repository temporal-repository))
101
(defun repository-is-temporal (designator)
102
(temporal-repository-p designator))
104
(defgeneric repository-temporal-predicate-p (repository predicate)
105
(:method ((repository repository) (predicate t))
108
(defgeneric repository-time-series-predicate-p (repository predicate)
109
(:method ((repository repository) (predicate t))
113
(defgeneric bitemporal-repository-p (repository)
114
(:method ((object t))
116
(:method ((repository bitemporal-repository))
119
(defgeneric time-series-repository-p (repository)
120
(:method ((object t))
122
(:method ((repository time-series-repository))
125
(defgeneric replicable-repository-p (repository)
126
(:method ((object t))
128
(:method ((repository replicable-repository))
130
(:method ((repository-id string))
131
(replicable-repository-p (repository-pathname repository-id))))
133
(defun repository-is-replicable (designator)
134
(replicable-repository-p designator))
137
(defgeneric revisioned-repository-p (repository)
138
(:documentation "Return true iff the repository maintains a revision history.")
139
(:method ((object t))
141
(:method ((repository revisioned-repository))
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*))
147
(repository-is-revisioned (repository-pathname repository-id))))))
149
(defun repository-is-revisioned (designator)
150
(revisioned-repository-p designator))
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)
158
finally (return t))))
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) ())
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) ())