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

KindCoveredAll%
expression55163 33.7
branch210 20.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
 ;;;
6
 ;;; disable uri normalization
7
 (setq puri::*normalize-standard-ports* nil)
8
 
9
 ;;;
10
 ;;; parameters
11
 
12
 (defparameter *accounts* (make-registry :test #'equal)
13
   "Caches accounts by name behind the account function")
14
 
15
 (defparameter *authentication-data-key* nil
16
   "Holds the key for password decryption.
17
    It is not present in source, but rather manually introduced into release binaries and retained separately.")
18
 
19
 (defparameter *dataset-source* nil
20
   "Bound by call-with-configuration-bound to :request when either default or named graphs was specified
21
  to indicate that they are specified by the request. If that is not the case, but it is rather in the query
22
  text itself, the parse sets this to :text .")
23
 
24
 (defparameter *dataset-graphs* nil
25
   "The graphs in the current effective dataset for query processing. Established either from values
26
  for default and named graphs specified in the request or those in the query text itself.")
27
 
28
 (defparameter *literal-string-tokens* nil
29
   "The collection of parsed string literals. Distinguishes them from other tokens which are
30
  also represented as strings - eg iri. nb. not the same as the set of strings which are
31
  in the parse result as those are copies.")
32
 
33
 (defparameter *namespace-bindings* '(("rdf" . "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
34
                                      ("rdfs" . "http://www.w3.org/2000/01/rdf-schema#")
35
                                      ("xsd" . "http://www.w3.org/2001/XMLSchema#")
36
                                      ;; these as synonyms for spocql.a ?
37
                                      ("fn" . "http://www.w3.org/2005/xpath-functions#")
38
                                      ("dc" . "http://purl.org/dc/terms/")
39
                                      ("dbp" . "http://dbpedia.org/property/")
40
                                      ("dcterms" . "http://purl.org/dc/terms/")
41
                                      ("foaf" . "http://xmlns.com/foaf/0.1/")
42
                                      ("owl" . "http://www.w3.org/2002/07/owl#")
43
                                      ("geonames" . "http://www.geonames.org/ontology#")
44
                                      ("geo" . "http://www.w3.org/2003/01/geo/wgs84_pos#")
45
                                      ("gr" . "http://purl.org/goodrelations/v1#")
46
                                      ("sfn" . "http://www.w3.org/ns/sparql#")
47
                                      ("skos" . "http://www.w3.org/2004/02/skos/core#")
48
                                      ("swrc" . "http://swrc.ontoware.org/ontology#")
49
                                      ;; from rdf.rb
50
                                      ("cc" . "http://creativecommons.org/ns#")
51
                                      ("cert" ."http://www.w3.org/ns/auth/cert#")
52
                                      ("dc11" ."http://purl.org/dc/elements/1.1/")
53
                                      ("doap" ."http://usefulinc.com/ns/doap#")
54
                                      ("exif" ."http://www.w3.org/2003/12/exif/ns#")
55
                                      ("http" ."http://www.w3.org/2006/http#")
56
                                      ("log" ."http://www.w3.org/2000/10/swap/log#")
57
                                      ("rei" ."http://www.w3.org/2004/06/rei#")
58
                                      ("rsa" ."http://www.w3.org/ns/auth/rsa#")
59
                                      ("rss" ."http://purl.org/rss/1.0/")
60
                                      ("sioc" ."http://rdfs.org/sioc/ns#")
61
                                      ;; the spec has no 'illustrative bindings' section, but
62
                                      ;; the sioct does appear once
63
                                      ;; ("types" ."http://rdfs.org/sioc/types#")
64
                                      ("sioct" ."http://rdfs.org/sioc/types#")
65
                                      ("wot" ."http://xmlns.com/wot/0.1/")
66
                                      ("xhtml" ."http://www.w3.org/1999/xhtml#"))
67
   "The default prefix map used by the sparql parser - an a-list which reflects the prefix declarations.
68
  The keys are case-sensitive. The values are namespace namestring, intended to be combined with prefixed
69
  local parts.")
70
 
71
 
72
 
73
 ;;; (defparameter *accounting-note-channel* nil)
74
 ;;; these are retained for any top-level activity, while the task-specific
75
 ;;; notes are recoreded in the individual instance
76
 (defparameter *accounting-notes*
77
   (make-array 32 :adjustable t :fill-pointer 0))
78
 (defparameter *accounting-notes-lock* (bt:make-lock "accounting notes"))
79
 
80
 
81
 (defparameter *planning-channel* nil)
82
 (defparameter *service-channel* nil
83
   "A channel for tasks from which theressoults are to be streamed as a response to a
84
  service request.")
85
 (defparameter *algebra-task-channel* nil
86
   "The queue of tasks pending algebra processing.
87
   Each task appears once per operation.")
88
 (defparameter *algebra-task-lock* (bt:make-lock "algebra task lock"))
89
 
90
 #+(or)
91
 (defparameter *thread-channel* nil
92
   "The pool of threads available to perform algebra reduction")
93
 
94
 (defparameter *accounting-content-type* mime:application/sse
95
   "The content type to use for account messages.")
96
 
97
 (defparameter *plan-content-type* mime:application/sse
98
   "The content type to use for the plan messages.")
99
 
100
 (defparameter *accounting-exchange* "spocq.account")
101
 
102
 (defvar *accounting-io* nil
103
   "When operating with a messaging broker, the processor binds this to a channel opened
104
  to write accounting notes to an accounting exchange keyed wiht the query id.")
105
 
106
 (defvar *accounting-destination* '*error-output*
107
   "Indicates where the stream processor is to write accounting notes. Is one of
108
  - *error-output* : to error output
109
  - *standard-output* : to standard output
110
  - *accounting-io* : to a message broker
111
  The default value is *error-output*")
112
 
113
 (defun accounting-destination-p (object)
114
   (when (member object '(:amqp :accounting-io *accounting-io*
115
                          :error-output *error-output*
116
                          :standard-output *standard-output*
117
                          :store
118
                          :syslog
119
                          nil))
120
     t))
121
 
122
 (defparameter *accounting-key* nil)
123
 
124
 (defparameter *accounting-queue* "accounting")
125
 
126
 (defparameter *agent* nil
127
   "The authenticated entity under which authorization a task is performed.")
128
 
129
 (defparameter *agent-id* nil
130
   "The id of the requesting agent. NB, this is distinct 'user-id', which an arbitrary string
131
  communicated with the request as well as the 'api-key', which is used for authentication,
132
  but neither communicated back, nore logged.")
133
 
134
 (defparameter *agent-location* nil
135
   "The ip address from which the request was sent. Initialized from the command-line
136
  and bound into the running task.")
137
 
138
 (defparameter *authorize-service-access* t
139
   "When true, require client/service authorization for each service request.")
140
 
141
 (defparameter *propagate-agp-bindings* nil
142
   "Control whether bindings are propagated. The default value, nil, disables propagation.")
143
 
144
 (defparameter *declare-agp-variables* nil
145
   "Control whether variable declarations are included in the AGP. The default value, nil, disables a declaration.")
146
 
147
 (defparameter *agp-maximum-threads* nil)
148
 
149
 (defparameter *agp-sort-patterns* t)
150
 ;;; (defparameter *agp-sort-patterns* t)
151
 ;;; (defparameter *agp-sort-patterns* nil)
152
 
153
 (defparameter *agp-sort-statement-count-minimum* 500
154
   "Establishes a minimum statement count below which agp constituents remain unsorted.")
155
 
156
 (defparameter *algebra-operations* 0
157
   "Counts the number of abstract algebra operations executed by a query.
158
  Rebound by with-accounting")
159
 
160
 (defvar *algebra-package* (find-package :org.datagraph.spocq.algebra))
161
 
162
 (defvar *algebra-operator-thread-count* 2
163
   "The count of threads to be created when reducing partitioned algebra operations, such as
164
  join and leftjoin.")
165
 
166
 (defun algebra-operator-thread-count ()
167
   *algebra-operator-thread-count*)
168
 
169
 (defvar *algebra-thread-count* 2        ; until all source is updated
170
   "The count of threads to be created when reducing partitioned algebra operations, such as
171
  join and leftjoin.")
172
 
173
 (defvar *all-graph-uri* |urn:dydra|:|all|)
174
 
175
 (defparameter *allow-blank-node-verb* nil
176
   "When bound to true, permits blanks nodes as statement pattern verbs. Otherwise such a form
177
  causes the parser to signal an error. Rebound to t when parsing entailment constructs.")
178
 
179
 (defvar *api-key* nil
180
   "Optionally binds a declared api-key to use to authorize a task's access to a repository.
181
  As a metadata property, it can be set as a default for an account or a repository or specified
182
  in the individual request metadata.")
183
 
184
 (defvar *api-access-mode* :read-write-control
185
   "A configuration parameter to specify which operations are permitted. The default :read-write value
186
  indicates query and opdate/modify operations. The alternative :read value prevents writing
187
  and indicates that modify and update operators should signal an error.")
188
 
189
 (defparameter *ask-dimensions* '(?:|boolean|))
190
 
191
 (defparameter *authorize-service-access* t)
192
 
193
 (defparameter *base-iri* nil
194
   "The base uri to combine with relative iri values which appear in a request in cases
195
  when no repository is specified. The [rdf3986](http://www.ietf.org/rfc/rfc3986.txt)
196
  passage indicates, that
197
 
198
    If no base URI is embedded and the representation is not encapsulated
199
    within some other entity, then, if a URI was used to retrieve the
200
    representation, that URI shall be considered the base URI.
201
 
202
  From which the succession from repository uri to host uri is correct.
203
  The value is computed on demand from the hostname if none is specified
204
  by configuration and defaults to the host's http iri. As a metadata property,
205
  it can be set as a default for an account or a repository or specified in the individual
206
  request metadata.")
207
 
208
 (defparameter *bgp-join-mode* :scan
209
   "Specifies how to perform intra bgp joins. Options are :scan (the default) and :match")
210
 
211
 (defparameter *bgp-end-revision* nil
212
   "bound within a bgp to the end revision of the interval which satisfies a revision relation")
213
 (defparameter *bgp-start-revision* nil
214
   "bound within a bgp to the start revision of the interval which satisfies a revision relation")
215
 
216
 (defparameter *bgp-triple-translations*
217
   '(((spocq.a:|triple| ?s |dydra|:|contains| ?o)
218
      . (spocq.a:|filter| (|dydra|:|contains| ?s ?o)))))
219
 
220
 (defparameter *bgp.suppress-null-patterns* t) ; nil)
221
 
222
 (defparameter *blank-node-package*
223
   (or (find-package "_") (make-package "_" :use nil)))
224
 
225
 (defparameter *blank-node-global-label-limit* (1+ (parse-integer "zzzzzzz" :radix 36)))
226
 
227
 (defparameter *blank-node-global-prefix* nil)
228
 
229
 (defparameter *blank-node-prefix* nil
230
   "The prefix to prepend to blank nodes in responses. If null, no prefix is used. If a
231
  zero-length string, then a new prefix is comnputed for each emitted document.")
232
 
233
 (defparameter *blank-node-cons-prefix* "g"
234
   "The prefix to prepend to blank nodes when constructing them internally and for minimal responses
235
  It is not configured and ise used when the *blank-node-prefix* is null.")
236
 
237
 (defparameter *blank-node-skolemize* '|urn:dydra|:|skolemize-insert|
238
   "Specifies whether blank nodes are rewrittein on import and export into unique
239
  identifiers. This has no effect on query processing, as the match process treats a
240
  blank nodes the same as an existential variable. it is matches, but not projected.
241
  The default vaulue is true, which can be over-ridden with the pragma 'skolemize',
242
  which takes the value, |urn:dydra|:|skolemize-insert|, |urn:dydra|:|skolemize-export|, and
243
  |urn:dydra|:|skolemize|")
244
 
245
 (deftype skolemize-mode ()
246
   `(member nil
247
            |urn:dydra|:|skolemize|
248
            |urn:dydra|:|skolemize-export|
249
            |urn:dydra|:|skolemize-insert|))
250
 
251
 (defvar *break-on-filter-errors* nil
252
   "Catch designated error types during filter predicate evaluation and invoke the debugger.
253
  The default value, NIL, causes errors to be ignored and treated as a false result.")
254
 
255
 (defparameter *broker-uri* (puri:uri "amqp://guest:guest@localhost/"))
256
 ;; for local use
257
 ;; (setq spocq.i::*broker-uri* (puri:uri "amqp://guest:guest@ec2-174-129-66-148.compute-1.amazonaws.com/"))
258
 
259
 (defparameter *build-revision* #.(or (cl-user::read-revision) "-"))
260
 
261
 (defparameter *build-timestamp* (iso-time))
262
 
263
 (defparameter *bytes-allocated* 0
264
   "Rebound to the current count at the start of the dynamic context of call-with-accounting.")
265
 
266
 (defparameter *bytes-read* 0
267
   "Rebound to 0 in the dynamic context of call-with-accounting to track bytes read from streams.")
268
 
269
 (defparameter *bytes-written* 0
270
   "Rebound to 0 in the dynamic context of call-with-accounting to track written to streams.")
271
 
272
 (defparameter *cache-account-name* "cache"
273
   "Specifies the account for repositories which cache graphs grom external locations")
274
 
275
 (defparameter *cache-path* '("cache" "run-external-view-request")
276
   "Specify a relative directory path for use by run-external-view-request to cache results.
277
  That root directory should include sub-directories, each os which identifies an authority for which
278
  request results are to be cached. If none is present on cache, results are not cached.
279
  The key the sha1 digest of the printed representatio of the iri string and any request arguments.")
280
 
281
 (defparameter *catalog-root-pathname*
282
   (make-pathname :directory '(:absolute "srv" "dydra" "catalog"))
283
   "The root directory for the store catalog
284
    - repository, account, service authorization, entailment settings, ...")
285
 
286
 (defparameter *channel-sliced-size-limit* 4)
287
 (defparameter *channel-put-wait* nil)
288
 (defparameter *channel-get-wait* t)
289
 
290
 (defparameter *channel-size-limit* 64
291
   "Specifies a limit to pending pages in a channel, especially from a bgp processing thread.")
292
 
293
 (defparameter *solution-count-limit* 5000000
294
   "Specifies a limit materialized solutions in a join/leftjoin.")
295
 
296
 
297
 (defvar *class.account* 'rdfcache-account)
298
 
299
 (defvar *class.agent* 'agent)
300
 (defvar *class.authenticated-agent* 'authenticated-agent)
301
 (defvar *class.located-agent* 'located-agent)
302
 
303
 ;;; the two configuration parameters are mirrors. the implementation is shifting from specization based on
304
 ;;; agp to based on repository.
305
 
306
 (defvar *class.agp* 'rdfcache-agp
307
   "A configuration parameter which specifies how to implement graph patterns.
308
  - amqp-agp, delegates graph processing to a store via amqp.
309
  - hashcache-agp, operates on in-memory, hash-indexed storage.
310
  - rdfcache-agp, uses the rdfcache library for quad pattern retrieval and processes the bgp itself.
311
  The default is rdfcache-agp.")
312
 
313
 (defparameter *class.data-task* 'data-task)
314
 
315
 (defvar *class.query* 'query
316
   "A configuration parameter which specifies how to implement queries.
317
  The default is query")
318
 
319
 (defvar *class.internal-view-repository* 'internal-view-repository)
320
 (defvar *class.lmdb-repository* 'rdfcache-lmdb-repository)
321
 (defvar *class.hdt-repository* 'hdt-repository)
322
 (defvar *class.hdt-storage-class* nil
323
   "At presente there is no variant delegate to handle the concrete storage for hdt documents")
324
 (defvar *class.rdfcache-repository* 'rdfcache-stream-repository)
325
 (defvar *class.replicable-repository* 'lmdb-replicable-repository)
326
 (defvar *class.repository* *class.lmdb-repository*
327
   "A configuration parameter which specifies how to communicate with repositories.
328
  - amqp-repository, delegates graph processing to a store via amqp.
329
  - hashcache-repository, operates on in-memory, hash-indexed storage.
330
  - rdfcache-repository, uses the rdfcache library for quad pattern retrieval and processes the bgp itself.
331
  The default is rdfcache-repository.")
332
 
333
 (defvar *class.request-processor* 'shell-request-processor
334
   "Specifies the processor class for requests processing.
335
  The default is NIL and a value must be specified in the
336
  runtime base implementation.")
337
 
338
 (defparameter *class.revisioned-repository* 'lmdb-revisioned-repository)
339
 
340
 (defvar *class.service-repository* 'service-repository
341
   "The default class for repositories which mediate service requests.")
342
 
343
 (defparameter *class.sparql-script* 'script)
344
 
345
 (defvar *class.task* 'query
346
   "A configuration parameter which specifies how to implement tasks.
347
  The default is query")
348
 
349
 (defvar *class.transaction* 'rdfcache-transaction
350
   "The default class for transactions which mediate store requests.")
351
 
352
 (defparameter *compile-algebra-expression* t
353
   "When true, algebra expressions are compiled rather than interpreted.")
354
 
355
 (defvar *compute-bgp-lambda.trace* nil)
356
 
357
 (defparameter *configuration-keys*
358
   `(:api-key :base-iri :blank-node-prefix :blank-node-skolemize :default-context-term
359
     :describe-form :describe-object-depth :describe-subject-depth
360
     :federation-mode :import-limit :library-path  :memory-limit :named-contexts-term
361
     :prefixes :operation-limit :provenance-repository-id :response-limit :response-offset
362
     :skolemize :skolemize-prefix :strict-vocabulary-terms :undefined-variable-behavior)
363
   "The list of configuration parameter keys which are permitted for an account or repository metadata")
364
 
365
 (defparameter *configuration-pathname* (make-pathname :directory '(:relative) :name "init" :type "sxp"))
366
 
367
 (defparameter *construct-dimensions* (triple-dimensions)
368
   "The dimensions included in response solution field for a construct query.")
369
 
370
 (defparameter *default-context-identifier* 0
371
   "Designates to the store that a match term designates the default context.
372
  When an operation is specific to a storage interface, this is rebound to that repository's indicator,
373
  which, in turn, has been set from, eg. rdfcache:*default-context-number*, based on the *default-context-term*.")
374
 
375
 (defparameter *default-context-term* '|urn:dydra|:|default|
376
   "Indicates which mode to follow when matching against the default context:
377
  <urn:dydra:default> : statements in the default graph (that is, imported without a graph)
378
  <urn:dydra:named> : statements in the union of all named graphs
379
  <urn:dydra:all> : statements in the union of he default and the named graphs,")
380
 
381
 (deftype context-term ()
382
   '(member |urn:dydra|:|all|
383
            |urn:dydra|:|default|
384
            |urn:dydra|:|named|))
385
 
386
 (defparameter *describe-subject-depth* 1)
387
 (defparameter *describe-object-depth* 1)
388
 
389
 (defparameter *describe-dimensions* (triple-dimensions)
390
   "The dimensions included in response solution field for a describe query.")
391
 
392
 (defparameter *describe-form* '|urn:dydra|:|simple-symmetric-concise-bounded-description|
393
   "Specified the navigation form which generates a description field.
394
  <urn:dydra:simple-symmetric-concise-bounded-description>    CBD bidirectional w/o reification
395
  <urn:dydra:simple-concise-bounded-description>              CBD subject->object w/o the reification
396
  <urn:dydra:simple-inverse-concise-bounded-description>      CBD object->subject w/o the reification
397
  ")
398
 
399
 (deftype describe-form ()
400
   '(member |urn:dydra|:|simple-symmetric-concise-bounded-description|
401
            |urn:dydra|:|simple-concise-bounded-description|
402
            |urn:dydra|:|simple-inverse-concise-bounded-description|))
403
 
404
 (defparameter *describe-properties* nil
405
   "binds either a list of property term ids permitted for describe traversal or 't' to indicate all
406
  properies are permitted")
407
 
408
 (defparameter *disabled-repositories* ())
409
 
410
 (defparameter *dynamic-bindings* ()
411
   "Holds a pair of variable and value lists as
412
    ( ( var1 var2 ...) val1 vla2 ...)
413
  fur use as the dynamic bindings. The global value is reboung by the cli main-query operators.")
414
 
415
 (defparameter *enable-sort-precedence* nil
416
   "When true, the ordering operators observe sort precedence, which establishes relations
417
  among otherwise incomparable data type. Globally bound to nil")
418
 
419
 (defparameter *encode-json-term.type-members* nil
420
   ;; 20200611:
421
   ;; json-ld result encoding should now observe the media type compact-or-not
422
   ;; application/json v/s results+json should invoke the respective -compact or -expanded operator
423
   ;; this applies to json-ld contexts and other incidental usage, for which it should be nil
424
   "Indicates whether expanded json literal terms include a type in the dictionary object.
425
    *expand-literal-values* indicates wheter the the dictionary is encoded or just the compact term.")
426
 
427
 (defparameter *encode-object-subtypes* nil
428
   "Specifies whether encoded datatypes distinguish subtypes, eg short, from theie more abstract types,
429
  eg. integer. The default is nil.")
430
 
431
 (defparameter *encode-ssf-object-nil-designator* "nil")
432
 ;;; (defparameter *encode-ssf-object-nil-designator* "<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>")
433
 
434
 (defparameter *encode-turtle-object-as-variable-p* nil
435
   "when true, variables are encoded in turtle and trix as their names")
436
 
437
 (defvar *end-time* nil
438
   "The end of the time interval for re-runs of a repeated query.")
439
 
440
 (defvar *engine-io* nil
441
   "In a store process, binds the stream for messages from/to engines.")
442
 
443
 (defparameter *engine-query-queue* nil
444
   "Specifies the queue to which the engine subscribes to accept queries. The initial value is nil.
445
  Unless configured, at first use, a default value is '<service>.query' is generated.")
446
 
447
 (defparameter *engine-query-routing-key* "query"
448
   "Specifies the topic pattern for queries to which a given engine responds. The default value, '#', accepts
449
  all queries.")
450
 
451
 (defparameter *engine-store-routing-key* nil
452
   "Specifies a globally unique, per instance routing key to bind an algebra engine's store response queue
453
  to the store exchange. If none is specified in a configuration, the combination <short-site-name>.<pid> is
454
  generated at first use. The key is passed with store bgpmatch requests and routes the responses back to
455
  the originating engine instance.")
456
 
457
 (defparameter *engine-store-queue* nil
458
   "Specifies the queue to which a query engine subscribes to accept bgp solution responses. The initial value
459
  is nil. Unless configured a default value is '<service>.store.<site>.<pid>' is generated at first reference.")
460
 
461
 (defparameter *entailment-mode* :none)
462
 
463
 (defparameter *entailment-regime* nil
464
   "The default entailment mechanism as set by configuration")
465
 
466
 (defparameter *entailment-repository-name* "schema/entailment"
467
   "Names the repository into which foreign entailment regimes are loaded.")
468
 
469
 (defparameter *entailment-repository-id* nil
470
   "Bond on-demand to the repository identifier corresponding to *entailment-repository-name*.")
471
 
472
 (defparameter *error-condition-channel* nil)
473
 
474
 (defparameter *error-destination* :store
475
   "The output location for error notes.
476
    Permitted values are a stream, :store or :syslog or some list of those values.")
477
 
478
 (defun error-destination-p (object)
479
   (when (or (member object '(:error-output :standard-output :store :syslog nil))
480
             (streamp object))
481
     t))
482
 
483
 (defparameter *error-routing-suffix* ".error")
484
 
485
 
486
 (defparameter *executable-pathname.admin* nil)
487
 (defun admin-executable-pathname ()
488
   (executable-pathname.admin))
489
 (defun executable-pathname.admin ()
490
   (or *executable-pathname.admin*
491
       (let ((pathname (make-pathname :directory '(:absolute "opt" "dydra" "bin")
492
                                      :name  "dydra-admin")))
493
         (if (setq *executable-pathname.admin* (probe-file pathname))
494
             (setq *executable-pathname.admin* (namestring *executable-pathname.admin*))
495
             (error "no dydra-admin found at ~a" pathname)))))
496
 
497
 (defparameter *executable-pathname.admin-print-view* nil)
498
 (defun executable-pathname.admin-print-view ()
499
   (or *executable-pathname.admin-print-view*
500
       (let ((pathname (make-pathname :directory '(:absolute "opt" "dydra" "bin")
501
                                      :name  "dydra-admin-print-view")))
502
         (if (setq *executable-pathname.admin-print-view* (probe-file pathname))
503
             (setq *executable-pathname.admin-print-view* (namestring *executable-pathname.admin-print-view*))
504
             (error "no dydra-admin-print-view found at ~a" pathname)))))
505
 
506
 (defparameter *executable-pathname.export* nil)
507
 (defun executable-pathname.export ()
508
   (or *executable-pathname.export*
509
       (let ((pathname (make-pathname :directory '(:absolute "opt" "dydra" "bin")
510
                                      :name  "dydra-export")))
511
         (or (setq *executable-pathname.export* (probe-file pathname))
512
             (error "no dydra-export found at ~a" pathname)))))
513
 
514
 (defparameter *executable-pathname.copy* nil)
515
 (defun executable-pathname.copy ()
516
   (or *executable-pathname.copy*
517
       (let ((pathname (make-pathname :directory '(:absolute "bin")
518
                                      :name  "cp")))
519
         (or (setq *executable-pathname.copy* (probe-file pathname))
520
             (error "no dydra-export found at ~a" pathname)))))
521
 
522
 (defparameter *executable-pathname.hdt-merge* nil)
523
 (defun executable-pathname.hdt-merge ()
524
   (or *executable-pathname.hdt-merge*
525
       (let ((pathname (make-pathname :directory '(:absolute "opt" "dydra" "bin")
526
                                      :name  "mergeHDT")))
527
         (or (setq *executable-pathname.hdt-merge* (probe-file pathname))
528
             (error "no mergeHDT found at ~a" pathname)))))
529
 
530
 (defparameter *executable-pathname.import* nil)
531
 (defun executable-pathname.import ()
532
   (or *executable-pathname.import*
533
       (let ((pathname (make-pathname :directory '(:absolute "opt" "dydra" "bin")
534
                                      :name  "dydra-import")))
535
         (or (setq *executable-pathname.import* (probe-file pathname))
536
             (error "no dydra-import found at ~a" pathname)))))
537
 
538
 ;;; gem install json-ld -v 1.11.1  # creates /usr/local/bin/jsonld
539
 (defparameter *executable-pathname.jsonld* "/usr/local/bin/jsonld")
540
 
541
 (defparameter *executable-pathname.rapper* "/usr/bin/rapper")
542
 
543
 (defparameter *executable-pathname.dot* "/usr/bin/rapper")
544
 
545
 (defparameter *executable-pathname.rdfcache*
546
   (namestring (make-pathname :directory '(:absolute "opt" "dydra" "bin") :name "rdfcache")))
547
 
548
 (defparameter *executable-pathname.shasum* "/usr/bin/shasum")
549
 
550
 (defparameter *executable-pathname.trix2nq* "/opt/dydra/bin/trix2nq")
551
 
552
 (defparameter *executable-pathname.tarql* "/opt/dydra/bin/tarql")
553
 
554
 (defparameter *executable-pathname.xslt* "/usr/bin/xsltproc"
555
   "locates an xslt processor which implements version 1.0")
556
 
557
 (defparameter *executable-pathname.zip* "/usr/bin/zip")
558
 
559
 
560
 (defparameter *sparql-query-pathname* "/development/bin/sparql-query")
561
 
562
 (defparameter *roqet-pathname* nil)
563
 
564
 
565
 
566
 
567
 
568
 
569
 
570
 (defparameter *exit-on-errors* t
571
   "Determines in cgi-mode whether to continue after an error occurd or to exit immeidately. The default it true.")
572
 
573
 (defparameter *expand-literal-values* 'number
574
   "Indicates whether encoded literal values have a type attribute.
575
    if null, just the 'literal' member appears
576
    see *encode-json-term.type-members*")
577
 
578
 (defparameter *external-service-request-method* :curl)
579
 (defparameter *external-view-request-method* :curl-csv) ;; alternatively tsv
580
 (defparameter *external-request-timeout* 30)
581
 (defparameter *external-request-retry* 5)
582
 
583
 (defparameter *federation-mode* nil
584
   "When 'internal' or 'external', process service operations. In either case, enable implicit
585
  service processing for graph forms when the graph is non internal. When 'none', suppress service
586
  forms and return empty solution fields.
587
  The initial value, nil, permits any value to be supplied at run-time, either form the global
588
  configuratin file, a configuration specific to the account/repository or a request value.
589
  Once it has been set, succesive source can only make the value more restrictive. cf (setf federation-mode).")
590
 
591
 (deftype federation-mode () '(member |urn:dydra|:|external| |urn:dydra|:|internal| |urn:dydra|:|none|))
592
 
593
 (defun federation-mode ()
594
   "returns the global federation mode, with a global default, none."
595
   (or *federation-mode* '|urn:dydra|:|none|))
596
 
597
 (defparameter *field-page-length* 512
598
   "Specified the numr of solution rows per solution page")
599
 
600
 (defparameter *field-sliced-page-length* 4
601
   "Specified the numr of solution rows per solution page")
602
 
603
 (defparameter *field-optimization* '((speed 3) (safety 0))
604
   "Optmization declaration to apply when compiling algebra operator aspects.")
605
 
606
 (defparameter *fold-agp-filters* t
607
   "When true, fold constants from disjunctive filter clauses into governed bgps.")
608
 
609
 (defparameter *foreign-library-search-path*
610
   (list (make-pathname :directory '(:absolute "opt" "dydra" "lib"))))
611
 ;;; reduce to just that directory
612
 ;;; (make-pathname :directory '(:absolute "development" "source" "library" "com" "b9" "git" "clsql" "uffi"))))
613
 
614
 (defparameter *host-name* nil
615
   "The public hostname. The initial value is nil. It can be set in the start-up parameters.
616
  If not, upon first reference it is retrieved from the OS.
617
  This will differ from the *server-host-name* if the server is behind a proxy.")
618
 
619
 (defvar *import-limit* (* 128 1024 1024)
620
   "Specifies  the byte could limit for imported documnts. Scopes: global, repository, account.")
621
 
622
 (defparameter *import-root-pathname*
623
   (make-pathname :directory '(:absolute "srv" "dydra" "runtime" "imports"))
624
   "The root repository for import files.")
625
 
626
 (defun import-root-pathname ()
627
   *import-root-pathname*)
628
 
629
 (defun import-queue-root-pathname ()
630
   (merge-pathnames (make-pathname :directory '(:relative "queue")) *import-root-pathname*))
631
 
632
 (defparameter *join-propagation-mode* nil ; :propagate
633
   "Indicate whether to process joins by propagating solutions from the between clauses where possible
634
  (:propagate),  or by leaving all variables as is, which leads to scanning in all cases (nil).")
635
 
636
 (defparameter *localhost-authorities*
637
   ()
638
   "serve as equivalent to localhost for internal federation")
639
 
640
 (defparameter *leftjoin-propagation-mode* nil ; favor scanning :propagate
641
   "Indicate whether to process left joins by propagating solutions from the base clause where possible
642
  (:propagate),  or by leaving all variables as is, which leads to scanning in all cases (nil).")
643
 
644
 (defvar *leftjoin-expansion-mode* :literal ; :combine 
645
   "Indicate whether to macro-expand sequential left joins by merging compatible patterns (:logical) or
646
  to leave them as the original, separate forms (:literal).")
647
 
648
 (defparameter *leftjoin-operator* nil
649
   "When set, this fized the leftjoin operator.")
650
 
651
 (defvar *lexical->spocq-term-registry* (make-registry :test #'equal))
652
 
653
 (defvar *library-registry* (make-registry :test #'equal))
654
 
655
 
656
 (defvar *literal-strings* (make-registry :weakness :key)
657
   "A eq/weak-key hash table which maps between the interned data object and its literal string.")
658
 
659
 (defparameter *literal-language-tags* (make-registry :weakness :key)
660
   "A eq/weak-key hash table which maps between the interned/literal string and its language tag.")
661
 
662
 (defparameter *literal-datatypes* (make-registry :weakness :key)
663
   "A eq/weak-key hash table which maps between the interned/literal string and its datatype.")
664
 
665
 (defvar *lmdb-filename* "data.mdb")
666
 
667
 (defparameter *log-compilation-errors* nil
668
   "If true, a compilation error causes a stacktrace to to be written to the server's error log.")
669
 ;; (setq *log-compilation-errors* t)
670
 
671
 
672
 (defparameter *log-condition* nil
673
   "If an error occurs during write-log, the ignored condition is bound to this.")
674
 
675
 (defparameter *log-level* :warn
676
   "The current log level. Used by the log-* operators to filter log entries.")
677
 
678
 (defparameter *log-levels* '(:trace :debug :info :notice :warn :error :critical :fatal))
679
 
680
 ;; the site name for mcl only, since that's where os x mounts the root volume
681
 (defparameter *log-pathname*
682
   (make-pathname :directory (list :absolute #+mcl (short-site-name) "var" "log" "dydra" "spocq")
683
                  :name "debug" :type "log"))
684
 
685
 
686
 ;;; (defparameter *make-channel.class* 'page-ring)
687
 ;;; (defparameter *make-channel.class* 'page-queue)
688
 (defparameter *make-channel.class* 'page-mailbox)
689
 ;;; (defparameter *make-channel.class* 'paged-matrix)
690
 ;;; (defparameter *make-channel.class* 'fifo)
691
 
692
 (defvar *management-thread* nil)
693
 
694
 (defvar *management-thread-interval* 1
695
    "Count in seconds the management thread suspends between accounting/cleanup/status-check cycles.")
696
 
697
 
698
 (defparameter *postgres-user* "postgres")
699
 (defparameter *postgres-password* "postgres")
700
 (defparameter *postgres-authority* "localhost")
701
 
702
 (defvar *processing-thread-interval* 10
703
    "Count in seconds for backgroun processing thread cycles.")
704
 
705
 (defvar *processing-threads* ())
706
 
707
 (defparameter *macroexpand-bgp-phases*
708
   '(;:rewrite-paths  ;; need to happen before annotation
709
     :annotate-patterns
710
     :fold-filters
711
     :rewrite-formula
712
     :rewrite-inferences
713
     ;; the bind- rewrites must precede any which decompose
714
     ;; as the argument and result bindings can span several statements.
715
     :bind-views
716
     :bind-functions
717
     :collate-indexes
718
     :collate-subjects
719
     :iterate-or-join
720
     :suppress-null-cardinality
721
     :base))
722
 
723
 (defparameter *macroexpand-bgp-base-phases*
724
   '(:bind-views
725
     :bind-functions
726
     :suppress-null-cardinality
727
     :base))
728
 
729
 
730
 
731
 (defparameter *match-rate* 20000
732
   "Rate of matches-per-second. Used to determine whether to partition a bgp
733
  for propagation or for a join.")
734
 
735
 (defparameter *match-requests* 0
736
   "Accumulated by bgp match operations. Each quad query operation counts as one request.")
737
 
738
 (defparameter *match-responses* 0
739
   "Accumulated by bgp match operations. Each matched statement counts as one response.")
740
 
741
 (defparameter *match-target-graph* nil
742
   "Binds the target graph active in a basic-graph-pattern matching operation
743
   for use in extension function and path processing")
744
 
745
 (defparameter *materialized-repositories* ()
746
   "A list of those repositoriy identifiers to be handled as materialized views.")
747
 
748
 ;; both unsigned or not...
749
 (eval-when (:compile-toplevel :load-toplevel :execute)
750
   (defconstant +matrix-element-type+ :int)
751
   (defconstant +matrix-element-size+ (cffi:foreign-type-size +matrix-element-type+))
752
   (defconstant +matrix-accessor+ 'sb-sys:signed-sap-ref-32)
753
   (deftype term-number () '(signed-byte 32)))
754
 
755
 #+(or)
756
 (eval-when (:compile-toplevel :load-toplevel :execute)
757
   (defconstant +matrix-element-type+ :long)
758
   (defconstant +matrix-element-size+ (cffi:foreign-type-size +matrix-element-type+))
759
   (defconstant +matrix-accessor+ 'sb-sys:signed-sap-ref-64)
760
   (deftype term-number () '(signed-byte 64)))
761
 
762
 
763
 (defparameter *matrix-fold-length* 1024
764
   "Specifies the row count increment when extending a matrix")
765
     
766
 (defparameter *matrix-page-length* nil
767
   "When an integer, acts in combination with the marix channel to effect streaming
768
  should the row matrix ros count exceed the limit.")
769
     
770
 (defparameter *matrix-trace-output* nil)
771
 
772
 (defvar *memory-limit* (* 32 1024 1024 1024)
773
   "Specifies  the memory limits in bytes allocated to field pages for task data processing,
774
  for use by limit-resources to terminate excessive tasks.")
775
 ;;; (setq *memory-limit* (* 1024 1024 1024))
776
 ;;; (setq *memory-limit* (* 1024 1024 1024))
777
 ;;; (setq *memory-limit* (* 1024 1024 1024))
778
 
779
 (defparameter *metadata* nil
780
   "The current meta-data instance. Re-bound by with-metadata.")
781
 
782
 (defparameter *metadata-root-pathname*
783
   *catalog-root-pathname*)
784
 
785
 (defparameter *metadata-file-name* "metadata"
786
   "The file name for metadata")
787
 
788
 (defparameter *metadata-file-extension* nil
789
   "The file extension for metadata")
790
 
791
 (defvar *mysql-host* "localhost")
792
 ;; production : (setq *mysql-host* "mysql.de1")
793
 ;; de4 : (setq *mysql-host* "127.0.0.1")
794
 ;; james.dev : (setq *mysql-host* "127.0.0.1" *mysql-database* "nl1_nxp")
795
 
796
 (defvar *mysql-database* "wulff")
797
 ;; (setq *mysql-database* "production")
798
 ;; (setq *mysql-database* "de4_wulff")
799
 
800
 ;;; nl1.dydra.com
801
 ;; (setq *mysql-host* "localhost")
802
 ;; (setq *mysql-database* "nl1_nxp")
803
 
804
 (defparameter *named-contexts-term* '|urn:dydra|:|named|
805
   "Indicates which mode to follow when matching against named contexts:
806
  <urn:dydra:default> : statements in the default graph (that is, imported without a graph)
807
  <urn:dydra:named> : statements in the union of all named graphs
808
  <urn:dydra:all> : statements in the union of he default and the named graphs,")
809
 
810
 (defvar +NAMESPACE-DYDRA+ (uuid:make-v5-uuid uuid:+NAMESPACE-DNS+ "dydra.com")
811
     "the uuid namespace to be used to generate root uuid values for dydra")
812
 
813
 (defvar +NAMESPACE-PROVENANCE+ (uuid:make-v5-uuid +NAMESPACE-DYDRA+ "provenance")
814
   "The namespace to be used to generate provenance record task ids")
815
 
816
 (defparameter *nondistinguished-marker-type* :variable
817
   "Specify the type of internal nodes in a generated sequence:
818
  :variable   : generate nondistinguished variables
819
  :blank_node : generate blank nodes.
820
  The default is :variable.")
821
 
822
 (defconstant +null-term-id+ 0
823
   "The distinguished, static value for unbound variables and/or no rdf term.")
824
 
825
 (defconstant +null-term+ 'spocq.a:|nil|)
826
 
827
 (defvar *operation* nil
828
   "The current request operation.")
829
 
830
 (defvar *operation-limit* nil
831
   "Specifies maximum algebra operator count permitted in a query.")
832
 
833
 (defparameter *output-format.jsonld* "--format=nquads")
834
 
835
 (defparameter *page-count* 0
836
   "A running count of pages created within a running server process.")
837
 
838
 (defparameter *parse-sparql.timeout* 10
839
   "The limit in seconds for parsing a sparql query text")
840
 
841
 (defparameter *patches* ()
842
   "To be modified as patches are added. In each case add a p-list with the patch description
843
  (:pathname :time :description)")
844
 
845
 (defparameter *permit-float-special-values* t
846
   "Indicates whether decoding/encoding permits the float special values for
847
  +/- infinity and not-a-number. Iff false, then an attempt to de/encode such an
848
  object signals an error.")
849
 
850
 (defparameter *presentation-codec-package* (find-package :org.datagraph.presentation-codec))
851
 
852
 (defparameter *pidfile-pathname*
853
   (make-pathname :directory (list :absolute #+mcl (short-site-name) "var" "tmp" "run")))
854
 
855
 (defparameter *predicate.event* '|urn:dydra|:|event|)
856
 
857
 ;;; temporary configuration for indexed properties
858
 (defvar *predicate-indices* (make-hash-table :test 'equalp)
859
   "Maps from predicate iri to the identifier for the respective index.
860
  At present loaded as part of the processor configuration, but eventually available
861
  on a per-repository basis.")
862
 
863
 (defparameter *priority* 0)
864
 
865
 (defvar *processes* nil)
866
 
867
 (defparameter *provenance-mode* |urn:dydra|:|internal|
868
   "When 'internal' (the default), process provenance information give a base repository which has an
869
  associated provenance repository.")
870
 
871
 (deftype provenance-mode () '(member |urn:dydra|:|internal| |urn:dydra|:|none|))
872
 
873
 (defparameter *project-null-solution-sets* t
874
   "When true, group, project, and select retain solutions in which no projected variable is bound.
875
  The default is true.")
876
 
877
 (defparameter *provenance-repository-id* nil
878
   "Names the repository to collect provenance information.
879
  This is either a global configuration value or specified in the account or repository metadata.")
880
 
881
 (defparameter *push-agp-filters* t
882
   "When true, filter expressions which are bound within the scope of an individual, directly contained
883
  BGP are pushed into it and interleaved with the triple pattern match operations.
884
  The default is t.")
885
 
886
 (defvar *quad-data-variable-behavior* nil
887
   "Determine how to handle variable in quad data.
888
  The standard result is an error.
889
  Alternatively, when defining rules, it is to rewrite to an iri")
890
 
891
 (defvar *query* nil
892
   "Bound to the current query during dynamic extent of the query expression computation.
893
  Used for generated requests to the store for describe operations.")
894
 
895
 (defparameter *query-evaluation-mode* :compiled
896
   "The value controls whether a query is compiled comonent-wise orjust the wwapper:
897
  :compiled : cause the sse to be compiled down to the nodes
898
  :interpreted : compiles just the wrapper and evaluates the actual algebra sse")
899
 
900
 (defparameter *query-exchange* nil
901
   "Specifies the exchange to which the engine subscribes to accept queries. The initial value is nil.
902
  Unless configured, at first use, a default value is '<service>.query' is generated.")
903
 
904
 (defparameter *query-execution-method* :stream
905
   "Specify how to execute queries:
906
  :reduce : perform bottom-up algebra reduction based on solution-matrices generated from bgp matches
907
  :stream : stream results from bgp matches through an algebra network.")
908
 
909
 (defparameter *query-maximum-length* nil
910
   "The maximum length of a query in bytes. A longer query is rejected.")
911
 
912
 (defparameter *query-maximum-threads* nil
913
   "The maximum number of threads which will be dedicated to a task by query-run-in-thread.
914
  If null, no limit applies.")
915
 
916
 (defparameter *query-operator-thread-threshold* 3
917
   "Specifies the minimum operator count in order that additional threads be allocated to a query.")
918
 
919
 (defparameter *query-prototypes* (make-registry :test 'equal)
920
   "Stores queries by (repository-id signature bindings) to reuse them when a match appears.")
921
 
922
 (defparameter *query-prototypes-maximum-count* 500
923
   "Size limit for query prototype cache")
924
 
925
 (defvar *query-parser* )
926
 
927
 (defvar *query-queue* )
928
 
929
 (defparameter *query-registry* (make-registry :test 'equal)
930
   "A registry which maps query id and bgp id to query instances.")
931
 
932
 (defparameter *query-signature* nil
933
   "A place holder for a command-line setting for the current query, to be used to cache
934
  and or look-up queries.")
935
 
936
 (defvar *quoted-terms )
937
 
938
 (defvar *rdfcache-pathname* nil
939
   "An optional configuration parameter to specify the rdfcache library pathname.
940
  The default is NIL, which leaves the choice to the org.datagraph.rdfcache ffi.")
941
 
942
 (defparameter *rdf-string-length-maximum* (* 1024 64)
943
   "The maximum value string to be permitted to be interned in the store, but with consequence
944
  for intermediate values only if they need to be committed to a solution field.")
945
 
946
 (defparameter *real-time* 0
947
   "Rebound to the initial internal run time at the start of the dynamic context of call-with-accounting.")
948
 
949
 (defparameter *redis-connection* nil)
950
 
951
 (defparameter *redis-default-graph-id*
952
   (with-output-to-string (stream)
953
     (map nil #'(lambda (x) (format stream "~(~2,'0x~)" x))
954
          (ironclad:digest-sequence 'ironclad:sha1 (make-array 0 :element-type '(unsigned-byte 8)))))
955
   "Identifes the default graph to redis stores.")
956
 
957
 (defparameter *redis-port* 6379)
958
 
959
 (defparameter *redis-host* (puri:uri "redis://guest:guest@localhost:6379/"))
960
 
961
 (defparameter *redis-store-name* "datagraph")
962
 
963
 (defparameter *redis-keys* (make-registry :weakness :key))
964
 
965
 (defparameter *reply-routing-suffix* ".reply")
966
 
967
 (defparameter *repositories* (make-registry :test #'equal))
968
 
969
 (defparameter *built-in-repositories* (make-registry :test #'equal))
970
 
971
 (defvar *repository* nil
972
   "Binds the current tasks's repository _revision_ during the dynamic context of its
973
  operations. The revision is used instead of the root repository in order to ensure
974
  that statistics reflect the correct state")
975
 
976
 (defvar *repository-authorization-lists* (make-hash-table :test 'equal)
977
   "Hold statis authorization lists")
978
 
979
 (defvar *repository-id* nil
980
   "Optionally binds a repository id declared in a query pragma to be returned as a property
981
  of the parsed document")
982
 
983
 (defvar *repository-limit* 128
984
   "maximum count in the *repositories* registry at which the oldest repositories
985
  are removed.")
986
 
987
 (defvar *repository-aspect-limit* 256
988
   "Maximum count in a given repository at which half the cached aspect functions are removed.")
989
 
990
 (defvar *repository-bgp-limit* 256
991
   "Maximum count in a given repository at which half the cached bgp functions are removed.")
992
 
993
 (defparameter *repository-resolution-mode* :internal-to-external)
994
 
995
 (deftype repository-resolution-mode ()
996
   '(member
997
     :internal-to-external               ; symbolic link from internal name to external name
998
     :external-to-internal               ; symbolic link from external name to internal name
999
     :none                               ; no symbolic linke
1000
     ))
1001
 
1002
 
1003
 #+(or)
1004
 (defparameter *repository-client-authorizations*
1005
   (load-time-value
1006
    (loop for (repository . authorizations)
1007
          in '((".*" "http://example.*\\.org"))
1008
          collect (cons (cl-ppcre:create-scanner repository)
1009
                        (mapcar #'cl-ppcre:create-scanner authorizations)))))
1010
 
1011
 #+(or)
1012
 (defparameter *repository-service-authorizations*
1013
   (load-time-value
1014
    (loop for (repository . authorizations)
1015
          in '((".*" ".*")                         ; everything can use everything
1016
               )
1017
          collect (cons (cl-ppcre:create-scanner repository)
1018
                        (mapcar #'cl-ppcre:create-scanner authorizations)))))
1019
 
1020
 (defvar *repository-time-to-live* 300
1021
   "Number of seconds before an unused repository is purged.")
1022
 
1023
 (defparameter *request-configuration* ()
1024
   "The parsed, interned argument property list as extracted from the process' command line,
1025
  the request headers, etc. Made available in the dynamic context of call-with-configuration-bound.
1026
  Access with the request-argument function.")
1027
 
1028
 (defparameter *request-content-type* ;; mime:application/octet-stream
1029
   mime:application/sparql-query
1030
   "The default content type for request content.
1031
    Each received message content type can over-ride this.")
1032
 
1033
 (defvar *request-headers* nil
1034
   "The header property list for the current request when it is handled through messaging interface,
1035
  or the association list when handled through the http interface.")
1036
 
1037
 (defvar *request-location* nil
1038
   "The request input source, as bound for convenience by each respective request processor.
1039
  The initial value is NIL.")
1040
 
1041
 (defvar *request-routing-key* nil
1042
   "THe routing key for processing responses when configured for messaging.")
1043
 
1044
 (defvar *request-io* nil
1045
   "Bound to the current request channel/stream while processing a query request or store response.")
1046
 
1047
 (defvar *request-exchange* nil
1048
   "The exchange for processing responses when configured for messaging.")
1049
 
1050
 (defparameter *request-processor* nil
1051
   "Binds a concrete request-processor instance as a proxy for the run-time mode -
1052
  http, command.line, or amqp")
1053
 
1054
 (defparameter *request-properties* nil
1055
   "Binds a property list of those request arguments which are not intrinsic.
1056
  The values are parsed as terms.
1057
  Differs from request values, which are intended to be a bind clause and
1058
  from dynamic bindings, which are marked in the request with an initial '$'.")
1059
 
1060
 (defparameter *request-values* nil
1061
   "binds an sse clause for a request's binding clause")
1062
 
1063
 (defvar *resource-api-endpoint* )
1064
 
1065
 (defparameter *resource-api-endpoints*
1066
   '(;; testing
1067
    ;;"http://dydra.com/hydra/api-definition/get-api-class-definitions.csv"
1068
    ;; nxp data remotely
1069
    "http://qa.nxp.dydra.com/awacs/api-definition/get-api-class-definitions.csv"
1070
    ;; nxp data on nxp-qa
1071
    ;; "http://10.2.1.2/awacs/api-definition/get-api-class-definitions.csv"
1072
    "http://qa.nxp.dydra.com/awacs/roots-r2rml/select-mappings.csv"
1073
   ))
1074
 (defparameter *resource-api-token* NIL)
1075
 
1076
 
1077
 
1078
 (defparameter *response-content-type* mime:application/sparql-results+json-columns
1079
   "The content type to use to initialize the store response channel.
1080
  As the engine initiates this exchange, this setting should determine the encoding.")
1081
 
1082
 (defparameter *response-header-types* '(:shell-operation)
1083
   "A list of header type keywords which deterimes which are written to the
1084
  response preceding the content.
1085
   - :shell-operation : applies to a shell process conntect to the store
1086
   - :timemap : applies to a memento server")
1087
 
1088
 (defparameter *response-limit* nil
1089
   "The overriding solution count limit for a query response.
1090
  This is observed by the encoding operators independent of any slice
1091
  specification in the query text itself.")
1092
 
1093
 (defvar *response-location* nil
1094
   "The request output source, as bound for convenience by each respective request processor.
1095
  The initial value is NIL.")
1096
 
1097
 (defparameter *response-offset* nil
1098
   "The overriding solution count offset for a query response.
1099
  This is observed by the encoding operators independent of any slice
1100
  specification in the query text itself.")
1101
 
1102
 (defparameter *revision-id* nil
1103
   "Binds the specific revision id passed through external interfaces (pragma or cli) for
1104
  use with a query.")
1105
 
1106
 (defparameter *library-path* ()
1107
   "Optionally binds a list of location to be searched to locate functions, rules, constraints, etc.
1108
  The members should be iri. The search protocol takes each element in turn first as a graph in the
1109
  respective query repository and then as a location for a service request in order to retrieve
1110
  the extension entity definition.")
1111
 
1112
 (defun iri-list-p (object)
1113
   (and (listp object) (every #'iri-p object)))
1114
 
1115
 (deftype iri-list () '(satisfies iri-list-p))
1116
 
1117
 (defvar *run-state* nil
1118
   "Indicates one of three states for the entire engine process:
1119
  - nil : loaded, inactive
1120
  - :initialize : resding configuration files, loading libraries, conecting to store
1121
  - :connect : connecting to message broker
1122
  - :configure : establish request processing configuration
1123
  - :process : processing messages
1124
  - :terminate : completing queries and exiting")
1125
 
1126
 (defparameter *run-time* 0
1127
   "Rebound to the initial internal real time at the start of the dynamic context of call-with-accounting.")
1128
 
1129
 (defparameter *runtime-function* 'shell-runtime
1130
   "Specifies the operator to invoke as the tumtime implementation.
1131
  This, a function which accepts unrestricted keyword arguments, is called
1132
  from the main function immediately after process initialization.
1133
  It performs initialization specific to the respective runtime and
1134
  processes queries.
1135
  Upon return, the main process exits.")
1136
 
1137
 (defparameter *scan-rate* 3000000
1138
   "Rate of solutions-per-second scanned. Used to determine whether to partition a bgp
1139
  for propagation or for a join.")
1140
 
1141
 (defparameter *select-bindings* ()
1142
   "Established by a select operator when a BINDINGS clause is present.")
1143
 
1144
 (defparameter *server-host-name* nil
1145
   "The server host name. Can be distinct from the site name in the event there is a proxy mediating this name.
1146
  The initial value is 'dydra.com', but it can be set in the start-up parameters.
1147
  If not, upon first reference it is retrieved from the OS.")
1148
 
1149
 (defparameter *server-uri* nil)
1150
 
1151
 (defparameter *server-protocol* "https")
1152
 
1153
 (defparameter *service-name* "spocq")
1154
 
1155
 (defparameter *service-request-count-limit* 4
1156
   "Specifies the number of service requests to run simultaneously. Relates in some manner with
1157
  the number of processors available, as that correlates to the context-switch free parallelism.
1158
  The default value is 4, but configuration is supported.")
1159
 
1160
 (defparameter *site-name* "dydra.com"
1161
   "The site installation name. Can be distinct from the host name in order to generate entity names which
1162
  are shared among more than one host within an installation - for example account and repository identifiers -
1163
  as opposed to a repository request url.
1164
  The initial value is 'dydra.com', but it can be set in the start-up parameters.
1165
  If not, upon first reference it is retrieved from the OS.")
1166
 
1167
 (defparameter *site-namespace* nil
1168
   "Constructed on-demand to combine the site name with 'http://'")
1169
 
1170
 (defparameter *site-protocol* "https")
1171
 
1172
 (defparameter *site-uri* nil
1173
   "the http url for the site _without_ a trailing slash and with the abstract rather than the server protocol.")
1174
 
1175
 (defparameter *solutions-processed* 0
1176
   "Rebound to 0 at the start of call-with-accounting to track statements examined during reduction.")
1177
 
1178
 (defparameter *solutions-constructed* 0
1179
   "Rebound to 0 at the start of call-with-accounting to track statements created during reduction.")
1180
 
1181
 (defvar *solution-limit* nil
1182
   "Specifies the limit on solutions constructed when processing and individual algebra operation.
1183
  If set, should the intermediate results from an operation exceed this number, the step completes
1184
  prematurely with the partial results")
1185
 
1186
 (defvar *spocq->store-term-registry* (make-registry :test #'equal)
1187
   "Cache store term identifier by spocq term.
1188
  nb. In order to distinguosh numeric values (eg 1.0s0 v/s 1.0d0) this uses an
1189
  equal key, which then requires that the spoc object be interned
1190
  in order to support term structure identity. Anything else will require a 
1191
  custom predicate as in a solution-cache implmentation.")
1192
 
1193
 (defvar *spocq-reader-package* (find-package :org.datagraph.spocq.algebra))
1194
 
1195
 (defparameter *sparql-syntax-package* (find-package :spocq.s)
1196
   "The home package for lexical tokens in the sparql grammar")
1197
 
1198
 (defparameter *sql-verbose* nil)
1199
 
1200
 (defparameter *sse-readtable* (copy-readtable)
1201
   "The readtable established to read sse forms and to pprint them.
1202
  It is set up to preserve case and to read particular sse forms, like variables and
1203
  blank nodes.")
1204
 
1205
 (setf (readtable-case *sse-readtable*) :preserve)
1206
 
1207
 (defparameter *start-timestamp* nil)
1208
 
1209
 (defparameter *statements-returned* 0
1210
   "Rebound to 0 at the start of call-with-accounting to track statements returned in responses.")
1211
 
1212
 (defvar *store->spocq-term-registry* (make-registry :test #'eql))
1213
 
1214
 (defparameter *store-codec-package* (find-package :org.datagraph.store-codec))
1215
 
1216
 (defparameter *store-content-type* mime:application/sparql-query+sse
1217
   "The content type to use to initialize the store request/response channel.
1218
  As the engine initiates this exchange, this setting should determine the encoding.")
1219
 
1220
 (defparameter *store-exchange* nil
1221
   "Specifies the exchange to which the store subscribes to accept queries. The initial value is nil.
1222
  Unless configured, at first use, a default value is '<service>.store' is generated.")
1223
 
1224
 (defvar *store-queue* )
1225
 
1226
 (defparameter *store-store-queue* nil
1227
   "Specifies the queue to which a store engine subscribes to accept bgp match request. The initial value
1228
  is nil. Unless configured a default value is <service>.store is generated generated at first reference.")
1229
 
1230
 (defparameter *store-store-routing-key* "spocq"
1231
   "Specifies the topic pattern to bind a store's request queue to the store exchange.
1232
  This must be specified in the configuration such that it does not conflict with engine keys.
1233
  the default value is 'spocq'.")
1234
 
1235
 (defvar *store-io* nil
1236
   "Bound to the current store channel/stream while processing a query request or store response.")
1237
 
1238
 (defparameter *store-root-pathname*
1239
   (make-pathname :directory '(:absolute "srv" "dydra"))
1240
   "The root repository the store")
1241
 
1242
 (defparameter *runtime-root-pathname*
1243
   (merge-pathnames (make-pathname :directory '(:relative "runtime")) *store-root-pathname*))
1244
 
1245
 (defparameter *store-system-events* nil
1246
   "indicate whether events should be saved for queries and imports to system repositores and/or by system processes.
1247
  default: nil")
1248
 
1249
 (defparameter *store-uri* "tcp://127.0.0.1:5551"
1250
   "Designates the connection to rdfcache.")
1251
 
1252
 (defparameter *strict-aggregation-sample* t)
1253
 
1254
 (defparameter *strict-extend-bindings* t
1255
   "Signal an error if a binding is already preent among the base field dimensions.
1256
  See [http://www.w3.org/TR/sparql11-query/#sparqlGrammar] wrt restrictions.")
1257
 
1258
 (defparameter *strict-vocabulary-terms* t
1259
   "When true, signal an error if a terms is presented which is not in the respective
1260
  vocabulary. If false, intern new term.")
1261
 
1262
 (defvar *syntax-package* (or (find-package :spocq.s)
1263
                              (error "SPARQL syntax package not found."))
1264
   "The home package for SPARQL constant terminal tokens." )
1265
 
1266
 (defparameter *system-account-name* "system")
1267
 
1268
 (defparameter *system-repository-id* "system/system")
1269
 
1270
 (defparameter *system-repository-name* "system")
1271
 
1272
 (defparameter *system-agent* nil
1273
   "Binds an agent instance for use with internal queries - especially against the global system repository")
1274
 
1275
 (defvar *system-api-key* nil
1276
   "Binds a declared api-key to use to authorize the system's access to a system repositories.
1277
  It is loaded as a configuration parameter.")
1278
 
1279
 (defvar *task* nil
1280
   "The current task. Established by with-task-environment.")
1281
 
1282
 (defvar *task-count* 0
1283
   "A running count of tasks performed. Incremented when a task is registered.")
1284
 
1285
 (defvar *task-id* nil
1286
   "Caches a task id between cgi calls")
1287
 
1288
 (defvar *task-name* nil
1289
   "Serves as an indication in messages")
1290
 
1291
 (defvar *task-indices* )
1292
 (setf (documentation '*task-indices* 'variable)
1293
       "Used in a construct form to generate solution-scoped, sequential blank node identifiers
1294
  rdf sequence uir, variables, ...")
1295
 (declaim (type task-indices *task-indices*))
1296
 
1297
 (defvar *task-operation* nil
1298
   "A dynamic binding of the current task's top-level operator. Established by with-task-environment
1299
  and used in some response encodings.")
1300
 
1301
 (defvar *task-parent* nil
1302
   "A dynamic binding of the parent of the current task.")
1303
 
1304
 (defvar *toplevel-function* 'run-management-thread
1305
   "The toplevel function run by a tread. The default value handles query requests via amqp.")
1306
 
1307
 (defparameter *transaction-trace-output* nil
1308
   "When non-null transaction operators trace to the given stream.")
1309
 
1310
 (defvar *thread-count-limit* 50
1311
   "Specifies a limit to the number of operations a thread should perform before it exits.
1312
  over time a thread processes operations roughlt at a rate equal to
1313
    queries-per-second / response-thread-count
1314
  as each query ensures one thread per operation. The premature terminate helps to avoid memory retained by
1315
  a conservative collector. The default value is 50.")
1316
 
1317
 (defvar *thread-name* t
1318
   "If bound to a key from the *thread-specifications* a-list, establish those bindings and
1319
  run the processing loop. If null, create one thread per specification entry, each of which
1320
  establishes its own connections and runs its own look. In non-null, but not a known indicator,
1321
  run a single thread based on the global settings.")
1322
 
1323
 (defvar *thread-operations* nil
1324
   "Collects a list of dynamically bound operation arguments to indicate what tasks and
1325
  task operations the thread is excuting at that moment.")
1326
 
1327
 (defvar *thread-specifications* nil
1328
   "An association list of (name . parameters) which specifies the runtime settings for the respective threads.
1329
  See main().")
1330
 
1331
 (defvar *thread-specifications-running* nil
1332
   "A copy of thread specification as started")
1333
 
1334
 (defparameter *thread-byte-buffer* nil)
1335
 (defparameter *thread-byte-buffer-increment* 128)
1336
 (defun thread-byte-buffer ()
1337
   (or *thread-byte-buffer*
1338
       (setq *thread-byte-buffer*
1339
             (make-array *thread-byte-buffer-increment* :element-type '(unsigned-byte 8)))))
1340
 
1341
 (defparameter *thread-string-buffer* nil)
1342
 (defun thread-string-buffer ()
1343
   (or *thread-string-buffer* (setq *thread-string-buffer* (make-string 64))))
1344
 (defun (setf thread-string-buffer) (value)
1345
   (assert (stringp value) () "invalid string buffer ~s" value)
1346
   (setq *thread-string-buffer* value))
1347
 
1348
 (defvar *time-interval* nil
1349
   "The interval between re-runs of a repeated query.")
1350
 
1351
 (defvar *time-limit* nil
1352
   "Specifies the time limit, in seconds, for task completion, for use by limit-resources to 
1353
  terminate over-time tasks. the initial value is nil to permit arbitrary setting in the initial configuration.")
1354
 ;;; (setq *time-limit*  300)
1355
 ;;; (setq *time-limit*  5000)
1356
 ;;; (setq *time-limit*  5)
1357
 
1358
 (defvar *timebundle-graph-uri* '|urn:dydra|:|timebundle|)
1359
 
1360
 (defvar *timemap-graph-uri* '|urn:dydra|:|timemap|)
1361
 
1362
 (defvar *timemap-properties* ())
1363
 
1364
 #+(or) ;; eliminated -- trace messages go to the request exchange with a trace routing key
1365
 (defvar *trace-io* nil
1366
   "When bound to a channel/stream intermediate query forms and results are written to this destination.")
1367
 
1368
 (defvar *trace-lock* (bt:make-recursive-lock "trace lock"))
1369
 
1370
 (defvar *trace-routing-key* nil
1371
   "THe routing key for trace responses when configured for messaging.")
1372
 
1373
 (defvar *transaction* nil
1374
   "Bound to a rdfcache transaction object during the dynamic extent fo a transaction.")
1375
 
1376
 (defvar *undefined-variable-behavior* '|urn:dydra|:|error|
1377
   "Specifies the effect of an undefined variable in a query expression:
1378
  |urn:dydra|:|error|   : signal a compilation error
1379
  |urn:dydra|:|warning|    : log a warning an treat as unbound
1380
  |urn:dydra|:|dynamicBinding| : declare as special")
1381
 
1382
 (deftype undefined-variable-behavior ()
1383
   '(member |urn:dydra|:|error| |urn:dydra|:|warning| |urn:dydra|:|dynamicBinding|))
1384
 
1385
 (defconstant spocq.a:|unit| 'spocq.a:|unit|)
1386
 
1387
 (defparameter *table-unit-sse* '(spocq.a:|table| spocq.a:|unit|))
1388
 (defparameter *select-table-unit-sse* '(spocq.a:|select| (spocq.a:|table| spocq.a:|unit|) nil))
1389
 
1390
 
1391
 (defparameter *true-all-context-term-number* nil)
1392
 (defparameter *true-default-context-term-number* nil)
1393
 (defparameter *true-named-context-term-number* nil)
1394
 (defparameter *true-none-context-term-number* nil)
1395
 (defparameter *none-context-term-number* -4)
1396
 
1397
 (defvar *user-id* nil
1398
   "Caches a user id between cgi calls")
1399
 
1400
 (defparameter *users* (make-registry :test #'equal)
1401
   "Caches users by name behind the user function")
1402
 
1403
 (defconstant +uuid-length+ 16)
1404
 
1405
 (defparameter *variable-package*
1406
   (or (find-package "?") (error "variable package not found.")))
1407
 
1408
 (defparameter +context-variable+ (cons-symbol *variable-package* "?" "context"))
1409
 
1410
 (defparameter *variables* ())
1411
 
1412
 (defparameter *version* nil
1413
   "During BGP execution this is bound to a revision-interval which combines
1414
   the first and last irdinals for the respective active revision")
1415
 
1416
 (defparameter *wildcard-identifier* nil
1417
   "Designates to the store that a match term is a wildcard. When an operation is specific to a storage
1418
  architecture, this may be rebound to that store's indicator - eg. rdfcache:*wildcard-term-number* for 
1419
  rdfcache.")
1420
 
1421
 (defparameter *xslt-stylesheet* nil
1422
   "when bound to a location, an xml query result stream is post-processed with xslt")
1423
 
1424
 (defvar *zero-duration* nil
1425
   "Bound to a zero-length duration literal once connected to a store.")
1426
 
1427
 
1428
 
1429
 ;;;
1430
 ;;; shorthand numbers
1431
 ;;; just single float, as the serve as markers only
1432
 ;;;
1433
 ;;; *** eventually redefine as symbol macros
1434
 
1435
 (defparameter nan de.setf.amqp.utility:single-float-nan
1436
   "shorthand for single-float-nan")
1437
 (defparameter +inf de.setf.amqp.utility:single-float-positive-infinity
1438
   "shorthand for single-float-positive-infinity")
1439
 (defparameter -inf de.setf.amqp.utility:single-float-negative-infinity
1440
   "shorthand for single-float-negative-infinity")
1441
 
1442
 
1443
 ;;;
1444
 ;;; bound iri terms -> parameters.lisp
1445
 
1446
 ;;; (defstruct ssl:state stack code environment)
1447
 (defparameter sslr:*stack* ())
1448
 
1449
 (defparameter sslr:*code* ()
1450
   "The current SSL code sequence.")
1451
 
1452
 (defparameter sslr:*environment* ())
1453
 
1454
 (defparameter ssl::*toplevel-stack* ())
1455
 (defparameter ssl::*toplevel-code* '(|ssl|:|Query| (|ssl|:|Decode| |ssl|:|Bind| |ssl|:|Project| |ssl|:|Encode|))
1456
   "The initial code performs a parse-bind-project-encode process")
1457
 (defparameter ssl::*toplevel-environment* ())
1458
 
1459