Coverage report: /development/source/library/com/dydra/gitlab/dydra-cgi/ffi/lisp/rdfcache/term-cursor.lisp
| Kind | Covered | All | % |
| expression | 0 | 124 | 0.0 |
| branch | 0 | 10 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
3
;; Term Cursor API: Private
5
(defun term-cursor-init (cursor-pointer term-position &key (distinct t) (ordered t))
6
(declare (type foreign-pointer cursor-pointer)
7
(type keyword term-position)
8
(type boolean distinct ordered)
9
(ignore ordered)) ;; TODO: do something useful with ORDERED
10
(with-checked-errno-result "rdfcache_term_cursor_init"
11
(%%term-cursor-init cursor-pointer
12
(the fixnum (if distinct 1 0))
15
(defun term-cursor-dispose (cursor-pointer)
16
(declare (type foreign-pointer cursor-pointer))
17
(with-checked-errno-result "rdfcache_term_cursor_dispose"
18
(%%term-cursor-dispose cursor-pointer)))
20
(defun term-cursor-open (cursor-pointer transaction-pointer &key (context-number *all-context-number*))
21
(declare (type foreign-pointer cursor-pointer transaction-pointer)
22
(type fixnum context-number))
23
(with-checked-int-result "rdfcache_term_cursor_open"
24
(%%term-cursor-open cursor-pointer
25
(transaction-uuid-pointer transaction-pointer)
28
(defun term-cursor-count (cursor-pointer)
29
(declare (type foreign-pointer cursor-pointer))
30
(with-checked-long-result "rdfcache_term_cursor_count"
31
(%%term-cursor-count cursor-pointer)))
33
(declaim (inline term-cursor-next))
34
(defun term-cursor-next (cursor-pointer)
35
(declare (type foreign-pointer cursor-pointer))
36
(not (zerop (%%term-cursor-next cursor-pointer))))
38
(defun term-cursor-skip (cursor-pointer &optional (count 1))
39
(declare (type foreign-pointer cursor-pointer)
41
(%%term-cursor-skip cursor-pointer count))
43
(defun term-cursor-close (cursor-pointer)
44
(declare (type foreign-pointer cursor-pointer))
45
(with-checked-errno-result "rdfcache_term_cursor_close"
46
(%%term-cursor-close cursor-pointer)))
48
;; Term Cursor API: Macros
50
(defmacro term-cursor-term-number (cursor-var)
51
`(foreign-slot-value ,cursor-var 'term-cursor 'term-number))
53
(defmacro with-context-cursor ((cursor-var transaction-pointer &key (distinct t) (ordered t)) &body body)
54
`(with-foreign-object (,cursor-var '(:struct term-cursor))
55
(term-cursor-init ,cursor-var :context :distinct ,distinct :ordered ,ordered)
56
(unwind-protect (progn (term-cursor-open ,cursor-var ,transaction-pointer)
58
(term-cursor-close ,cursor-var)
59
(term-cursor-dispose ,cursor-var))))
61
(defun map-term-numbers (function %transaction position &key (distinct t) (ordered t) (context *all-context-number*))
62
(declare (dynamic-extent function))
63
(with-foreign-object (%cursor '(:struct term-cursor))
64
(term-cursor-init %cursor position :distinct distinct :ordered ordered)
65
(unwind-protect (progn (term-cursor-open %cursor %transaction :context-number context)
66
(loop for count from 0
67
until (null (term-cursor-next %cursor))
68
do (funcall function (term-cursor-term-number %cursor))
69
finally (return count)))
70
(term-cursor-close %cursor)
71
(term-cursor-dispose %cursor))))
73
;; Term Cursor API: Public
75
(defun map-context-numbers (function transaction-pointer &key (distinct t) (ordered t)) ;; used by SPOCQ
76
(declare (dynamic-extent function))
77
(with-context-cursor (cursor transaction-pointer :distinct distinct :ordered ordered)
78
(loop for count from 0
79
until (null (term-cursor-next cursor))
80
do (funcall function (term-cursor-term-number cursor))
81
finally (return count))))
83
(defun map-subject-numbers (function %transaction &key (distinct t) (ordered t) (context *all-context-number*)) ;; used by SPOCQ
84
(declare (dynamic-extent function))
85
(map-term-numbers function %transaction :subject
86
:distinct distinct :ordered ordered :context context))
88
(defun map-predicate-numbers (function %transaction &key (distinct t) (ordered t) (context *all-context-number*)) ;; used by SPOCQ
89
(declare (dynamic-extent function))
90
(map-term-numbers function %transaction :predicate
91
:distinct distinct :ordered ordered :context context))
93
(defun map-object-numbers (function %transaction &key (distinct t) (ordered t) (context *all-context-number*)) ;; used by SPOCQ
94
(declare (dynamic-extent function))
95
(map-term-numbers function %transaction :object
96
:distinct distinct :ordered ordered :context context))