Coverage report: /development/source/library/org/datagraph/spocq-shard/src/algebra/operators/table.lisp

KindCoveredAll%
expression4974 66.2
branch212 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; -*-
2
 
3
 (in-package :org.datagraph.spocq.implementation)
4
 
5
 (:documentation "This file defines the unit TABLE operator for the 'org.datagraph.spocq' RDF SPARQL engine."
6
 
7
  (copyright
8
   "Copyright 2010 [james anderson](mailto:james.anderson@setf.de) All Rights Reserved."))
9
 
10
 
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.
16
 
17
 Per rec-sparql[1], the 'unit' table is 'one solution that does not bind any variables.'
18
 ---
19
 [1]: http://www.w3.org/TR/rdf-sparql-query/#emptyGroupPattern"
20
 
21
   `(spocq.e::table :dimensions ',dimensions ,@(when graph `(:graph ',graph))))
22
 
23
 
24
 (defun spocq.e::table (&key (dimensions 'spocq.a:|unit|) graph)
25
   (table-generator dimensions :graph graph))
26
 
27
 (defun table-generator (dimensions &key graph)
28
   "Generate a table fo the possible situations:
29
    - a unit table
30
    - a table iff a constant graph is present
31
    - a uni-dimension stream for all graphs"
32
 
33
   (cond ((and (null graph) (member dimensions '(nil spocq.a:|unit|)))
34
          (unit-table-generator))
35
         ((iri-p graph)
36
          (if (plusp (repository-pattern-count *repository* nil nil nil graph))
37
            (unit-table-generator)
38
            (null-generator)))
39
         ((and (variable-p graph(equal dimensions (list graph)))
40
          (spocq.e::contexts :dimensions dimensions))
41
         (t
42
          "Invalid table form : ~s~@[ ~s~]." dimensions graph)))
43
 
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)
48
                'spocq.a:|table|))
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
53
                                :constituents ()))))
54
 
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)
60
 
61
   (put-field-page destination (unit-table))
62
   (complete-field destination))
63
 
64
   
65
 
66
 ;;; (spocq.a:|table| spocq.a:|unit|)
67