Coverage report: /development/source/library/com/dydra/gitlab/dydra-cgi/ffi/lisp/dydra-ndk/quad_cursor.lisp
| Kind | Covered | All | % |
| expression | 0 | 143 | 0.0 |
| branch | 0 | 6 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
(in-package :dydra-ndk)
3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5
(defctype size_t :ullong "std::size_t")
7
;; Quad cursors are opaque dydra::term_cursor structures allocated on the
8
;; foreign heap and referenced indirectly through a foreign pointer.
9
(defctype quad-cursor :pointer
10
"Quad cursor handle.")
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
(defcfunwi ("dydra_quad_cursor_make" %%quad-cursor-make) quad-cursor
15
(transaction-uuid (:pointer uuid))
18
(predicate-id term-id)
22
(defcfunwi ("dydra_quad_cursor_free" %%quad-cursor-free) :void
25
(defcfun ("dydra_quad_cursor_set_offset" %%quad-cursor-set-offset) :void
29
(defcfun ("dydra_quad_cursor_set_limit" %%quad-cursor-set-limit) :void
33
(defcfun ("dydra_quad_cursor_set_buffer" %%quad-cursor-set-buffer) :void
37
(defcfun ("dydra_quad_cursor_set_flags" %%quad-cursor-set-flags) :void
41
(defcfun ("dydra_quad_cursor_add_graph" %%quad-cursor-add-graph) :void
45
(defcfun ("dydra_quad_cursor_set_graph" %%quad-cursor-set-graph) :void
49
(defcfun ("dydra_quad_cursor_get_id" %%quad-cursor-get-id) :uint64
52
(defcfun ("dydra_quad_cursor_get_term" %%quad-cursor-get-term) term-id
56
(defcfun ("dydra_quad_cursor_get_quad" %%quad-cursor-get-quad) (:pointer quad)
59
(defcfun ("dydra_quad_cursor_get_position" %%quad-cursor-get-position) size_t
62
(defcfun ("dydra_quad_cursor_open" %%quad-cursor-open) :void
65
(defcfun ("dydra_quad_cursor_close" %%quad-cursor-close) :void
68
(defcfun ("dydra_quad_cursor_count" %%quad-cursor-count) size_t
71
(defcfun ("dydra_quad_cursor_has_next" %%quad-cursor-has-next) :boolean
74
(defcfun ("dydra_quad_cursor_next" %%quad-cursor-next) :boolean
77
(defcfun ("dydra_quad_cursor_skip" %%quad-cursor-skip) size_t
81
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
83
(defun make-quad-cursor (transaction-uuid graph-id* subject-id predicate-id object-id
84
&key (distinct nil) (ordered t) (graph nil)
85
(offset nil) (limit nil) (buffer nil))
86
"Creates a new transaction-scoped quad cursor, returning its handle."
87
(declare (type foreign-pointer transaction-uuid)
88
(type (or list fixnum) graph-id*)
89
(type fixnum subject-id predicate-id object-id)
90
(type boolean distinct ordered)
91
(type (or fixnum null) graph)
92
(type (or integer null) offset limit buffer))
93
(let ((cursor (%%quad-cursor-make transaction-uuid
94
(if (integerp graph-id*) graph-id* 0)
95
subject-id predicate-id object-id
96
(if (or distinct ordered) 1 0))))
97
(when (listp graph-id*)
98
(dolist (graph-id graph-id*)
99
(%%quad-cursor-add-graph cursor graph-id)))
100
(when graph (%%quad-cursor-set-graph cursor graph))
101
(when offset (%%quad-cursor-set-offset cursor offset))
102
(when limit (%%quad-cursor-set-limit cursor limit))
103
(when buffer (%%quad-cursor-set-buffer cursor buffer))
104
(%%quad-cursor-open cursor)
107
(defun free-quad-cursor (cursor)
108
(declare (type foreign-pointer cursor))
109
(%%quad-cursor-free cursor))
111
(defun quad-cursor-id (cursor)
112
(declare (type foreign-pointer cursor))
113
(%%quad-cursor-get-id cursor))
115
(defun quad-cursor-term (cursor term-position)
116
(declare (type foreign-pointer cursor)
117
(type fixnum term-position))
118
(%%quad-cursor-get-term cursor term-position))
120
(defun quad-cursor-graph-id (cursor)
121
(declare (type foreign-pointer cursor))
122
(quad-cursor-term cursor 0))
124
(defun quad-cursor-subject-id (cursor)
125
(declare (type foreign-pointer cursor))
126
(quad-cursor-term cursor 1))
128
(defun quad-cursor-predicate-id (cursor)
129
(declare (type foreign-pointer cursor))
130
(quad-cursor-term cursor 2))
132
(defun quad-cursor-object-id (cursor)
133
(declare (type foreign-pointer cursor))
134
(quad-cursor-term cursor 3))
136
(defun quad-cursor-quad (cursor)
137
(declare (type foreign-pointer cursor))
138
(%%quad-cursor-get-quad cursor))
140
(defun quad-cursor-position (cursor)
141
(declare (type foreign-pointer cursor))
142
(%%quad-cursor-get-position cursor))
144
(defun quad-cursor-count (cursor)
145
(declare (type foreign-pointer cursor))
146
(%%quad-cursor-count cursor))
148
(defun quad-cursor-close (cursor)
149
(declare (type foreign-pointer cursor))
150
(%%quad-cursor-close cursor))
152
(defun quad-cursor-next (cursor)
153
(declare (type foreign-pointer cursor))
154
(%%quad-cursor-next cursor))
156
(defun quad-cursor-skip (cursor &optional (count 1))
157
(declare (type foreign-pointer cursor)
158
(type integer count))
159
(%%quad-cursor-skip cursor count))
161
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
163
(defun print-quad-cursor (cursor &optional (stream *standard-output*))
164
(declare (type foreign-pointer cursor))
165
(print-unreadable-object (cursor stream :type nil :identity t)
166
(format stream "DYDRA-NDK:QUAD-CURSOR #~s"
167
(quad-cursor-id cursor))))
169
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
171
(defun count-matched-quads (transaction-uuid graph-id* subject-id predicate-id object-id
172
&key (offset nil) (limit nil))
173
"Executes a transaction-scoped quad-pattern match, returning the matched quad count."
174
(declare (type foreign-pointer transaction-uuid)
175
(type (or list fixnum) graph-id*)
176
(type fixnum subject-id predicate-id object-id)
177
(type (or integer null) offset limit))
178
(let* ((cursor (make-quad-cursor transaction-uuid graph-id* subject-id predicate-id object-id
179
:distinct t :ordered nil :graph nil
180
:offset offset :limit limit :buffer nil))
181
(count (quad-cursor-count cursor)))
182
(free-quad-cursor cursor)