Coverage report: /development/source/library/org/datagraph/spocq-shard/src/algebra/operators/table.lisp
| Kind | Covered | All | % |
| expression | 49 | 74 | 66.2 |
| branch | 2 | 12 | 16.7 |
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
(:documentation "This file defines the unit TABLE operator for the 'org.datagraph.spocq' RDF SPARQL engine."
8
"Copyright 2010 [james anderson](mailto:james.anderson@setf.de) All Rights Reserved."))
11
(defmacro spocq.a:|table| (&optional dimensions &key graph)
12
"( ( variable*? ) solutionField )
13
A TABLE form produces an zero-dimension solution field with a single solution.
14
If in the scope of a GRAPH form, a constant graph name will reduce the result
15
to a null field if the graph does not exist.
17
Per rec-sparql[1], the 'unit' table is 'one solution that does not bind any variables.'
19
[1]: http://www.w3.org/TR/rdf-sparql-query/#emptyGroupPattern"
21
`(spocq.e::table :dimensions ',dimensions ,@(when graph `(:graph ',graph))))
24
(defun spocq.e::table (&key (dimensions 'spocq.a:|unit|) graph)
25
(table-generator dimensions :graph graph))
27
(defun table-generator (dimensions &key graph)
28
"Generate a table fo the possible situations:
30
- a table iff a constant graph is present
31
- a uni-dimension stream for all graphs"
33
(cond ((and (null graph) (member dimensions '(nil spocq.a:|unit|)))
34
(unit-table-generator))
36
(if (plusp (repository-pattern-count *repository* nil nil nil graph))
37
(unit-table-generator)
39
((and (variable-p graph) (equal dimensions (list graph)))
40
(spocq.e::contexts :dimensions dimensions))
42
"Invalid table form : ~s~@[ ~s~]." dimensions graph)))
44
(defun unit-table-generator ()
45
(let ((result-channel (make-unit-table-channel :dimensions nil)))
46
(labels ((run-table-thread (result-channel)
47
(process-unit-table result-channel)
49
(make-solution-generator :operator 'spocq.a:|table|
50
:dimensions nil ; actual dimensions are null
51
:expression (list #'run-table-thread result-channel)
52
:channel result-channel
55
(defun process-unit-table (destination)
56
(assert-argument-types process-table
57
(destination (or channel function)))
58
(incf-stat *algebra-operations*)
59
(trace-algebra process-table)
61
(put-field-page destination (unit-table))
62
(complete-field destination))
66
;;; (spocq.a:|table| spocq.a:|unit|)