Coverage report: /development/source/library/com/dydra/gitlab/dydra-cgi/ffi/lisp/dydra-ndk/query.lisp

KindCoveredAll%
expression086 0.0
branch02 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 (in-package :dydra-ndk)
2
 
3
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4
 
5
 (defcfun ("dydra_query_tally_by_uuid_str" %%query-tally) :void (query-uuid-string :string) (key :string) (value :string))
6
 
7
 ;; BGP queries are opaque dydra::bgp_query structures allocated on the
8
 ;; foreign heap and referenced indirectly through a foreign pointer.
9
 (defctype bgp-query :pointer
10
   "BGP query handle.")
11
 
12
 ;; SPARQL queries are opaque dydra::sparql_query structures allocated on the
13
 ;; foreign heap and referenced indirectly through a foreign pointer.
14
 (defctype sparql-query :pointer
15
   "SPARQL query handle.")
16
 
17
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18
 
19
 (defun record-query-accounting-entry (query-uuid-string key value)
20
   (declare (type string query-uuid-string)
21
            (type (or string null) key))
22
   (when (and key value)
23
     (%%query-tally query-uuid-string key (write-to-string value)))
24
   (values))
25
 
26
 (defun %record-query-accounting (query-uuid-string query-accounting)
27
   (declare (type (or string foreign-pointer) query-uuid-string)
28
            (type list query-accounting)) ;; a plist, more specifically
29
   (loop for (k v) on query-accounting by #'cddr do
30
     ;(format t "k=~S v=~S ~%" k v) ; DEBUG
31
     (case k
32
       (:|query_time|
33
        (record-query-accounting-entry query-uuid-string nil v)) ;; ignored
34
       (:|state|
35
        (record-query-accounting-entry query-uuid-string nil v)) ;; ignored
36
       (:|solutions_returned|
37
        (record-query-accounting-entry query-uuid-string "solutions-returned" v))
38
       (:|solutions_processed|
39
        (record-query-accounting-entry query-uuid-string "solutions-processed" v))
40
       (:|solutions_constructed|
41
        (record-query-accounting-entry query-uuid-string "solutions-constructed" v))
42
       ((:|real_time| :|elapsed_time|)
43
        (record-query-accounting-entry query-uuid-string "elapsed-time" v))
44
       (:|parse_run_time|
45
        (record-query-accounting-entry query-uuid-string nil v)) ;; ignored
46
       ((:|run_time| :|process_time|)
47
        (record-query-accounting-entry query-uuid-string "process-time" v))
48
       (:|match_responses|
49
        (record-query-accounting-entry query-uuid-string "match-responses" v))
50
       (:|match_requests|
51
        (record-query-accounting-entry query-uuid-string "match-requests" v))
52
       (:|bytes_allocated|
53
        (record-query-accounting-entry query-uuid-string "bytes-allocated" v))
54
       (:|algebra_operations|
55
        (record-query-accounting-entry query-uuid-string "algebra-operations" v))
56
       (:|signature|
57
        (record-query-accounting-entry query-uuid-string nil v)) ;; ignored
58
       (:|agent|
59
        (record-query-accounting-entry query-uuid-string nil v)) ;; ignored
60
       (otherwise nil))) ;; ignore unknown keys, for future-proofness
61
   (let ((null-pointer (null-pointer)))
62
     (%%query-tally query-uuid-string null-pointer null-pointer))
63
   (values))
64
 
65
 (defun record-query-accounting (&rest arguments)
66
   (ecase (length arguments)
67
     (2 (apply #'%record-query-accounting arguments))
68
     (4 (%record-query-accounting (first arguments) (fourth arguments)))))