@comunica/actor-optimize-query-operation-prune-empty-source-operations 3.0.1-alpha.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +22 -0
- package/README.md +43 -0
- package/components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld +186 -0
- package/components/components.jsonld +11 -0
- package/components/context.jsonld +46 -0
- package/lib/ActorOptimizeQueryOperationPruneEmptySourceOperations.d.ts +34 -0
- package/lib/ActorOptimizeQueryOperationPruneEmptySourceOperations.js +117 -0
- package/lib/ActorOptimizeQueryOperationPruneEmptySourceOperations.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/package.json +48 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Comunica Prune Empty Source Operations Optimize Query Operation Actor
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/actor-optimize-query-operation-prune-empty-source-operations)
|
|
4
|
+
|
|
5
|
+
An [Optimize Query Operation](https://github.com/comunica/comunica/tree/master/packages/bus-optimize-query-operation) actor
|
|
6
|
+
that removes operations from the query plan that are guaranteed to produce empty results.
|
|
7
|
+
This actor relies on source-based cardinality metadata,
|
|
8
|
+
or may optionally make use of ASK queries if the source supports it.
|
|
9
|
+
|
|
10
|
+
This module is part of the [Comunica framework](https://github.com/comunica/comunica),
|
|
11
|
+
and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
|
|
12
|
+
|
|
13
|
+
[Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ yarn add @comunica/actor-optimize-query-operation-prune-empty-source-operations
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configure
|
|
22
|
+
|
|
23
|
+
After installing, this package can be added to your engine's configuration as follows:
|
|
24
|
+
```text
|
|
25
|
+
{
|
|
26
|
+
"@context": [
|
|
27
|
+
...
|
|
28
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-prune-empty-source-operations/^1.0.0/components/context.jsonld"
|
|
29
|
+
],
|
|
30
|
+
"actors": [
|
|
31
|
+
...
|
|
32
|
+
{
|
|
33
|
+
"@id": "urn:comunica:default:optimize-query-operation/actors#prune-empty-source-operations",
|
|
34
|
+
"@type": "ActorOptimizeQueryOperationPruneEmptySourceOperations",
|
|
35
|
+
"useAskIfSupported": false
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Config Parameters
|
|
42
|
+
|
|
43
|
+
* `useAskIfSupported`: If true, ASK queries will be sent to the source instead of COUNT queries to check emptiness for patterns. This will only be done for sources that accept ASK queries. _(defaults to `false`)_
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-prune-empty-source-operations/^3.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^3.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^3.0.0/components/context.jsonld"
|
|
6
|
+
],
|
|
7
|
+
"@id": "npmd:@comunica/actor-optimize-query-operation-prune-empty-source-operations",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations",
|
|
11
|
+
"@type": "Class",
|
|
12
|
+
"requireElement": "ActorOptimizeQueryOperationPruneEmptySourceOperations",
|
|
13
|
+
"extends": [
|
|
14
|
+
"cboqo:components/ActorOptimizeQueryOperation.jsonld#ActorOptimizeQueryOperation"
|
|
15
|
+
],
|
|
16
|
+
"comment": "A comunica Prune Empty Source Operations Optimize Query Operation Actor.",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_useAskIfSupported",
|
|
20
|
+
"range": "xsd:boolean",
|
|
21
|
+
"default": "false",
|
|
22
|
+
"comment": "If true, ASK queries will be sent to the source instead of COUNT queries to check emptiness for patterns. This will only be done for sources that accept ASK queries."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_name",
|
|
26
|
+
"range": "xsd:string",
|
|
27
|
+
"default": {
|
|
28
|
+
"@id": "rdf:subject"
|
|
29
|
+
},
|
|
30
|
+
"comment": "The name for this actor."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_bus",
|
|
34
|
+
"range": {
|
|
35
|
+
"@type": "ParameterRangeGenericComponent",
|
|
36
|
+
"component": "cc:components/Bus.jsonld#Bus",
|
|
37
|
+
"genericTypeInstances": [
|
|
38
|
+
{
|
|
39
|
+
"@type": "ParameterRangeGenericComponent",
|
|
40
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
41
|
+
"genericTypeInstances": [
|
|
42
|
+
{
|
|
43
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
44
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
48
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
52
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
58
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
62
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
66
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"default": {
|
|
71
|
+
"@id": "cboqo:components/ActorOptimizeQueryOperation.jsonld#ActorOptimizeQueryOperation_default_bus",
|
|
72
|
+
"@type": "cc:components/Bus.jsonld#Bus"
|
|
73
|
+
},
|
|
74
|
+
"comment": "The bus this actor subscribes to."
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_beforeActors",
|
|
78
|
+
"range": {
|
|
79
|
+
"@type": "ParameterRangeUnion",
|
|
80
|
+
"parameterRangeElements": [
|
|
81
|
+
{
|
|
82
|
+
"@type": "ParameterRangeArray",
|
|
83
|
+
"parameterRangeValue": {
|
|
84
|
+
"@type": "ParameterRangeGenericComponent",
|
|
85
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
86
|
+
"genericTypeInstances": [
|
|
87
|
+
{
|
|
88
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
89
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
93
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
97
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"@type": "ParameterRangeUndefined"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"comment": "Actor that must be registered in the bus before this actor."
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"memberFields": [
|
|
111
|
+
{
|
|
112
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_useAskIfSupported",
|
|
113
|
+
"memberFieldName": "useAskIfSupported"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_constructor",
|
|
117
|
+
"memberFieldName": "constructor"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_test",
|
|
121
|
+
"memberFieldName": "test"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_run",
|
|
125
|
+
"memberFieldName": "run"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_collectMultiOperationInputs",
|
|
129
|
+
"memberFieldName": "collectMultiOperationInputs"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_mapMultiOperation",
|
|
133
|
+
"memberFieldName": "mapMultiOperation"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations__member_hasSourceResults",
|
|
137
|
+
"memberFieldName": "hasSourceResults"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"constructorArguments": [
|
|
141
|
+
{
|
|
142
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args__constructorArgument",
|
|
143
|
+
"fields": [
|
|
144
|
+
{
|
|
145
|
+
"keyRaw": "useAskIfSupported",
|
|
146
|
+
"value": {
|
|
147
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_useAskIfSupported"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"keyRaw": "name",
|
|
152
|
+
"value": {
|
|
153
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_name"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"keyRaw": "bus",
|
|
158
|
+
"value": {
|
|
159
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_bus"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"keyRaw": "beforeActors",
|
|
164
|
+
"value": {
|
|
165
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_beforeActors"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs",
|
|
174
|
+
"@type": "AbstractClass",
|
|
175
|
+
"requireElement": "IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs",
|
|
176
|
+
"parameters": [],
|
|
177
|
+
"memberFields": [
|
|
178
|
+
{
|
|
179
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs__member_useAskIfSupported",
|
|
180
|
+
"memberFieldName": "useAskIfSupported"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"constructorArguments": []
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-prune-empty-source-operations/^3.0.0/components/context.jsonld"
|
|
4
|
+
],
|
|
5
|
+
"@id": "npmd:@comunica/actor-optimize-query-operation-prune-empty-source-operations",
|
|
6
|
+
"@type": "Module",
|
|
7
|
+
"requireName": "@comunica/actor-optimize-query-operation-prune-empty-source-operations",
|
|
8
|
+
"import": [
|
|
9
|
+
"caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
4
|
+
{
|
|
5
|
+
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
+
"caoqopeso": "npmd:@comunica/actor-optimize-query-operation-prune-empty-source-operations/^3.0.0/",
|
|
7
|
+
"ActorOptimizeQueryOperationPruneEmptySourceOperations": {
|
|
8
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations",
|
|
9
|
+
"@prefix": true,
|
|
10
|
+
"@context": {
|
|
11
|
+
"args_useAskIfSupported": {
|
|
12
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_useAskIfSupported"
|
|
13
|
+
},
|
|
14
|
+
"args_name": {
|
|
15
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_name"
|
|
16
|
+
},
|
|
17
|
+
"args_bus": {
|
|
18
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_bus"
|
|
19
|
+
},
|
|
20
|
+
"args_beforeActors": {
|
|
21
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_beforeActors",
|
|
22
|
+
"@container": "@list"
|
|
23
|
+
},
|
|
24
|
+
"useAskIfSupported": {
|
|
25
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_useAskIfSupported"
|
|
26
|
+
},
|
|
27
|
+
"name": {
|
|
28
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_name"
|
|
29
|
+
},
|
|
30
|
+
"bus": {
|
|
31
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_bus"
|
|
32
|
+
},
|
|
33
|
+
"beforeActors": {
|
|
34
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#ActorOptimizeQueryOperationPruneEmptySourceOperations_args_beforeActors",
|
|
35
|
+
"@container": "@list"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs": {
|
|
40
|
+
"@id": "caoqopeso:components/ActorOptimizeQueryOperationPruneEmptySourceOperations.jsonld#IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs",
|
|
41
|
+
"@prefix": true,
|
|
42
|
+
"@context": {}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IActionOptimizeQueryOperation, IActorOptimizeQueryOperationOutput, IActorOptimizeQueryOperationArgs } from '@comunica/bus-optimize-query-operation';
|
|
2
|
+
import { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';
|
|
3
|
+
import type { IActorTest } from '@comunica/core';
|
|
4
|
+
import type { IActionContext, IQuerySourceWrapper } from '@comunica/types';
|
|
5
|
+
import { Algebra } from 'sparqlalgebrajs';
|
|
6
|
+
/**
|
|
7
|
+
* A comunica Prune Empty Source Operations Optimize Query Operation Actor.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ActorOptimizeQueryOperationPruneEmptySourceOperations extends ActorOptimizeQueryOperation {
|
|
10
|
+
private readonly useAskIfSupported;
|
|
11
|
+
constructor(args: IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs);
|
|
12
|
+
test(action: IActionOptimizeQueryOperation): Promise<IActorTest>;
|
|
13
|
+
run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput>;
|
|
14
|
+
protected collectMultiOperationInputs(inputs: Algebra.Operation[], collectedOperations: (Algebra.Pattern | Algebra.Link)[], inputType: (Algebra.Pattern | Algebra.Link)['type']): void;
|
|
15
|
+
protected mapMultiOperation<O extends Algebra.Union | Algebra.Alt>(operation: O, emptyOperations: Set<Algebra.Operation>, multiOperationFactory: (input: O['input']) => Algebra.Operation): {
|
|
16
|
+
result: Algebra.Operation;
|
|
17
|
+
recurse: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Check if the given query operation will produce at least one result in the given source.
|
|
21
|
+
* @param source A query source.
|
|
22
|
+
* @param input A query operation.
|
|
23
|
+
* @param context The query context.
|
|
24
|
+
*/
|
|
25
|
+
hasSourceResults(source: IQuerySourceWrapper, input: Algebra.Operation, context: IActionContext): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export interface IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs extends IActorOptimizeQueryOperationArgs {
|
|
28
|
+
/**
|
|
29
|
+
* If true, ASK queries will be sent to the source instead of COUNT queries to check emptiness for patterns.
|
|
30
|
+
* This will only be done for sources that accept ASK queries.
|
|
31
|
+
* @default {false}
|
|
32
|
+
*/
|
|
33
|
+
useAskIfSupported: boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActorOptimizeQueryOperationPruneEmptySourceOperations = void 0;
|
|
4
|
+
const bus_optimize_query_operation_1 = require("@comunica/bus-optimize-query-operation");
|
|
5
|
+
const bus_query_operation_1 = require("@comunica/bus-query-operation");
|
|
6
|
+
const rdf_data_factory_1 = require("rdf-data-factory");
|
|
7
|
+
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
8
|
+
const AF = new sparqlalgebrajs_1.Factory();
|
|
9
|
+
const DF = new rdf_data_factory_1.DataFactory();
|
|
10
|
+
/**
|
|
11
|
+
* A comunica Prune Empty Source Operations Optimize Query Operation Actor.
|
|
12
|
+
*/
|
|
13
|
+
class ActorOptimizeQueryOperationPruneEmptySourceOperations extends bus_optimize_query_operation_1.ActorOptimizeQueryOperation {
|
|
14
|
+
constructor(args) {
|
|
15
|
+
super(args);
|
|
16
|
+
}
|
|
17
|
+
async test(action) {
|
|
18
|
+
if (bus_query_operation_1.ActorQueryOperation.getOperationSource(action.operation)) {
|
|
19
|
+
throw new Error(`Actor ${this.name} does not work with top-level operation sources.`);
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
async run(action) {
|
|
24
|
+
let operation = action.operation;
|
|
25
|
+
// Collect all operations with source types
|
|
26
|
+
// Only consider unions of patterns or alts of links, since these are created during exhaustive source assignment.
|
|
27
|
+
const collectedOperations = [];
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias,consistent-this
|
|
29
|
+
const self = this;
|
|
30
|
+
sparqlalgebrajs_1.Util.recurseOperation(operation, {
|
|
31
|
+
[sparqlalgebrajs_1.Algebra.types.UNION](subOperation) {
|
|
32
|
+
self.collectMultiOperationInputs(subOperation.input, collectedOperations, sparqlalgebrajs_1.Algebra.types.PATTERN);
|
|
33
|
+
return true;
|
|
34
|
+
},
|
|
35
|
+
[sparqlalgebrajs_1.Algebra.types.ALT](subOperation) {
|
|
36
|
+
self.collectMultiOperationInputs(subOperation.input, collectedOperations, sparqlalgebrajs_1.Algebra.types.LINK);
|
|
37
|
+
return false;
|
|
38
|
+
},
|
|
39
|
+
[sparqlalgebrajs_1.Algebra.types.SERVICE](subOperation) {
|
|
40
|
+
return false;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
// Determine in an async manner whether or not these sources return non-empty results
|
|
44
|
+
const emptyOperations = new Set();
|
|
45
|
+
await Promise.all(collectedOperations.map(async (collectedOperation) => {
|
|
46
|
+
const checkOperation = collectedOperation.type === 'link' ?
|
|
47
|
+
AF.createPattern(DF.variable('?s'), collectedOperation.iri, DF.variable('?o')) :
|
|
48
|
+
collectedOperation;
|
|
49
|
+
if (!await this.hasSourceResults(bus_query_operation_1.ActorQueryOperation.getOperationSource(collectedOperation), checkOperation, action.context)) {
|
|
50
|
+
emptyOperations.add(collectedOperation);
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
// Only perform next mapping if we have at least one empty operation
|
|
54
|
+
this.logDebug(action.context, `Pruning ${emptyOperations.size} source-specific operations`);
|
|
55
|
+
if (emptyOperations.size > 0) {
|
|
56
|
+
// Rewrite operations by removing the empty children
|
|
57
|
+
operation = sparqlalgebrajs_1.Util.mapOperation(operation, {
|
|
58
|
+
[sparqlalgebrajs_1.Algebra.types.UNION](subOperation, factory) {
|
|
59
|
+
return self.mapMultiOperation(subOperation, emptyOperations, children => factory.createUnion(children));
|
|
60
|
+
},
|
|
61
|
+
[sparqlalgebrajs_1.Algebra.types.ALT](subOperation, factory) {
|
|
62
|
+
return self.mapMultiOperation(subOperation, emptyOperations, children => factory.createAlt(children));
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return { operation, context: action.context };
|
|
67
|
+
}
|
|
68
|
+
collectMultiOperationInputs(inputs, collectedOperations, inputType) {
|
|
69
|
+
for (const input of inputs) {
|
|
70
|
+
if (bus_query_operation_1.ActorQueryOperation.getOperationSource(input) && input.type === inputType) {
|
|
71
|
+
collectedOperations.push(input);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
mapMultiOperation(operation, emptyOperations, multiOperationFactory) {
|
|
76
|
+
// Determine which operations return non-empty results
|
|
77
|
+
const nonEmptyInputs = operation.input.filter(input => !emptyOperations.has(input));
|
|
78
|
+
// Remove empty operations
|
|
79
|
+
if (nonEmptyInputs.length === operation.input.length) {
|
|
80
|
+
return { result: operation, recurse: true };
|
|
81
|
+
}
|
|
82
|
+
if (nonEmptyInputs.length === 0) {
|
|
83
|
+
return { result: multiOperationFactory([]), recurse: false };
|
|
84
|
+
}
|
|
85
|
+
if (nonEmptyInputs.length === 1) {
|
|
86
|
+
return { result: nonEmptyInputs[0], recurse: true };
|
|
87
|
+
}
|
|
88
|
+
return { result: multiOperationFactory(nonEmptyInputs), recurse: true };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Check if the given query operation will produce at least one result in the given source.
|
|
92
|
+
* @param source A query source.
|
|
93
|
+
* @param input A query operation.
|
|
94
|
+
* @param context The query context.
|
|
95
|
+
*/
|
|
96
|
+
async hasSourceResults(source, input, context) {
|
|
97
|
+
// Send an ASK query
|
|
98
|
+
if (this.useAskIfSupported) {
|
|
99
|
+
const askOperation = AF.createAsk(input);
|
|
100
|
+
if (bus_query_operation_1.ActorQueryOperation
|
|
101
|
+
.doesShapeAcceptOperation(await source.source.getSelectorShape(context), askOperation)) {
|
|
102
|
+
return source.source.queryBoolean(askOperation, context);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Send the operation as-is and check the response cardinality
|
|
106
|
+
const bindingsStream = source.source.queryBindings(input, context);
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
bindingsStream.on('error', reject);
|
|
109
|
+
bindingsStream.getProperty('metadata', (metadata) => {
|
|
110
|
+
bindingsStream.destroy();
|
|
111
|
+
resolve(metadata.cardinality.value > 0);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.ActorOptimizeQueryOperationPruneEmptySourceOperations = ActorOptimizeQueryOperationPruneEmptySourceOperations;
|
|
117
|
+
//# sourceMappingURL=ActorOptimizeQueryOperationPruneEmptySourceOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActorOptimizeQueryOperationPruneEmptySourceOperations.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationPruneEmptySourceOperations.ts"],"names":[],"mappings":";;;AAEA,yFAAqF;AACrF,uEAAoE;AAGpE,uDAA+C;AAC/C,qDAAyD;AAEzD,MAAM,EAAE,GAAG,IAAI,yBAAO,EAAE,CAAC;AACzB,MAAM,EAAE,GAAG,IAAI,8BAAW,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAa,qDAAsD,SAAQ,0DAA2B;IAGpG,YAAmB,IAAgE;QACjF,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAAqC;QACrD,IAAI,yCAAmB,CAAC,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC5D,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,kDAAkD,CAAC,CAAC;SACvF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAqC;QACpD,IAAI,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAEjC,2CAA2C;QAC3C,kHAAkH;QAClH,MAAM,mBAAmB,GAAuC,EAAE,CAAC;QACnE,4EAA4E;QAC5E,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,sBAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE;YAC/B,CAAC,yBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,YAAY;gBAChC,IAAI,CAAC,2BAA2B,CAAC,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,yBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjG,OAAO,I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IACL,CAAC;CACF;AAtID,sHAsIC","sourcesContent":["import type { IActionOptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput, IActorOptimizeQueryOperationArgs } from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport { ActorQueryOperation } from '@comunica/bus-query-operation';\nimport type { IActorTest } from '@comunica/core';\nimport type { IActionContext, IQuerySourceWrapper, MetadataBindings } from '@comunica/types';\nimport { DataFactory } from 'rdf-data-factory';\nimport { Algebra, Factory, Util } from 'sparqlalgebrajs';\n\nconst AF = new Factory();\nconst DF = new DataFactory();\n\n/**\n * A comunica Prune Empty Source Operations Optimize Query Operation Actor.\n */\nexport class ActorOptimizeQueryOperationPruneEmptySourceOperations extends ActorOptimizeQueryOperation {\n private readonly useAskIfSupported: boolean;\n\n public constructor(args: IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs) {\n super(args);\n }\n\n public async test(action: IActionOptimizeQueryOperation): Promise<IActorTest> {\n if (ActorQueryOperation.getOperationSource(action.operation)) {\n throw new Error(`Actor ${this.name} does not work with top-level operation sources.`);\n }\n return true;\n }\n\n public async run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput> {\n let operation = action.operation;\n\n // Collect all operations with source types\n // Only consider unions of patterns or alts of links, since these are created during exhaustive source assignment.\n const collectedOperations: (Algebra.Pattern | Algebra.Link)[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias,consistent-this\n const self = this;\n Util.recurseOperation(operation, {\n [Algebra.types.UNION](subOperation) {\n self.collectMultiOperationInputs(subOperation.input, collectedOperations, Algebra.types.PATTERN);\n return true;\n },\n [Algebra.types.ALT](subOperation) {\n self.collectMultiOperationInputs(subOperation.input, collectedOperations, Algebra.types.LINK);\n return false;\n },\n [Algebra.types.SERVICE](subOperation) {\n return false;\n },\n });\n\n // Determine in an async manner whether or not these sources return non-empty results\n const emptyOperations: Set<Algebra.Operation> = new Set();\n await Promise.all(collectedOperations.map(async collectedOperation => {\n const checkOperation = collectedOperation.type === 'link' ?\n AF.createPattern(DF.variable('?s'), collectedOperation.iri, DF.variable('?o')) :\n collectedOperation;\n if (!await this.hasSourceResults(\n ActorQueryOperation.getOperationSource(collectedOperation)!,\n checkOperation,\n action.context,\n )) {\n emptyOperations.add(collectedOperation);\n }\n }));\n\n // Only perform next mapping if we have at least one empty operation\n this.logDebug(action.context, `Pruning ${emptyOperations.size} source-specific operations`);\n if (emptyOperations.size > 0) {\n // Rewrite operations by removing the empty children\n operation = Util.mapOperation(operation, {\n [Algebra.types.UNION](subOperation, factory) {\n return self.mapMultiOperation(subOperation, emptyOperations, children => factory.createUnion(children));\n },\n [Algebra.types.ALT](subOperation, factory) {\n return self.mapMultiOperation(subOperation, emptyOperations, children => factory.createAlt(children));\n },\n });\n }\n\n return { operation, context: action.context };\n }\n\n protected collectMultiOperationInputs(\n inputs: Algebra.Operation[],\n collectedOperations: (Algebra.Pattern | Algebra.Link)[],\n inputType: (Algebra.Pattern | Algebra.Link)['type'],\n ): void {\n for (const input of inputs) {\n if (ActorQueryOperation.getOperationSource(input) && input.type === inputType) {\n collectedOperations.push(input);\n }\n }\n }\n\n protected mapMultiOperation<O extends Algebra.Union | Algebra.Alt>(\n operation: O,\n emptyOperations: Set<Algebra.Operation>,\n multiOperationFactory: (input: O['input']) => Algebra.Operation,\n ): {\n result: Algebra.Operation;\n recurse: boolean;\n } {\n // Determine which operations return non-empty results\n const nonEmptyInputs = operation.input.filter(input => !emptyOperations.has(input));\n\n // Remove empty operations\n if (nonEmptyInputs.length === operation.input.length) {\n return { result: operation, recurse: true };\n }\n if (nonEmptyInputs.length === 0) {\n return { result: multiOperationFactory([]), recurse: false };\n }\n if (nonEmptyInputs.length === 1) {\n return { result: nonEmptyInputs[0], recurse: true };\n }\n return { result: multiOperationFactory(nonEmptyInputs), recurse: true };\n }\n\n /**\n * Check if the given query operation will produce at least one result in the given source.\n * @param source A query source.\n * @param input A query operation.\n * @param context The query context.\n */\n public async hasSourceResults(\n source: IQuerySourceWrapper,\n input: Algebra.Operation,\n context: IActionContext,\n ): Promise<boolean> {\n // Send an ASK query\n if (this.useAskIfSupported) {\n const askOperation = AF.createAsk(input);\n if (ActorQueryOperation\n .doesShapeAcceptOperation(await source.source.getSelectorShape(context), askOperation)) {\n return source.source.queryBoolean(askOperation, context);\n }\n }\n\n // Send the operation as-is and check the response cardinality\n const bindingsStream = source.source.queryBindings(input, context);\n return new Promise((resolve, reject) => {\n bindingsStream.on('error', reject);\n bindingsStream.getProperty('metadata', (metadata: MetadataBindings) => {\n bindingsStream.destroy();\n resolve(metadata.cardinality.value > 0);\n });\n });\n }\n}\n\nexport interface IActorOptimizeQueryOperationPruneEmptySourceOperationsArgs extends IActorOptimizeQueryOperationArgs {\n /**\n * If true, ASK queries will be sent to the source instead of COUNT queries to check emptiness for patterns.\n * This will only be done for sources that accept ASK queries.\n * @default {false}\n */\n useAskIfSupported: boolean;\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActorOptimizeQueryOperationPruneEmptySourceOperations';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ActorOptimizeQueryOperationPruneEmptySourceOperations"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0FAAwE","sourcesContent":["export * from './ActorOptimizeQueryOperationPruneEmptySourceOperations';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/actor-optimize-query-operation-prune-empty-source-operations",
|
|
3
|
+
"version": "3.0.1-alpha.43.0",
|
|
4
|
+
"description": "A prune-empty-source-operations optimize-query-operation actor",
|
|
5
|
+
"lsd:module": true,
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"typings": "lib/index",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/comunica/comunica.git",
|
|
11
|
+
"directory": "packages/actor-optimize-query-operation-prune-empty-source-operations"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"keywords": [
|
|
18
|
+
"comunica",
|
|
19
|
+
"actor",
|
|
20
|
+
"optimize-query-operation",
|
|
21
|
+
"prune-empty-source-operations"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/comunica/comunica/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://comunica.dev/",
|
|
28
|
+
"files": [
|
|
29
|
+
"components",
|
|
30
|
+
"lib/**/*.d.ts",
|
|
31
|
+
"lib/**/*.js",
|
|
32
|
+
"lib/**/*.js.map"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@comunica/bus-optimize-query-operation": "3.0.1-alpha.43.0",
|
|
36
|
+
"@comunica/bus-query-operation": "3.0.1-alpha.43.0",
|
|
37
|
+
"@comunica/core": "3.0.1-alpha.43.0",
|
|
38
|
+
"@comunica/types": "3.0.1-alpha.43.0",
|
|
39
|
+
"rdf-data-factory": "^1.1.2",
|
|
40
|
+
"sparqlalgebrajs": "^4.3.3"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "npm run build:ts && npm run build:components",
|
|
44
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
45
|
+
"build:components": "componentsjs-generator"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "d11e44cf07d4699f9d2c51d5851b5ed443de1997"
|
|
48
|
+
}
|