@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown 4.4.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 +37 -0
- package/components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld +181 -0
- package/components/components.jsonld +11 -0
- package/components/context.jsonld +41 -0
- package/lib/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.d.ts +18 -0
- package/lib/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js +67 -0
- package/lib/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.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 +53 -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,37 @@
|
|
|
1
|
+
# Comunica LeftJoin Expression Pushdown Optimize Query Operation Actor
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown)
|
|
4
|
+
|
|
5
|
+
An [Optimize Query Operation](https://github.com/comunica/comunica/tree/master/packages/bus-optimize-query-operation) actor
|
|
6
|
+
that pushes down expressions in left joins into either the left-hand or right-hand operator
|
|
7
|
+
if it overlaps with just one of them.
|
|
8
|
+
|
|
9
|
+
This module is part of the [Comunica framework](https://github.com/comunica/comunica),
|
|
10
|
+
and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
|
|
11
|
+
|
|
12
|
+
[Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
$ yarn add @comunica/actor-optimize-query-operation-leftjoin-expression-pushdown
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Configure
|
|
21
|
+
|
|
22
|
+
After installing, this package can be added to your engine's configuration as follows:
|
|
23
|
+
```text
|
|
24
|
+
{
|
|
25
|
+
"@context": [
|
|
26
|
+
...
|
|
27
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^1.0.0/components/context.jsonld"
|
|
28
|
+
],
|
|
29
|
+
"actors": [
|
|
30
|
+
...
|
|
31
|
+
{
|
|
32
|
+
"@id": "urn:comunica:default:optimize-query-operation/actors#leftjoin-expression-pushdown",
|
|
33
|
+
"@type": "ActorOptimizeQueryOperationLeftjoinExpressionPushdown"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
```
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^4.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^4.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^4.0.0/components/context.jsonld"
|
|
6
|
+
],
|
|
7
|
+
"@id": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown",
|
|
11
|
+
"@type": "Class",
|
|
12
|
+
"requireElement": "ActorOptimizeQueryOperationLeftjoinExpressionPushdown",
|
|
13
|
+
"extends": [
|
|
14
|
+
"cboqo:components/ActorOptimizeQueryOperation.jsonld#ActorOptimizeQueryOperation"
|
|
15
|
+
],
|
|
16
|
+
"comment": "A comunica LeftJoin Expression Pushdown Optimize Query Operation Actor.",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_name",
|
|
20
|
+
"range": "xsd:string",
|
|
21
|
+
"default": {
|
|
22
|
+
"@id": "rdf:subject"
|
|
23
|
+
},
|
|
24
|
+
"comment": "The name for this actor."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_bus",
|
|
28
|
+
"range": {
|
|
29
|
+
"@type": "ParameterRangeGenericComponent",
|
|
30
|
+
"component": "cc:components/Bus.jsonld#Bus",
|
|
31
|
+
"genericTypeInstances": [
|
|
32
|
+
{
|
|
33
|
+
"@type": "ParameterRangeGenericComponent",
|
|
34
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
35
|
+
"genericTypeInstances": [
|
|
36
|
+
{
|
|
37
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
38
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
42
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
46
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
50
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
64
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
68
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"default": {
|
|
73
|
+
"@id": "cboqo:components/ActorOptimizeQueryOperation.jsonld#ActorOptimizeQueryOperation_default_bus",
|
|
74
|
+
"@type": "cc:components/Bus.jsonld#Bus"
|
|
75
|
+
},
|
|
76
|
+
"comment": "The bus this actor subscribes to."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_busFailMessage",
|
|
80
|
+
"range": {
|
|
81
|
+
"@type": "ParameterRangeUnion",
|
|
82
|
+
"parameterRangeElements": [
|
|
83
|
+
"xsd:string",
|
|
84
|
+
{
|
|
85
|
+
"@type": "ParameterRangeUndefined"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"default": "Query optimization failed: none of the configured actors were able to optimize",
|
|
90
|
+
"comment": "The message that will be configured in the bus for reporting failures. This message may be a template string that contains references to the executed `action`. For example, the following templated string is allowed: \"RDF dereferencing failed: no actors could handle ${action.handle.mediaType}\""
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_beforeActors",
|
|
94
|
+
"range": {
|
|
95
|
+
"@type": "ParameterRangeUnion",
|
|
96
|
+
"parameterRangeElements": [
|
|
97
|
+
{
|
|
98
|
+
"@type": "ParameterRangeArray",
|
|
99
|
+
"parameterRangeValue": {
|
|
100
|
+
"@type": "ParameterRangeGenericComponent",
|
|
101
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
102
|
+
"genericTypeInstances": [
|
|
103
|
+
{
|
|
104
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
105
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
109
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
113
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
117
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"@type": "ParameterRangeUndefined"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
"comment": "Actor that must be registered in the bus before this actor."
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"memberFields": [
|
|
131
|
+
{
|
|
132
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown__member_constructor",
|
|
133
|
+
"memberFieldName": "constructor"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown__member_test",
|
|
137
|
+
"memberFieldName": "test"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown__member_run",
|
|
141
|
+
"memberFieldName": "run"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown__member_variablesIntersect",
|
|
145
|
+
"memberFieldName": "variablesIntersect"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"constructorArguments": [
|
|
149
|
+
{
|
|
150
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args__constructorArgument",
|
|
151
|
+
"fields": [
|
|
152
|
+
{
|
|
153
|
+
"keyRaw": "name",
|
|
154
|
+
"value": {
|
|
155
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_name"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"keyRaw": "bus",
|
|
160
|
+
"value": {
|
|
161
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_bus"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"keyRaw": "busFailMessage",
|
|
166
|
+
"value": {
|
|
167
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_busFailMessage"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"keyRaw": "beforeActors",
|
|
172
|
+
"value": {
|
|
173
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_beforeActors"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^4.0.0/components/context.jsonld"
|
|
4
|
+
],
|
|
5
|
+
"@id": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
6
|
+
"@type": "Module",
|
|
7
|
+
"requireName": "@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
8
|
+
"import": [
|
|
9
|
+
"caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
|
|
4
|
+
{
|
|
5
|
+
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
+
"caoqolep": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^4.0.0/",
|
|
7
|
+
"ActorOptimizeQueryOperationLeftjoinExpressionPushdown": {
|
|
8
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown",
|
|
9
|
+
"@prefix": true,
|
|
10
|
+
"@context": {
|
|
11
|
+
"args_name": {
|
|
12
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_name"
|
|
13
|
+
},
|
|
14
|
+
"args_bus": {
|
|
15
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_bus"
|
|
16
|
+
},
|
|
17
|
+
"args_busFailMessage": {
|
|
18
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_busFailMessage"
|
|
19
|
+
},
|
|
20
|
+
"args_beforeActors": {
|
|
21
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_beforeActors",
|
|
22
|
+
"@container": "@list"
|
|
23
|
+
},
|
|
24
|
+
"name": {
|
|
25
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_name"
|
|
26
|
+
},
|
|
27
|
+
"bus": {
|
|
28
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_bus"
|
|
29
|
+
},
|
|
30
|
+
"busFailMessage": {
|
|
31
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_busFailMessage"
|
|
32
|
+
},
|
|
33
|
+
"beforeActors": {
|
|
34
|
+
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown_args_beforeActors",
|
|
35
|
+
"@container": "@list"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IActionOptimizeQueryOperation, IActorOptimizeQueryOperationOutput, IActorOptimizeQueryOperationArgs } from '@comunica/bus-optimize-query-operation';
|
|
2
|
+
import { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';
|
|
3
|
+
import type { TestResult, IActorTest } from '@comunica/core';
|
|
4
|
+
import type * as RDF from '@rdfjs/types';
|
|
5
|
+
/**
|
|
6
|
+
* A comunica LeftJoin Expression Pushdown Optimize Query Operation Actor.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ActorOptimizeQueryOperationLeftjoinExpressionPushdown extends ActorOptimizeQueryOperation {
|
|
9
|
+
constructor(args: IActorOptimizeQueryOperationArgs);
|
|
10
|
+
test(_action: IActionOptimizeQueryOperation): Promise<TestResult<IActorTest>>;
|
|
11
|
+
run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if there is an overlap between the two given lists of variables.
|
|
14
|
+
* @param varsA A list of variables.
|
|
15
|
+
* @param varsB A list of variables.
|
|
16
|
+
*/
|
|
17
|
+
variablesIntersect(varsA: RDF.Variable[], varsB: RDF.Variable[]): boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActorOptimizeQueryOperationLeftjoinExpressionPushdown = void 0;
|
|
4
|
+
const bus_optimize_query_operation_1 = require("@comunica/bus-optimize-query-operation");
|
|
5
|
+
const context_entries_1 = require("@comunica/context-entries");
|
|
6
|
+
const core_1 = require("@comunica/core");
|
|
7
|
+
const utils_query_operation_1 = require("@comunica/utils-query-operation");
|
|
8
|
+
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
9
|
+
/**
|
|
10
|
+
* A comunica LeftJoin Expression Pushdown Optimize Query Operation Actor.
|
|
11
|
+
*/
|
|
12
|
+
class ActorOptimizeQueryOperationLeftjoinExpressionPushdown extends bus_optimize_query_operation_1.ActorOptimizeQueryOperation {
|
|
13
|
+
constructor(args) {
|
|
14
|
+
super(args);
|
|
15
|
+
}
|
|
16
|
+
async test(_action) {
|
|
17
|
+
return (0, core_1.passTestVoid)();
|
|
18
|
+
}
|
|
19
|
+
async run(action) {
|
|
20
|
+
const dataFactory = action.context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
21
|
+
const algebraFactory = new sparqlalgebrajs_1.Factory(dataFactory);
|
|
22
|
+
let operation = action.operation;
|
|
23
|
+
// eslint-disable-next-line ts/no-this-alias
|
|
24
|
+
const self = this;
|
|
25
|
+
operation = sparqlalgebrajs_1.Util.mapOperation(operation, {
|
|
26
|
+
leftjoin(op, factory) {
|
|
27
|
+
// Try to push the expression to either the left or right if it exclusively overlaps with just one of them.
|
|
28
|
+
if (op.expression) {
|
|
29
|
+
const variablesExpression = (0, utils_query_operation_1.getExpressionVariables)(op.expression);
|
|
30
|
+
const variablesLeft = sparqlalgebrajs_1.Util.inScopeVariables(op.input[0]);
|
|
31
|
+
const variablesRight = sparqlalgebrajs_1.Util.inScopeVariables(op.input[1]);
|
|
32
|
+
const intersectLeft = self.variablesIntersect(variablesExpression, variablesLeft);
|
|
33
|
+
const intersectRight = self.variablesIntersect(variablesExpression, variablesRight);
|
|
34
|
+
if (intersectLeft && !intersectRight) {
|
|
35
|
+
self.logDebug(action.context, `Pushed down optional expression to left-hand operator`);
|
|
36
|
+
return {
|
|
37
|
+
recurse: true,
|
|
38
|
+
result: factory.createLeftJoin(factory.createFilter(op.input[0], op.expression), op.input[1]),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (!intersectLeft && intersectRight) {
|
|
42
|
+
self.logDebug(action.context, `Pushed down optional expression to right-hand operator`);
|
|
43
|
+
return {
|
|
44
|
+
recurse: true,
|
|
45
|
+
result: factory.createLeftJoin(op.input[0], factory.createFilter(op.input[1], op.expression)),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
recurse: true,
|
|
51
|
+
result: op,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
}, algebraFactory);
|
|
55
|
+
return { operation, context: action.context };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if there is an overlap between the two given lists of variables.
|
|
59
|
+
* @param varsA A list of variables.
|
|
60
|
+
* @param varsB A list of variables.
|
|
61
|
+
*/
|
|
62
|
+
variablesIntersect(varsA, varsB) {
|
|
63
|
+
return varsA.some(varA => varsB.some(varB => varA.equals(varB)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ActorOptimizeQueryOperationLeftjoinExpressionPushdown = ActorOptimizeQueryOperationLeftjoinExpressionPushdown;
|
|
67
|
+
//# sourceMappingURL=ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationLeftjoinExpressionPushdown.ts"],"names":[],"mappings":"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","sourcesContent":["import type {\n IActionOptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput,\n IActorOptimizeQueryOperationArgs,\n} from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport { KeysInitQuery } from '@comunica/context-entries';\nimport type { TestResult, IActorTest } from '@comunica/core';\nimport { passTestVoid } from '@comunica/core';\nimport type { ComunicaDataFactory } from '@comunica/types';\nimport { getExpressionVariables } from '@comunica/utils-query-operation';\nimport type * as RDF from '@rdfjs/types';\nimport type { Algebra } from 'sparqlalgebrajs';\nimport { Factory, Util } from 'sparqlalgebrajs';\n\n/**\n * A comunica LeftJoin Expression Pushdown Optimize Query Operation Actor.\n */\nexport class ActorOptimizeQueryOperationLeftjoinExpressionPushdown extends ActorOptimizeQueryOperation {\n public constructor(args: IActorOptimizeQueryOperationArgs) {\n super(args);\n }\n\n public async test(_action: IActionOptimizeQueryOperation): Promise<TestResult<IActorTest>> {\n return passTestVoid();\n }\n\n public async run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput> {\n const dataFactory: ComunicaDataFactory = action.context.getSafe(KeysInitQuery.dataFactory);\n const algebraFactory = new Factory(dataFactory);\n let operation: Algebra.Operation = action.operation;\n\n // eslint-disable-next-line ts/no-this-alias\n const self = this;\n operation = Util.mapOperation(operation, {\n leftjoin(op: Algebra.LeftJoin, factory: Factory) {\n // Try to push the expression to either the left or right if it exclusively overlaps with just one of them.\n if (op.expression) {\n const variablesExpression = getExpressionVariables(op.expression);\n const variablesLeft = Util.inScopeVariables(op.input[0]);\n const variablesRight = Util.inScopeVariables(op.input[1]);\n const intersectLeft = self.variablesIntersect(variablesExpression, variablesLeft);\n const intersectRight = self.variablesIntersect(variablesExpression, variablesRight);\n if (intersectLeft && !intersectRight) {\n self.logDebug(action.context, `Pushed down optional expression to left-hand operator`);\n return {\n recurse: true,\n result: factory.createLeftJoin(\n factory.createFilter(op.input[0], op.expression),\n op.input[1],\n ),\n };\n }\n if (!intersectLeft && intersectRight) {\n self.logDebug(action.context, `Pushed down optional expression to right-hand operator`);\n return {\n recurse: true,\n result: factory.createLeftJoin(\n op.input[0],\n factory.createFilter(op.input[1], op.expression),\n ),\n };\n }\n }\n\n return {\n recurse: true,\n result: op,\n };\n },\n }, algebraFactory);\n\n return { operation, context: action.context };\n }\n\n /**\n * Check if there is an overlap between the two given lists of variables.\n * @param varsA A list of variables.\n * @param varsB A list of variables.\n */\n public variablesIntersect(varsA: RDF.Variable[], varsB: RDF.Variable[]): boolean {\n return varsA.some(varA => varsB.some(varB => varA.equals(varB)));\n }\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActorOptimizeQueryOperationLeftjoinExpressionPushdown';
|
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("./ActorOptimizeQueryOperationLeftjoinExpressionPushdown"), 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 './ActorOptimizeQueryOperationLeftjoinExpressionPushdown';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
3
|
+
"version": "4.4.0",
|
|
4
|
+
"description": "A leftjoin-expression-pushdown optimize-query-operation actor",
|
|
5
|
+
"lsd:module": true,
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"funding": {
|
|
8
|
+
"type": "opencollective",
|
|
9
|
+
"url": "https://opencollective.com/comunica-association"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://comunica.dev/",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/comunica/comunica.git",
|
|
15
|
+
"directory": "packages/actor-optimize-query-operation-leftjoin-expression-pushdown"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/comunica/comunica/issues"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"comunica",
|
|
22
|
+
"actor",
|
|
23
|
+
"optimize-query-operation",
|
|
24
|
+
"leftjoin-expression-pushdown"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "lib/index.js",
|
|
28
|
+
"typings": "lib/index",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"components",
|
|
34
|
+
"lib/**/*.d.ts",
|
|
35
|
+
"lib/**/*.js",
|
|
36
|
+
"lib/**/*.js.map"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "yarn run build:ts && yarn run build:components",
|
|
40
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
41
|
+
"build:components": "componentsjs-generator"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@comunica/bus-optimize-query-operation": "^4.4.0",
|
|
45
|
+
"@comunica/context-entries": "^4.4.0",
|
|
46
|
+
"@comunica/core": "^4.4.0",
|
|
47
|
+
"@comunica/types": "^4.4.0",
|
|
48
|
+
"@comunica/utils-query-operation": "^4.4.0",
|
|
49
|
+
"@rdfjs/types": "*",
|
|
50
|
+
"sparqlalgebrajs": "^4.3.8"
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "27acde56dfe0c1ff1162c1f46818ad752296ca88"
|
|
53
|
+
}
|