Coverage report: /development/source/library/org/datagraph/spocq-shard/src/core/encoding/terms/nquads-shard-term.lisp
| Kind | Covered | All | % |
| expression | 48 | 81 | 59.3 |
| branch | 3 | 8 | 37.5 |
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
;;; replace the nquads field encoding operator with one which retrieves terms directly from lmdb.
6
;;; delegates to turtle term encoding
8
(defmethod write-rdf-nquads :around ((results solution-generator) (stream t))
9
(rlmdb::with-string-database (sdb)
12
(fmakunbound 'write-rdf-field-nquads)
14
(defun write-rdf-field-nquads (page variables stream &optional (index 0) (start 0) end)
15
(assert (= (length (array-dimensions page)) 2) () "invalid result array dimensions: ~a" (array-dimensions page))
16
(let ((width (array-dimension page 1))
17
(default-graph-term (when *nquads-default-graph-term* (iri-lexical-form *nquads-default-graph-term*))))
18
(dotimes (page-index (array-dimension page 0))
19
(when (>= index start)
20
(when (and end (>= index end))
22
(loop for value-index from 0 below width
23
do (let ((term-id (aref page page-index value-index)))
24
;; (print (list page-index value-index term-id))
28
(when default-graph-term
29
(format stream "<~a>" default-graph-term))
30
(ecase *ntriples-unbound-term-mode*
31
(spocq:unbound-variable
32
(format stream "<urn:dydra:unbound~@[:~a~]>" (nth value-index variables)))
34
(error "invalid null ntriples/nquads term.")))))
36
;; suppress the term as the graph designator
38
(when default-graph-term
39
(format stream "<~a>" default-graph-term))))
41
(write-string "<urn:dydra:named>" stream))
43
(encode-turtle-term-number term-id stream)))
44
(write-char #\space stream)))
45
(write-char #\. stream)