@comunica/actor-query-operation-leftjoin 4.2.0 → 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/README.md +1 -3
- package/components/ActorQueryOperationLeftJoin.jsonld +0 -18
- package/components/context.jsonld +0 -6
- package/lib/ActorQueryOperationLeftJoin.d.ts +0 -3
- package/lib/ActorQueryOperationLeftJoin.js +22 -54
- package/lib/ActorQueryOperationLeftJoin.js.map +1 -1
- package/package.json +8 -10
package/README.md
CHANGED
|
@@ -32,8 +32,7 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
32
32
|
"@type": "ActorQueryOperationLeftJoin",
|
|
33
33
|
"mediatorQueryOperation": { "@id": "urn:comunica:default:query-operation/mediators#main" },
|
|
34
34
|
"mediatorJoin": { "@id": "urn:comunica:default:rdf-join/mediators#main" },
|
|
35
|
-
"mediatorMergeBindingsContext": { "@id": "urn:comunica:default:merge-bindings-context/mediators#main" }
|
|
36
|
-
"expressionEvaluatorFactory": { "@id": "urn:comunica:default:expression-evaluator/evaluators#main" }
|
|
35
|
+
"mediatorMergeBindingsContext": { "@id": "urn:comunica:default:merge-bindings-context/mediators#main" }
|
|
37
36
|
}
|
|
38
37
|
]
|
|
39
38
|
}
|
|
@@ -44,4 +43,3 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
44
43
|
* `mediatorQueryOperation`: A mediator over the [Query Operation bus](https://github.com/comunica/comunica/tree/master/packages/bus-query-operation).
|
|
45
44
|
* `mediatorJoin`: A mediator over the [RDF Join bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join).
|
|
46
45
|
* `mediatorMergeBindingsContext`: A mediator over the [Merge Bindings Context bus](https://github.com/comunica/comunica/tree/master/packages/bus-merge-bindings-context).
|
|
47
|
-
* `expressionEvaluatorFactory`: A factory to create an [Expression Evaluator](https://github.com/comunica/comunica/tree/master/packages/expression-evaluator);
|
|
@@ -26,10 +26,6 @@
|
|
|
26
26
|
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
27
27
|
"comment": "A mediator for joining Bindings streams"
|
|
28
28
|
},
|
|
29
|
-
{
|
|
30
|
-
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorExpressionEvaluatorFactory",
|
|
31
|
-
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
32
|
-
},
|
|
33
29
|
{
|
|
34
30
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorQueryOperation",
|
|
35
31
|
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
@@ -152,10 +148,6 @@
|
|
|
152
148
|
"memberFieldName": "mediatorJoin",
|
|
153
149
|
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
154
150
|
},
|
|
155
|
-
{
|
|
156
|
-
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin__member_mediatorExpressionEvaluatorFactory",
|
|
157
|
-
"memberFieldName": "mediatorExpressionEvaluatorFactory"
|
|
158
|
-
},
|
|
159
151
|
{
|
|
160
152
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin__member_constructor",
|
|
161
153
|
"memberFieldName": "constructor"
|
|
@@ -179,12 +171,6 @@
|
|
|
179
171
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorJoin"
|
|
180
172
|
}
|
|
181
173
|
},
|
|
182
|
-
{
|
|
183
|
-
"keyRaw": "mediatorExpressionEvaluatorFactory",
|
|
184
|
-
"value": {
|
|
185
|
-
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorExpressionEvaluatorFactory"
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
174
|
{
|
|
189
175
|
"keyRaw": "mediatorQueryOperation",
|
|
190
176
|
"value": {
|
|
@@ -231,10 +217,6 @@
|
|
|
231
217
|
{
|
|
232
218
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#IActorQueryOperationLeftJoinArgs__member_mediatorJoin",
|
|
233
219
|
"memberFieldName": "mediatorJoin"
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#IActorQueryOperationLeftJoinArgs__member_mediatorExpressionEvaluatorFactory",
|
|
237
|
-
"memberFieldName": "mediatorExpressionEvaluatorFactory"
|
|
238
220
|
}
|
|
239
221
|
],
|
|
240
222
|
"constructorArguments": []
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
"args_mediatorJoin": {
|
|
12
12
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorJoin"
|
|
13
13
|
},
|
|
14
|
-
"args_mediatorExpressionEvaluatorFactory": {
|
|
15
|
-
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorExpressionEvaluatorFactory"
|
|
16
|
-
},
|
|
17
14
|
"args_mediatorQueryOperation": {
|
|
18
15
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorQueryOperation"
|
|
19
16
|
},
|
|
@@ -33,9 +30,6 @@
|
|
|
33
30
|
"mediatorJoin": {
|
|
34
31
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorJoin"
|
|
35
32
|
},
|
|
36
|
-
"mediatorExpressionEvaluatorFactory": {
|
|
37
|
-
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorExpressionEvaluatorFactory"
|
|
38
|
-
},
|
|
39
33
|
"mediatorQueryOperation": {
|
|
40
34
|
"@id": "caqol:components/ActorQueryOperationLeftJoin.jsonld#ActorQueryOperationLeftJoin_args_mediatorQueryOperation"
|
|
41
35
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { MediatorExpressionEvaluatorFactory } from '@comunica/bus-expression-evaluator-factory';
|
|
2
1
|
import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';
|
|
3
2
|
import { ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';
|
|
4
3
|
import type { MediatorRdfJoin } from '@comunica/bus-rdf-join';
|
|
@@ -10,7 +9,6 @@ import type { Algebra } from 'sparqlalgebrajs';
|
|
|
10
9
|
*/
|
|
11
10
|
export declare class ActorQueryOperationLeftJoin extends ActorQueryOperationTypedMediated<Algebra.LeftJoin> {
|
|
12
11
|
readonly mediatorJoin: MediatorRdfJoin;
|
|
13
|
-
private readonly mediatorExpressionEvaluatorFactory;
|
|
14
12
|
constructor(args: IActorQueryOperationLeftJoinArgs);
|
|
15
13
|
testOperation(_operation: Algebra.LeftJoin, _context: IActionContext): Promise<TestResult<IActorTest>>;
|
|
16
14
|
runOperation(operationOriginal: Algebra.LeftJoin, context: IActionContext): Promise<IQueryOperationResult>;
|
|
@@ -20,5 +18,4 @@ export interface IActorQueryOperationLeftJoinArgs extends IActorQueryOperationTy
|
|
|
20
18
|
* A mediator for joining Bindings streams
|
|
21
19
|
*/
|
|
22
20
|
mediatorJoin: MediatorRdfJoin;
|
|
23
|
-
mediatorExpressionEvaluatorFactory: MediatorExpressionEvaluatorFactory;
|
|
24
21
|
}
|
|
@@ -2,75 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorQueryOperationLeftJoin = void 0;
|
|
4
4
|
const bus_query_operation_1 = require("@comunica/bus-query-operation");
|
|
5
|
+
const context_entries_1 = require("@comunica/context-entries");
|
|
5
6
|
const core_1 = require("@comunica/core");
|
|
6
|
-
const utils_bindings_factory_1 = require("@comunica/utils-bindings-factory");
|
|
7
|
-
const utils_expression_evaluator_1 = require("@comunica/utils-expression-evaluator");
|
|
8
7
|
const utils_query_operation_1 = require("@comunica/utils-query-operation");
|
|
8
|
+
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
9
9
|
/**
|
|
10
10
|
* A comunica LeftJoin Query Operation Actor.
|
|
11
11
|
*/
|
|
12
12
|
class ActorQueryOperationLeftJoin extends bus_query_operation_1.ActorQueryOperationTypedMediated {
|
|
13
13
|
constructor(args) {
|
|
14
14
|
super(args, 'leftjoin');
|
|
15
|
-
this.mediatorExpressionEvaluatorFactory = args.mediatorExpressionEvaluatorFactory;
|
|
16
15
|
}
|
|
17
16
|
async testOperation(_operation, _context) {
|
|
18
17
|
return (0, core_1.passTestVoid)();
|
|
19
18
|
}
|
|
20
19
|
async runOperation(operationOriginal, context) {
|
|
20
|
+
const dataFactory = context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
21
|
+
const algebraFactory = new sparqlalgebrajs_1.Factory(dataFactory);
|
|
21
22
|
// Delegate to join bus
|
|
22
23
|
const entries = (await Promise.all(operationOriginal.input
|
|
23
|
-
.map(async (subOperation) =>
|
|
24
|
-
output
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line ts/no-misused-promises
|
|
42
|
-
transform: async (bindings, done, push) => {
|
|
43
|
-
// If variables of the right-hand entry are missing, we skip expression evaluation
|
|
44
|
-
if (!expressionVariables.every(variable => bindings.has(variable.variable.value))) {
|
|
45
|
-
push(bindings);
|
|
46
|
-
return done();
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const result = await evaluator.evaluateAsEBV(bindings);
|
|
50
|
-
if (result) {
|
|
51
|
-
push(bindings);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
// We ignore all Expression errors.
|
|
56
|
-
// Other errors (likely programming mistakes) are still propagated.
|
|
57
|
-
// Left Join is defined in terms of Filter (https://www.w3.org/TR/sparql11-query/#defn_algJoin),
|
|
58
|
-
// and Filter requires this (https://www.w3.org/TR/sparql11-query/#expressions).
|
|
59
|
-
if ((0, utils_expression_evaluator_1.isExpressionError)(error)) {
|
|
60
|
-
// In many cases, this is a user error, where the user should manually cast the variable to a string.
|
|
61
|
-
// In order to help users debug this, we should report these errors via the logger as warnings.
|
|
62
|
-
this.logWarn(context, 'Error occurred while filtering.', () => ({ error, bindings: (0, utils_bindings_factory_1.bindingsToString)(bindings) }));
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
bindingsStream.emit('error', error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
done();
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
joined.bindingsStream = bindingsStream;
|
|
72
|
-
}
|
|
73
|
-
return joined;
|
|
24
|
+
.map(async (subOperation, index) => {
|
|
25
|
+
const output = (0, utils_query_operation_1.getSafeBindings)(await this.mediatorQueryOperation.mediate({ operation: subOperation, context }));
|
|
26
|
+
// If we have an expression in the left join,
|
|
27
|
+
// we attach the expression to the right-hand operation,
|
|
28
|
+
// and enforce a bind-join.
|
|
29
|
+
if (operationOriginal.expression && index === 1) {
|
|
30
|
+
return {
|
|
31
|
+
output,
|
|
32
|
+
operation: algebraFactory.createFilter(subOperation, operationOriginal.expression),
|
|
33
|
+
operationRequired: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
output,
|
|
38
|
+
operation: subOperation,
|
|
39
|
+
};
|
|
40
|
+
})));
|
|
41
|
+
return await this.mediatorJoin.mediate({ type: 'optional', entries, context });
|
|
74
42
|
}
|
|
75
43
|
}
|
|
76
44
|
exports.ActorQueryOperationLeftJoin = ActorQueryOperationLeftJoin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQueryOperationLeftJoin.js","sourceRoot":"","sources":["ActorQueryOperationLeftJoin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ActorQueryOperationLeftJoin.js","sourceRoot":"","sources":["ActorQueryOperationLeftJoin.ts"],"names":[],"mappings":";;;AACA,uEAAiF;AAEjF,+DAA0D;AAE1D,yCAA8C;AAE9C,2EAAkE;AAElE,qDAA0C;AAE1C;;GAEG;AACH,MAAa,2BAA4B,SAAQ,sDAAkD;IAGjG,YAAmB,IAAsC;QACvD,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,UAA4B,EAAE,QAAwB;QAC/E,OAAO,IAAA,mBAAY,GAAE,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,iBAAmC,EAAE,OAAuB;QAEpF,MAAM,WAAW,GAAwB,OAAO,CAAC,OAAO,CAAC,+BAAa,CAAC,WAAW,CAAC,CAAC;QACpF,MAAM,cAAc,GAAG,IAAI,yBAAO,CAAC,WAAW,CAAC,CAAC;QAEhD,uBAAuB;QACvB,MAAM,OAAO,GAAiB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK;aACrE,GAAG,CAAC,KAAK,EAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YAChC,MAAM,MAAM,GAAG,IAAA,uCAAe,EAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAEhH,6CAA6C;YAC7C,wDAAwD;YACxD,2BAA2B;YAC3B,IAAI,iBAAiB,CAAC,UAAU,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChD,OAAO;oBACL,MAAM;oBACN,SAAS,EAAE,cAAc,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,UAAU,CAAC;oBAClF,iBAAiB,EAAE,IAAI;iBACxB,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,MAAM;gBACN,SAAS,EAAE,YAAY;aACxB,CAAC;QACJ,CAAC,CAAC,CAAC,CAAC,CAAC;QAEP,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACjF,CAAC;CACF;AAxCD,kEAwCC","sourcesContent":["import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';\nimport { ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';\nimport type { MediatorRdfJoin } from '@comunica/bus-rdf-join';\nimport { KeysInitQuery } from '@comunica/context-entries';\nimport type { IActorTest, TestResult } from '@comunica/core';\nimport { passTestVoid } from '@comunica/core';\nimport type { ComunicaDataFactory, IActionContext, IJoinEntry, IQueryOperationResult } from '@comunica/types';\nimport { getSafeBindings } from '@comunica/utils-query-operation';\nimport type { Algebra } from 'sparqlalgebrajs';\nimport { Factory } from 'sparqlalgebrajs';\n\n/**\n * A comunica LeftJoin Query Operation Actor.\n */\nexport class ActorQueryOperationLeftJoin extends ActorQueryOperationTypedMediated<Algebra.LeftJoin> {\n public readonly mediatorJoin: MediatorRdfJoin;\n\n public constructor(args: IActorQueryOperationLeftJoinArgs) {\n super(args, 'leftjoin');\n }\n\n public async testOperation(_operation: Algebra.LeftJoin, _context: IActionContext): Promise<TestResult<IActorTest>> {\n return passTestVoid();\n }\n\n public async runOperation(operationOriginal: Algebra.LeftJoin, context: IActionContext):\n Promise<IQueryOperationResult> {\n const dataFactory: ComunicaDataFactory = context.getSafe(KeysInitQuery.dataFactory);\n const algebraFactory = new Factory(dataFactory);\n\n // Delegate to join bus\n const entries: IJoinEntry[] = (await Promise.all(operationOriginal.input\n .map(async(subOperation, index) => {\n const output = getSafeBindings(await this.mediatorQueryOperation.mediate({ operation: subOperation, context }));\n\n // If we have an expression in the left join,\n // we attach the expression to the right-hand operation,\n // and enforce a bind-join.\n if (operationOriginal.expression && index === 1) {\n return {\n output,\n operation: algebraFactory.createFilter(subOperation, operationOriginal.expression),\n operationRequired: true,\n };\n }\n\n return {\n output,\n operation: subOperation,\n };\n })));\n\n return await this.mediatorJoin.mediate({ type: 'optional', entries, context });\n }\n}\n\nexport interface IActorQueryOperationLeftJoinArgs extends IActorQueryOperationTypedMediatedArgs {\n /**\n * A mediator for joining Bindings streams\n */\n mediatorJoin: MediatorRdfJoin;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-operation-leftjoin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "A leftjoin query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,15 +41,13 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-
|
|
45
|
-
"@comunica/bus-
|
|
46
|
-
"@comunica/
|
|
47
|
-
"@comunica/core": "^4.
|
|
48
|
-
"@comunica/types": "^4.
|
|
49
|
-
"@comunica/utils-
|
|
50
|
-
"@comunica/utils-expression-evaluator": "^4.2.0",
|
|
51
|
-
"@comunica/utils-query-operation": "^4.2.0",
|
|
44
|
+
"@comunica/bus-query-operation": "^4.4.0",
|
|
45
|
+
"@comunica/bus-rdf-join": "^4.4.0",
|
|
46
|
+
"@comunica/context-entries": "^4.4.0",
|
|
47
|
+
"@comunica/core": "^4.4.0",
|
|
48
|
+
"@comunica/types": "^4.4.0",
|
|
49
|
+
"@comunica/utils-query-operation": "^4.4.0",
|
|
52
50
|
"sparqlalgebrajs": "^4.3.8"
|
|
53
51
|
},
|
|
54
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "27acde56dfe0c1ff1162c1f46818ad752296ca88"
|
|
55
53
|
}
|