@comunica/actor-query-operation-union 2.10.0 → 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/README.md +1 -1
- package/components/ActorQueryOperationUnion.jsonld +43 -12
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +12 -1
- package/lib/ActorQueryOperationUnion.d.ts +9 -2
- package/lib/ActorQueryOperationUnion.js +55 -32
- package/lib/ActorQueryOperationUnion.js.map +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
22
22
|
{
|
|
23
23
|
"@context": [
|
|
24
24
|
...
|
|
25
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-union/^
|
|
25
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-union/^3.0.0/components/context.jsonld"
|
|
26
26
|
],
|
|
27
27
|
"actors": [
|
|
28
28
|
...
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-union/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-union/^3.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^3.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^3.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-query-operation-union",
|
|
8
8
|
"components": [
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
],
|
|
22
22
|
"comment": "A comunica Union Query Operation Actor.",
|
|
23
23
|
"parameters": [
|
|
24
|
+
{
|
|
25
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorRdfMetadataAccumulate",
|
|
26
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
27
|
+
},
|
|
24
28
|
{
|
|
25
29
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorQueryOperation",
|
|
26
30
|
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
@@ -45,29 +49,29 @@
|
|
|
45
49
|
"genericTypeInstances": [
|
|
46
50
|
{
|
|
47
51
|
"@type": "ParameterRangeGenericTypeReference",
|
|
48
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
52
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
49
53
|
},
|
|
50
54
|
{
|
|
51
55
|
"@type": "ParameterRangeGenericTypeReference",
|
|
52
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
53
57
|
},
|
|
54
58
|
{
|
|
55
59
|
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
57
61
|
}
|
|
58
62
|
]
|
|
59
63
|
},
|
|
60
64
|
{
|
|
61
65
|
"@type": "ParameterRangeGenericTypeReference",
|
|
62
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
66
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
63
67
|
},
|
|
64
68
|
{
|
|
65
69
|
"@type": "ParameterRangeGenericTypeReference",
|
|
66
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
70
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
67
71
|
},
|
|
68
72
|
{
|
|
69
73
|
"@type": "ParameterRangeGenericTypeReference",
|
|
70
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
74
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
71
75
|
}
|
|
72
76
|
]
|
|
73
77
|
},
|
|
@@ -90,15 +94,15 @@
|
|
|
90
94
|
"genericTypeInstances": [
|
|
91
95
|
{
|
|
92
96
|
"@type": "ParameterRangeGenericTypeReference",
|
|
93
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
97
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
94
98
|
},
|
|
95
99
|
{
|
|
96
100
|
"@type": "ParameterRangeGenericTypeReference",
|
|
97
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
101
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
98
102
|
},
|
|
99
103
|
{
|
|
100
104
|
"@type": "ParameterRangeGenericTypeReference",
|
|
101
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
105
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
102
106
|
}
|
|
103
107
|
]
|
|
104
108
|
}
|
|
@@ -112,6 +116,11 @@
|
|
|
112
116
|
}
|
|
113
117
|
],
|
|
114
118
|
"memberFields": [
|
|
119
|
+
{
|
|
120
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion__member_mediatorRdfMetadataAccumulate",
|
|
121
|
+
"memberFieldName": "mediatorRdfMetadataAccumulate",
|
|
122
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
123
|
+
},
|
|
115
124
|
{
|
|
116
125
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion__member_constructor",
|
|
117
126
|
"memberFieldName": "constructor"
|
|
@@ -137,6 +146,12 @@
|
|
|
137
146
|
{
|
|
138
147
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args__constructorArgument",
|
|
139
148
|
"fields": [
|
|
149
|
+
{
|
|
150
|
+
"keyRaw": "mediatorRdfMetadataAccumulate",
|
|
151
|
+
"value": {
|
|
152
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorRdfMetadataAccumulate"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
140
155
|
{
|
|
141
156
|
"keyRaw": "mediatorQueryOperation",
|
|
142
157
|
"value": {
|
|
@@ -164,6 +179,22 @@
|
|
|
164
179
|
]
|
|
165
180
|
}
|
|
166
181
|
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#IActorQueryOperationUnionArgs",
|
|
185
|
+
"@type": "AbstractClass",
|
|
186
|
+
"requireElement": "IActorQueryOperationUnionArgs",
|
|
187
|
+
"extends": [
|
|
188
|
+
"cbqo:components/ActorQueryOperationTypedMediated.jsonld#IActorQueryOperationTypedMediatedArgs"
|
|
189
|
+
],
|
|
190
|
+
"parameters": [],
|
|
191
|
+
"memberFields": [
|
|
192
|
+
{
|
|
193
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#IActorQueryOperationUnionArgs__member_mediatorRdfMetadataAccumulate",
|
|
194
|
+
"memberFieldName": "mediatorRdfMetadataAccumulate"
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"constructorArguments": []
|
|
167
198
|
}
|
|
168
199
|
]
|
|
169
200
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-union/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-union/^3.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-query-operation-union",
|
|
6
6
|
"@type": "Module",
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
-
"caqou": "npmd:@comunica/actor-query-operation-union/^
|
|
6
|
+
"caqou": "npmd:@comunica/actor-query-operation-union/^3.0.0/",
|
|
7
7
|
"ActorQueryOperationUnion": {
|
|
8
8
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion",
|
|
9
9
|
"@prefix": true,
|
|
10
10
|
"@context": {
|
|
11
|
+
"args_mediatorRdfMetadataAccumulate": {
|
|
12
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorRdfMetadataAccumulate"
|
|
13
|
+
},
|
|
11
14
|
"args_mediatorQueryOperation": {
|
|
12
15
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorQueryOperation"
|
|
13
16
|
},
|
|
@@ -21,6 +24,9 @@
|
|
|
21
24
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_beforeActors",
|
|
22
25
|
"@container": "@list"
|
|
23
26
|
},
|
|
27
|
+
"mediatorRdfMetadataAccumulate": {
|
|
28
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorRdfMetadataAccumulate"
|
|
29
|
+
},
|
|
24
30
|
"mediatorQueryOperation": {
|
|
25
31
|
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#ActorQueryOperationUnion_args_mediatorQueryOperation"
|
|
26
32
|
},
|
|
@@ -35,6 +41,11 @@
|
|
|
35
41
|
"@container": "@list"
|
|
36
42
|
}
|
|
37
43
|
}
|
|
44
|
+
},
|
|
45
|
+
"IActorQueryOperationUnionArgs": {
|
|
46
|
+
"@id": "caqou:components/ActorQueryOperationUnion.jsonld#IActorQueryOperationUnionArgs",
|
|
47
|
+
"@prefix": true,
|
|
48
|
+
"@context": {}
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
51
|
]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';
|
|
2
2
|
import { ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';
|
|
3
|
+
import type { MediatorRdfMetadataAccumulate } from '@comunica/bus-rdf-metadata-accumulate';
|
|
3
4
|
import type { IActorTest } from '@comunica/core';
|
|
4
5
|
import type { IActionContext, IQueryOperationResult, MetadataBindings, MetadataQuads } from '@comunica/types';
|
|
5
6
|
import type * as RDF from '@rdfjs/types';
|
|
@@ -8,7 +9,8 @@ import type { Algebra } from 'sparqlalgebrajs';
|
|
|
8
9
|
* A comunica Union Query Operation Actor.
|
|
9
10
|
*/
|
|
10
11
|
export declare class ActorQueryOperationUnion extends ActorQueryOperationTypedMediated<Algebra.Union> {
|
|
11
|
-
|
|
12
|
+
readonly mediatorRdfMetadataAccumulate: MediatorRdfMetadataAccumulate;
|
|
13
|
+
constructor(args: IActorQueryOperationUnionArgs);
|
|
12
14
|
/**
|
|
13
15
|
* Takes the union of the given double array variables.
|
|
14
16
|
* Uniqueness is guaranteed.
|
|
@@ -21,9 +23,14 @@ export declare class ActorQueryOperationUnion extends ActorQueryOperationTypedMe
|
|
|
21
23
|
* It will ensure that the cardinality metadata value is properly calculated.
|
|
22
24
|
* @param {{[p: string]: any}[]} metadatas Array of metadata.
|
|
23
25
|
* @param bindings If the union of the variables field should also be taken.
|
|
26
|
+
* @param context The action context
|
|
27
|
+
* @param mediatorRdfMetadataAccumulate Mediator for metadata accumulation
|
|
24
28
|
* @return {{[p: string]: any}} Union of the metadata.
|
|
25
29
|
*/
|
|
26
|
-
static unionMetadata<Bindings extends boolean, M extends (Bindings extends true ? MetadataBindings : MetadataQuads)>(metadatas: M[], bindings: Bindings): M
|
|
30
|
+
static unionMetadata<Bindings extends boolean, M extends (Bindings extends true ? MetadataBindings : MetadataQuads)>(metadatas: M[], bindings: Bindings, context: IActionContext, mediatorRdfMetadataAccumulate: MediatorRdfMetadataAccumulate): Promise<M>;
|
|
27
31
|
testOperation(operation: Algebra.Union, context: IActionContext): Promise<IActorTest>;
|
|
28
32
|
runOperation(operation: Algebra.Union, context: IActionContext): Promise<IQueryOperationResult>;
|
|
29
33
|
}
|
|
34
|
+
export interface IActorQueryOperationUnionArgs extends IActorQueryOperationTypedMediatedArgs {
|
|
35
|
+
mediatorRdfMetadataAccumulate: MediatorRdfMetadataAccumulate;
|
|
36
|
+
}
|
|
@@ -26,53 +26,76 @@ class ActorQueryOperationUnion extends bus_query_operation_1.ActorQueryOperation
|
|
|
26
26
|
* It will ensure that the cardinality metadata value is properly calculated.
|
|
27
27
|
* @param {{[p: string]: any}[]} metadatas Array of metadata.
|
|
28
28
|
* @param bindings If the union of the variables field should also be taken.
|
|
29
|
+
* @param context The action context
|
|
30
|
+
* @param mediatorRdfMetadataAccumulate Mediator for metadata accumulation
|
|
29
31
|
* @return {{[p: string]: any}} Union of the metadata.
|
|
30
32
|
*/
|
|
31
|
-
static unionMetadata(metadatas, bindings) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
33
|
+
static async unionMetadata(metadatas, bindings, context, mediatorRdfMetadataAccumulate) {
|
|
34
|
+
let accumulatedMetadata = (await mediatorRdfMetadataAccumulate
|
|
35
|
+
.mediate({ mode: 'initialize', context })).metadata;
|
|
36
|
+
// Accumulate cardinality
|
|
37
|
+
for (const appendingMetadata of metadatas) {
|
|
38
|
+
accumulatedMetadata = {
|
|
39
|
+
...appendingMetadata,
|
|
40
|
+
...(await mediatorRdfMetadataAccumulate
|
|
41
|
+
.mediate({
|
|
42
|
+
mode: 'append',
|
|
43
|
+
accumulatedMetadata: accumulatedMetadata,
|
|
44
|
+
appendingMetadata: appendingMetadata,
|
|
45
|
+
context,
|
|
46
|
+
})).metadata,
|
|
47
|
+
};
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
cardinality,
|
|
51
|
-
canContainUndefs: metadatas.some(metadata => metadata.canContainUndefs),
|
|
52
|
-
};
|
|
49
|
+
// Create new metadata state
|
|
50
|
+
accumulatedMetadata.state = new metadata_1.MetadataValidationState();
|
|
53
51
|
// Propagate metadata invalidations
|
|
54
|
-
const invalidateListener = () =>
|
|
52
|
+
const invalidateListener = () => accumulatedMetadata.state.invalidate();
|
|
55
53
|
for (const metadata of metadatas) {
|
|
56
54
|
metadata.state.addInvalidateListener(invalidateListener);
|
|
57
55
|
}
|
|
58
56
|
// Union variables
|
|
59
57
|
if (bindings) {
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
accumulatedMetadata.variables = ActorQueryOperationUnion
|
|
59
|
+
.unionVariables(metadatas.map(metadata => metadata.variables));
|
|
62
60
|
}
|
|
63
|
-
return
|
|
61
|
+
return accumulatedMetadata;
|
|
64
62
|
}
|
|
65
63
|
async testOperation(operation, context) {
|
|
66
64
|
return true;
|
|
67
65
|
}
|
|
68
66
|
async runOperation(operation, context) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.map(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
// Determine the type over which we are taking a union
|
|
68
|
+
const outputsRaw = await Promise.all(operation.input
|
|
69
|
+
.map(subOperation => this.mediatorQueryOperation.mediate({ operation: subOperation, context })));
|
|
70
|
+
let outputType;
|
|
71
|
+
for (const output of outputsRaw) {
|
|
72
|
+
if (outputType === undefined) {
|
|
73
|
+
outputType = output.type;
|
|
74
|
+
}
|
|
75
|
+
else if (outputType !== output.type) {
|
|
76
|
+
throw new Error(`Unable to union ${outputType} and ${output.type}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Handle bindings
|
|
80
|
+
if (outputType === 'bindings' || operation.input.length === 0) {
|
|
81
|
+
const outputs = outputsRaw.map(bus_query_operation_1.ActorQueryOperation.getSafeBindings);
|
|
82
|
+
const bindingsStream = new asynciterator_1.UnionIterator(outputs.map((output) => output.bindingsStream), { autoStart: false });
|
|
83
|
+
const metadata = () => Promise.all(outputs.map(output => output.metadata()))
|
|
84
|
+
.then(subMeta => ActorQueryOperationUnion
|
|
85
|
+
.unionMetadata(subMeta, true, context, this.mediatorRdfMetadataAccumulate));
|
|
86
|
+
return { type: 'bindings', bindingsStream, metadata };
|
|
87
|
+
}
|
|
88
|
+
// Handle quads
|
|
89
|
+
if (outputType === 'quads') {
|
|
90
|
+
const outputs = outputsRaw.map(bus_query_operation_1.ActorQueryOperation.getSafeQuads);
|
|
91
|
+
const quadStream = new asynciterator_1.UnionIterator(outputs.map((output) => output.quadStream), { autoStart: false });
|
|
92
|
+
const metadata = () => Promise.all(outputs.map(output => output.metadata()))
|
|
93
|
+
.then(subMeta => ActorQueryOperationUnion
|
|
94
|
+
.unionMetadata(subMeta, false, context, this.mediatorRdfMetadataAccumulate));
|
|
95
|
+
return { type: 'quads', quadStream, metadata };
|
|
96
|
+
}
|
|
97
|
+
// Throw otherwise
|
|
98
|
+
throw new Error(`Unable to union ${outputType}`);
|
|
76
99
|
}
|
|
77
100
|
}
|
|
78
101
|
exports.ActorQueryOperationUnion = ActorQueryOperationUnion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQueryOperationUnion.js","sourceRoot":"","sources":["ActorQueryOperationUnion.ts"],"names":[],"mappings":";;;AACA,uEAGuC;
|
|
1
|
+
{"version":3,"file":"ActorQueryOperationUnion.js","sourceRoot":"","sources":["ActorQueryOperationUnion.ts"],"names":[],"mappings":";;;AACA,uEAGuC;AAGvC,iDAA6D;AAS7D,iDAA8C;AAC9C,yCAAsC;AAGtC;;GAEG;AACH,MAAa,wBAAyB,SAAQ,sDAA+C;IAG3F,YAAmB,IAAmC;QACpD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,cAAc,CAAC,SAA2B;QACtD,OAAO,IAAA,qBAAS,EAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAI/B,SAAc,EACd,QAAkB,EAClB,OAAuB,EACvB,6BAA4D;QAC5D,IAAI,mBAAmB,GAAU,CAAC,MAAM,6BAA6B;aAClE,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEtD,yBAAyB;QACzB,KAAK,MAAM,iBAAiB,IAAI,SAAS,EAAE;YACzC,mBAAmB,GAAS;gBAC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zB,MAAM,QAAQ,GAAiC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;iBACvG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,wBAAwB;iBACtC,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC;YACjF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;SAChD;QAED,kBAAkB;QAClB,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAtHD,4DAsHC","sourcesContent":["import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';\nimport {\n ActorQueryOperation,\n ActorQueryOperationTypedMediated,\n} from '@comunica/bus-query-operation';\nimport type { MediatorRdfMetadataAccumulate } from '@comunica/bus-rdf-metadata-accumulate';\nimport type { IActorTest } from '@comunica/core';\nimport { MetadataValidationState } from '@comunica/metadata';\nimport type {\n BindingsStream,\n IQueryOperationResultBindings,\n IActionContext,\n IQueryOperationResult,\n MetadataBindings, MetadataQuads, IQueryOperationResultQuads,\n} from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { UnionIterator } from 'asynciterator';\nimport { uniqTerms } from 'rdf-terms';\nimport type { Algebra } from 'sparqlalgebrajs';\n\n/**\n * A comunica Union Query Operation Actor.\n */\nexport class ActorQueryOperationUnion extends ActorQueryOperationTypedMediated<Algebra.Union> {\n public readonly mediatorRdfMetadataAccumulate: MediatorRdfMetadataAccumulate;\n\n public constructor(args: IActorQueryOperationUnionArgs) {\n super(args, 'union');\n }\n\n /**\n * Takes the union of the given double array variables.\n * Uniqueness is guaranteed.\n * @param {string[][]} variables Double array of variables to take the union of.\n * @return {string[]} The union of the given variables.\n */\n public static unionVariables(variables: RDF.Variable[][]): RDF.Variable[] {\n return uniqTerms(variables.flat());\n }\n\n /**\n * Takes the union of the given metadata array.\n * It will ensure that the cardinality metadata value is properly calculated.\n * @param {{[p: string]: any}[]} metadatas Array of metadata.\n * @param bindings If the union of the variables field should also be taken.\n * @param context The action context\n * @param mediatorRdfMetadataAccumulate Mediator for metadata accumulation\n * @return {{[p: string]: any}} Union of the metadata.\n */\n public static async unionMetadata<\n Bindings extends boolean,\n M extends (Bindings extends true ? MetadataBindings : MetadataQuads)\n >(\n metadatas: M[],\n bindings: Bindings,\n context: IActionContext,\n mediatorRdfMetadataAccumulate: MediatorRdfMetadataAccumulate): Promise<M> {\n let accumulatedMetadata: M = <M> (await mediatorRdfMetadataAccumulate\n .mediate({ mode: 'initialize', context })).metadata;\n\n // Accumulate cardinality\n for (const appendingMetadata of metadatas) {\n accumulatedMetadata = <any> {\n ...appendingMetadata,\n ...(await mediatorRdfMetadataAccumulate\n .mediate({\n mode: 'append',\n accumulatedMetadata: <any> accumulatedMetadata,\n appendingMetadata: <any> appendingMetadata,\n context,\n })).metadata,\n };\n }\n\n // Create new metadata state\n accumulatedMetadata.state = new MetadataValidationState();\n\n // Propagate metadata invalidations\n const invalidateListener = (): void => accumulatedMetadata.state.invalidate();\n for (const metadata of metadatas) {\n metadata.state.addInvalidateListener(invalidateListener);\n }\n\n // Union variables\n if (bindings) {\n accumulatedMetadata.variables = ActorQueryOperationUnion\n .unionVariables(metadatas.map(metadata => metadata.variables));\n }\n\n return accumulatedMetadata;\n }\n\n public async testOperation(operation: Algebra.Union, context: IActionContext): Promise<IActorTest> {\n return true;\n }\n\n public async runOperation(operation: Algebra.Union, context: IActionContext):\n Promise<IQueryOperationResult> {\n // Determine the type over which we are taking a union\n const outputsRaw = await Promise.all(operation.input\n .map(subOperation => this.mediatorQueryOperation.mediate({ operation: subOperation, context })));\n let outputType: string | undefined;\n for (const output of outputsRaw) {\n if (outputType === undefined) {\n outputType = output.type;\n } else if (outputType !== output.type) {\n throw new Error(`Unable to union ${outputType} and ${output.type}`);\n }\n }\n\n // Handle bindings\n if (outputType === 'bindings' || operation.input.length === 0) {\n const outputs: IQueryOperationResultBindings[] = outputsRaw.map(ActorQueryOperation.getSafeBindings);\n\n const bindingsStream: BindingsStream = new UnionIterator(outputs.map(\n (output: IQueryOperationResultBindings) => output.bindingsStream,\n ), { autoStart: false });\n\n const metadata: () => Promise<MetadataBindings> = () => Promise.all(outputs.map(output => output.metadata()))\n .then(subMeta => ActorQueryOperationUnion\n .unionMetadata(subMeta, true, context, this.mediatorRdfMetadataAccumulate));\n return { type: 'bindings', bindingsStream, metadata };\n }\n\n // Handle quads\n if (outputType === 'quads') {\n const outputs: IQueryOperationResultQuads[] = outputsRaw.map(ActorQueryOperation.getSafeQuads);\n\n const quadStream = new UnionIterator(outputs.map(\n (output: IQueryOperationResultQuads) => output.quadStream,\n ), { autoStart: false });\n\n const metadata: () => Promise<MetadataQuads> = () => Promise.all(outputs.map(output => output.metadata()))\n .then(subMeta => ActorQueryOperationUnion\n .unionMetadata(subMeta, false, context, this.mediatorRdfMetadataAccumulate));\n return { type: 'quads', quadStream, metadata };\n }\n\n // Throw otherwise\n throw new Error(`Unable to union ${outputType}`);\n }\n}\n\nexport interface IActorQueryOperationUnionArgs extends IActorQueryOperationTypedMediatedArgs {\n mediatorRdfMetadataAccumulate: MediatorRdfMetadataAccumulate;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-operation-union",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1-alpha.43.0",
|
|
4
4
|
"description": "A union query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,19 +32,20 @@
|
|
|
32
32
|
"lib/**/*.js.map"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@comunica/bus-query-operation": "
|
|
36
|
-
"@comunica/
|
|
37
|
-
"@comunica/
|
|
38
|
-
"@comunica/
|
|
35
|
+
"@comunica/bus-query-operation": "3.0.1-alpha.43.0",
|
|
36
|
+
"@comunica/bus-rdf-metadata-accumulate": "3.0.1-alpha.43.0",
|
|
37
|
+
"@comunica/core": "3.0.1-alpha.43.0",
|
|
38
|
+
"@comunica/metadata": "3.0.1-alpha.43.0",
|
|
39
|
+
"@comunica/types": "3.0.1-alpha.43.0",
|
|
39
40
|
"@rdfjs/types": "*",
|
|
40
41
|
"asynciterator": "^3.8.1",
|
|
41
42
|
"rdf-terms": "^1.11.0",
|
|
42
|
-
"sparqlalgebrajs": "^4.
|
|
43
|
+
"sparqlalgebrajs": "^4.3.3"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "npm run build:ts && npm run build:components",
|
|
46
47
|
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
47
48
|
"build:components": "componentsjs-generator"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "d11e44cf07d4699f9d2c51d5851b5ed443de1997"
|
|
50
51
|
}
|