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

KindCoveredAll%
expression049 0.0
branch010 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 "sparql project operation for matrix fields")
6
 
7
 ;;; (load (compile-file "/development/source/library/org/datagraph/spocq/src/algebra/matrix-operators/project.lisp"))
8
 
9
 
10
 (defmethod spocq.e:project ((source-field matrix-field) bindings &rest arguments &key start end)
11
   "Generate a projected field to a result given a source, bindings and slice (start, end) specifications.
12
  This serves not only an explict projection for a select form, but also the projection
13
  from an explicit extend for aggregation and sorting.
14
  The sort order is reduced to reflect the projected dimensions."
15
   (declare (dynamic-extent arguments))
16
   (let* ((base-dimensions (matrix-field-dimensions source-field))
17
          (length (- (or end (field-length source-field)) (or start 0)))
18
          (result-dimensions (loop for binding in bindings
19
                                   collect (if (consp binding) (first binding) binding)))
20
          (width (length result-dimensions))
21
          (%data (rdfcache:make-matrix length width))
22
          (result-field (clone-matrix-field source-field :data %data
23
                                            :dimensions result-dimensions
24
                                            :sort-dimensions (loop for dimension in (matrix-field-sort-dimensions source-field)
25
                                                                   when (find dimension result-dimensions)
26
                                                                   collect dimension)))
27
          (operator (apply #'matrix-extend-operator result-dimensions base-dimensions
28
                           (loop for binding in bindings
29
                                 when (consp binding)
30
                                 collect binding)
31
                           arguments)))
32
       (apply operator result-field source-field
33
              arguments)
34
       result-field))
35
 
36
 
37
 (defmethod process-project ((result-field matrix-page-channel)
38
                             (source-field matrix-page-channel)
39
                             result-bindings base-dimensions
40
                             &rest args
41
                             &key start end)
42
   "Process a projection by converting it to an extension, possibly to fewer
43
  dimesions, but with the computed values"
44
   (declare (list base-dimensions result-bindings)
45
            (ignore start end))
46
   (assert-argument-types process-slice 
47
     (base-dimensions list)
48
     (result-bindings list))
49
 
50
   (apply #'process-extend result-field source-field
51
          (loop for binding in result-bindings
52
                collect (if (consp binding) (first binding) binding))
53
          base-dimensions
54
          (loop for binding in result-bindings
55
                when (consp binding)
56
                collect binding)
57
          args))
58