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

KindCoveredAll%
expression075 0.0
branch012 0.0
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 matrix unit TABLE operator for the 'org.datagraph.spocq' RDF SPARQL engine."
6
 
7
  (copyright
8
   "Copyright 2013 [james anderson](mailto:james.anderson@setf.de) All Rights Reserved."))
9
 
10
 
11
 
12
 (defun matrix-table (result-field dimensions &key (graph nil))
13
   "Generate a table for the possible situations:
14
    - a unit table
15
    - a table iff a constant graph is present
16
    - a uni-dimension stream for all graphs"
17
 
18
   (trace-algebra process-table :result-field result-field :dimensions dimensions :graph graph)
19
   (incf-stat *algebra-operations*)
20
 
21
   (cond ((and (null graph) (member dimensions '(nil spocq.a:|unit|)))
22
          (setf result-field
23
                (make-table-matrix-field :dimensions ())))
24
         ((iri-p graph)
25
          (setf result-field
26
                (if (plusp (repository-pattern-count *repository* nil nil nil graph))
27
                  (make-table-matrix-field :dimensions ())
28
                  (make-null-matrix-field :dimensions dimensions))))
29
         ((and (variable-p graph(equal dimensions (list graph)))
30
          (setf result-field
31
                (initialize-result-field result-field :dimensions dimensions))
32
          (let ((%result-data (cffi:null-pointer))
33
                (result-row 0))
34
            (declare (foreign-type (foreign-array #.+matrix-element-type+ (* 1)) %result-data)
35
                     (type fixnum result-row))
36
            (flet ((collect (term-number)
37
                     (setf (values %result-data result-row) (new-field-row result-field))
38
                     (setf (foreign-array-ref %result-data result-row) term-number)))
39
              (map-repository-contexts #'collect *transaction* :default nil)))
40
          (complete-field-data result-field))
41
         (t
42
          "Invalid table form : ~s~@[ ~s~]." dimensions graph))
43
   (let ((processed (solution-field-length result-field))
44
         (constructed (solution-field-length result-field)))
45
     (incf-stat *solutions-processed* processed)
46
     (incf-stat *solutions-constructed* constructed)
47
     (values result-field processed constructed)))