@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown 4.5.0 → 5.0.2
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/components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld +15 -15
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +1 -1
- package/lib/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js +24 -30
- package/lib/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^5.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^5.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
8
8
|
"components": [
|
|
@@ -35,37 +35,37 @@
|
|
|
35
35
|
"genericTypeInstances": [
|
|
36
36
|
{
|
|
37
37
|
"@type": "ParameterRangeGenericTypeReference",
|
|
38
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
38
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"@type": "ParameterRangeGenericTypeReference",
|
|
42
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
42
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"@type": "ParameterRangeGenericTypeReference",
|
|
46
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
46
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"@type": "ParameterRangeGenericTypeReference",
|
|
50
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
50
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
51
51
|
}
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"@type": "ParameterRangeGenericTypeReference",
|
|
60
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"@type": "ParameterRangeGenericTypeReference",
|
|
64
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
64
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"@type": "ParameterRangeGenericTypeReference",
|
|
68
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
68
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
69
69
|
}
|
|
70
70
|
]
|
|
71
71
|
},
|
|
@@ -102,19 +102,19 @@
|
|
|
102
102
|
"genericTypeInstances": [
|
|
103
103
|
{
|
|
104
104
|
"@type": "ParameterRangeGenericTypeReference",
|
|
105
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
105
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"@type": "ParameterRangeGenericTypeReference",
|
|
109
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
109
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
"@type": "ParameterRangeGenericTypeReference",
|
|
113
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
113
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"@type": "ParameterRangeGenericTypeReference",
|
|
117
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
117
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^5.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
6
6
|
"@type": "Module",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
-
"caoqolep": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^
|
|
6
|
+
"caoqolep": "npmd:@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown/^5.0.0/",
|
|
7
7
|
"ActorOptimizeQueryOperationLeftjoinExpressionPushdown": {
|
|
8
8
|
"@id": "caoqolep:components/ActorOptimizeQueryOperationLeftjoinExpressionPushdown.jsonld#ActorOptimizeQueryOperationLeftjoinExpressionPushdown",
|
|
9
9
|
"@prefix": true,
|
|
@@ -4,8 +4,8 @@ exports.ActorOptimizeQueryOperationLeftjoinExpressionPushdown = void 0;
|
|
|
4
4
|
const bus_optimize_query_operation_1 = require("@comunica/bus-optimize-query-operation");
|
|
5
5
|
const context_entries_1 = require("@comunica/context-entries");
|
|
6
6
|
const core_1 = require("@comunica/core");
|
|
7
|
+
const utils_algebra_1 = require("@comunica/utils-algebra");
|
|
7
8
|
const utils_query_operation_1 = require("@comunica/utils-query-operation");
|
|
8
|
-
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
9
9
|
/**
|
|
10
10
|
* A comunica LeftJoin Expression Pushdown Optimize Query Operation Actor.
|
|
11
11
|
*/
|
|
@@ -18,40 +18,34 @@ class ActorOptimizeQueryOperationLeftjoinExpressionPushdown extends bus_optimize
|
|
|
18
18
|
}
|
|
19
19
|
async run(action) {
|
|
20
20
|
const dataFactory = action.context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
21
|
-
const algebraFactory = new
|
|
21
|
+
const algebraFactory = new utils_algebra_1.AlgebraFactory(dataFactory);
|
|
22
22
|
let operation = action.operation;
|
|
23
23
|
// eslint-disable-next-line ts/no-this-alias
|
|
24
24
|
const self = this;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
self.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
25
|
+
// TODO: pass algebraFactory when traqula supports this.
|
|
26
|
+
operation = utils_algebra_1.algebraUtils.mapOperation(operation, {
|
|
27
|
+
[utils_algebra_1.Algebra.Types.LEFT_JOIN]: {
|
|
28
|
+
transform: (op) => {
|
|
29
|
+
// Try to push the expression to either the left or right if it exclusively overlaps with just one of them.
|
|
30
|
+
if (op.expression) {
|
|
31
|
+
const variablesExpression = (0, utils_query_operation_1.getExpressionVariables)(op.expression);
|
|
32
|
+
const variablesLeft = utils_algebra_1.algebraUtils.inScopeVariables(op.input[0]);
|
|
33
|
+
const variablesRight = utils_algebra_1.algebraUtils.inScopeVariables(op.input[1]);
|
|
34
|
+
const intersectLeft = self.variablesIntersect(variablesExpression, variablesLeft);
|
|
35
|
+
const intersectRight = self.variablesIntersect(variablesExpression, variablesRight);
|
|
36
|
+
if (intersectLeft && !intersectRight) {
|
|
37
|
+
self.logDebug(action.context, `Pushed down optional expression to left-hand operator`);
|
|
38
|
+
return algebraFactory.createLeftJoin(algebraFactory.createFilter(op.input[0], op.expression), op.input[1]);
|
|
39
|
+
}
|
|
40
|
+
if (!intersectLeft && intersectRight) {
|
|
41
|
+
self.logDebug(action.context, `Pushed down optional expression to right-hand operator`);
|
|
42
|
+
return algebraFactory.createLeftJoin(op.input[0], algebraFactory.createFilter(op.input[1], op.expression));
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
};
|
|
45
|
+
return op;
|
|
46
|
+
},
|
|
53
47
|
},
|
|
54
|
-
}
|
|
48
|
+
});
|
|
55
49
|
return { operation, context: action.context };
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationLeftjoinExpressionPushdown.ts"],"names":[],"mappings":";;;AAKA,yFAAqF;AACrF,+DAA0D;AAE1D,yCAA8C;AAE9C,2EAAyE;AAGzE
|
|
1
|
+
{"version":3,"file":"ActorOptimizeQueryOperationLeftjoinExpressionPushdown.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationLeftjoinExpressionPushdown.ts"],"names":[],"mappings":";;;AAKA,yFAAqF;AACrF,+DAA0D;AAE1D,yCAA8C;AAE9C,2DAAgF;AAChF,2EAAyE;AAGzE;;GAEG;AACH,MA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CAAC,MAAM,CAAC,OAAO,EAAE,uDAAuD,CAAC,CAAC;4BACvF,OAAO,cAAc,CAAC,cAAc,CAClC,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,EACvD,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CACZ,CAAC;wBACJ,CAAC;wBACD,IAAI,CAAC,aAAa,IAAI,cAAc,EAAE,CAAC;4BACrC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,wDAAwD,CAAC,CAAC;4BACxF,OAAO,cAAc,CAAC,cAAc,CAClC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EACX,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CACxD,CAAC;wBACJ,CAAC;oBACH,CAAC;oBAED,OAAO,EAAE,CAAC;gBACZ,CAAC;aACF;SACF,CAAC,CAAC;QAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,kBAAkB,CAAC,KAAqB,EAAE,KAAqB;QACpE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF;AA3DD,sHA2DC","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 { Algebra, AlgebraFactory, algebraUtils } from '@comunica/utils-algebra';\nimport { getExpressionVariables } from '@comunica/utils-query-operation';\nimport type * as RDF from '@rdfjs/types';\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 AlgebraFactory(dataFactory);\n let operation: Algebra.Operation = action.operation;\n\n // eslint-disable-next-line ts/no-this-alias\n const self = this;\n // TODO: pass algebraFactory when traqula supports this.\n operation = algebraUtils.mapOperation(operation, {\n [Algebra.Types.LEFT_JOIN]: {\n transform: (op: Algebra.LeftJoin) => {\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 = algebraUtils.inScopeVariables(op.input[0]);\n const variablesRight = algebraUtils.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 algebraFactory.createLeftJoin(\n algebraFactory.createFilter(op.input[0], op.expression),\n op.input[1],\n );\n }\n if (!intersectLeft && intersectRight) {\n self.logDebug(action.context, `Pushed down optional expression to right-hand operator`);\n return algebraFactory.createLeftJoin(\n op.input[0],\n algebraFactory.createFilter(op.input[1], op.expression),\n );\n }\n }\n\n return op;\n },\n },\n });\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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-optimize-query-operation-leftjoin-expression-pushdown",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "A leftjoin-expression-pushdown optimize-query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-optimize-query-operation": "^
|
|
45
|
-
"@comunica/context-entries": "^
|
|
46
|
-
"@comunica/core": "^
|
|
47
|
-
"@comunica/types": "^
|
|
48
|
-
"@comunica/utils-
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
44
|
+
"@comunica/bus-optimize-query-operation": "^5.0.2",
|
|
45
|
+
"@comunica/context-entries": "^5.0.2",
|
|
46
|
+
"@comunica/core": "^5.0.2",
|
|
47
|
+
"@comunica/types": "^5.0.0",
|
|
48
|
+
"@comunica/utils-algebra": "^5.0.0",
|
|
49
|
+
"@comunica/utils-query-operation": "^5.0.2",
|
|
50
|
+
"@rdfjs/types": "*"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "3b29f914010fd2fc56682a0ceff962ef6ff24f32"
|
|
53
53
|
}
|