@comunica/actor-rdf-join-inner-multi-smallest 2.0.1-alpha.7.0 → 2.0.1
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 +2 -0
- package/components/ActorRdfJoinMultiSmallest.jsonld +54 -8
- package/components/context.jsonld +7 -1
- package/lib/ActorRdfJoinMultiSmallest.d.ts +14 -1
- package/lib/ActorRdfJoinMultiSmallest.js +27 -27
- package/lib/index.js +5 -1
- package/package.json +8 -7
- package/LICENSE.txt +0 -22
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
31
31
|
"@id": "urn:comunica:default:rdf-join/actors#inner-multi-smallest",
|
|
32
32
|
"@type": "ActorRdfJoinMultiSmallest",
|
|
33
33
|
"mediatorJoinSelectivity": { "@id": "urn:comunica:default:rdf-join-selectivity/mediators#main" },
|
|
34
|
+
"mediatorJoinEntriesSort": { "@id": "urn:comunica:default:rdf-join-entries-sort/mediators#main" },
|
|
34
35
|
"mediatorJoin": { "@id": "urn:comunica:default:rdf-join/mediators#main" }
|
|
35
36
|
}
|
|
36
37
|
]
|
|
@@ -40,4 +41,5 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
40
41
|
### Config Parameters
|
|
41
42
|
|
|
42
43
|
* `mediatorJoinSelectivity`: A mediator over the [RDF Join Selectivity bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join-selectivity).
|
|
44
|
+
* `mediatorJoinEntriesSort`: A mediator over the [RDF Join Entries Sort bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join-entries-sort).
|
|
43
45
|
* `mediatorJoin`: A mediator over the [RDF Join bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join).
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
],
|
|
16
16
|
"comment": "A Multi Smallest RDF Join Actor. It accepts 3 or more streams, joins the smallest two, and joins the result with the remaining streams.",
|
|
17
17
|
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoinEntriesSort",
|
|
20
|
+
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
21
|
+
"comment": "The join entries sort mediator"
|
|
22
|
+
},
|
|
18
23
|
{
|
|
19
24
|
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoin",
|
|
20
25
|
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
@@ -110,17 +115,51 @@
|
|
|
110
115
|
"comment": "Actor that must be registered in the bus before this actor."
|
|
111
116
|
}
|
|
112
117
|
],
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
"memberFields": [
|
|
119
|
+
{
|
|
120
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_mediatorJoinEntriesSort",
|
|
121
|
+
"memberFieldName": "mediatorJoinEntriesSort",
|
|
122
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_mediatorJoin",
|
|
126
|
+
"memberFieldName": "mediatorJoin",
|
|
127
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_FACTORY",
|
|
131
|
+
"memberFieldName": "FACTORY",
|
|
132
|
+
"range": {
|
|
133
|
+
"@type": "ParameterRangeWildcard"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_constructor",
|
|
138
|
+
"memberFieldName": "constructor"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_sortJoinEntries",
|
|
142
|
+
"memberFieldName": "sortJoinEntries"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_getOutput",
|
|
146
|
+
"memberFieldName": "getOutput"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest__member_getJoinCoefficients",
|
|
150
|
+
"memberFieldName": "getJoinCoefficients"
|
|
151
|
+
}
|
|
119
152
|
],
|
|
120
153
|
"constructorArguments": [
|
|
121
154
|
{
|
|
122
155
|
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args__constructorArgument",
|
|
123
156
|
"fields": [
|
|
157
|
+
{
|
|
158
|
+
"keyRaw": "mediatorJoinEntriesSort",
|
|
159
|
+
"value": {
|
|
160
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoinEntriesSort"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
124
163
|
{
|
|
125
164
|
"keyRaw": "mediatorJoin",
|
|
126
165
|
"value": {
|
|
@@ -163,8 +202,15 @@
|
|
|
163
202
|
"cbrj:components/ActorRdfJoin.jsonld#IActorRdfJoinArgs"
|
|
164
203
|
],
|
|
165
204
|
"parameters": [],
|
|
166
|
-
"
|
|
167
|
-
|
|
205
|
+
"memberFields": [
|
|
206
|
+
{
|
|
207
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#IActorRdfJoinMultiSmallestArgs__member_mediatorJoinEntriesSort",
|
|
208
|
+
"memberFieldName": "mediatorJoinEntriesSort"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#IActorRdfJoinMultiSmallestArgs__member_mediatorJoin",
|
|
212
|
+
"memberFieldName": "mediatorJoin"
|
|
213
|
+
}
|
|
168
214
|
],
|
|
169
215
|
"constructorArguments": []
|
|
170
216
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
6
|
"carjimsm": "npmd:@comunica/actor-rdf-join-inner-multi-smallest/^2.0.0/",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest",
|
|
9
9
|
"@prefix": true,
|
|
10
10
|
"@context": {
|
|
11
|
+
"args_mediatorJoinEntriesSort": {
|
|
12
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoinEntriesSort"
|
|
13
|
+
},
|
|
11
14
|
"args_mediatorJoin": {
|
|
12
15
|
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoin"
|
|
13
16
|
},
|
|
@@ -24,6 +27,9 @@
|
|
|
24
27
|
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_beforeActors",
|
|
25
28
|
"@container": "@list"
|
|
26
29
|
},
|
|
30
|
+
"mediatorJoinEntriesSort": {
|
|
31
|
+
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoinEntriesSort"
|
|
32
|
+
},
|
|
27
33
|
"mediatorJoin": {
|
|
28
34
|
"@id": "carjimsm:components/ActorRdfJoinMultiSmallest.jsonld#ActorRdfJoinMultiSmallest_args_mediatorJoin"
|
|
29
35
|
},
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import type { IActionRdfJoin, IActorRdfJoinOutputInner, IActorRdfJoinArgs, MediatorRdfJoin } from '@comunica/bus-rdf-join';
|
|
2
2
|
import { ActorRdfJoin } from '@comunica/bus-rdf-join';
|
|
3
|
+
import type { MediatorRdfJoinEntriesSort } from '@comunica/bus-rdf-join-entries-sort';
|
|
3
4
|
import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients';
|
|
4
|
-
import type { MetadataBindings } from '@comunica/types';
|
|
5
|
+
import type { MetadataBindings, IActionContext, IJoinEntryWithMetadata } from '@comunica/types';
|
|
5
6
|
import { Factory } from 'sparqlalgebrajs';
|
|
6
7
|
/**
|
|
7
8
|
* A Multi Smallest RDF Join Actor.
|
|
8
9
|
* It accepts 3 or more streams, joins the smallest two, and joins the result with the remaining streams.
|
|
9
10
|
*/
|
|
10
11
|
export declare class ActorRdfJoinMultiSmallest extends ActorRdfJoin {
|
|
12
|
+
readonly mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort;
|
|
11
13
|
readonly mediatorJoin: MediatorRdfJoin;
|
|
12
14
|
static readonly FACTORY: Factory;
|
|
13
15
|
constructor(args: IActorRdfJoinMultiSmallestArgs);
|
|
16
|
+
/**
|
|
17
|
+
* Order the given join entries using the join-entries-sort bus.
|
|
18
|
+
* @param {IJoinEntryWithMetadata[]} entries An array of join entries.
|
|
19
|
+
* @param context The action context.
|
|
20
|
+
* @return {IJoinEntryWithMetadata[]} The sorted join entries.
|
|
21
|
+
*/
|
|
22
|
+
sortJoinEntries(entries: IJoinEntryWithMetadata[], context: IActionContext): Promise<IJoinEntryWithMetadata[]>;
|
|
14
23
|
protected getOutput(action: IActionRdfJoin): Promise<IActorRdfJoinOutputInner>;
|
|
15
24
|
protected getJoinCoefficients(action: IActionRdfJoin, metadatas: MetadataBindings[]): Promise<IMediatorTypeJoinCoefficients>;
|
|
16
25
|
}
|
|
17
26
|
export interface IActorRdfJoinMultiSmallestArgs extends IActorRdfJoinArgs {
|
|
27
|
+
/**
|
|
28
|
+
* The join entries sort mediator
|
|
29
|
+
*/
|
|
30
|
+
mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort;
|
|
18
31
|
/**
|
|
19
32
|
* A mediator for joining Bindings streams
|
|
20
33
|
*/
|
|
@@ -17,22 +17,27 @@ class ActorRdfJoinMultiSmallest extends bus_rdf_join_1.ActorRdfJoin {
|
|
|
17
17
|
limitEntriesMin: true,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Order the given join entries using the join-entries-sort bus.
|
|
22
|
+
* @param {IJoinEntryWithMetadata[]} entries An array of join entries.
|
|
23
|
+
* @param context The action context.
|
|
24
|
+
* @return {IJoinEntryWithMetadata[]} The sorted join entries.
|
|
25
|
+
*/
|
|
26
|
+
async sortJoinEntries(entries, context) {
|
|
27
|
+
return (await this.mediatorJoinEntriesSort.mediate({ entries, context })).entries;
|
|
28
|
+
}
|
|
20
29
|
async getOutput(action) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
metadatas.splice(smallestIndex1, 1);
|
|
27
|
-
const smallestIndex2 = bus_rdf_join_1.ActorRdfJoin.getLowestCardinalityIndex(metadatas);
|
|
28
|
-
const smallestItem2 = entries.splice(smallestIndex2, 1)[0];
|
|
29
|
-
metadatas.splice(smallestIndex2, 1);
|
|
30
|
+
// Determine the two smallest streams by sorting (e.g. via cardinality)
|
|
31
|
+
const entries = await this.sortJoinEntries(await bus_rdf_join_1.ActorRdfJoin.getEntriesWithMetadatas([...action.entries]), action.context);
|
|
32
|
+
const smallestEntry1 = entries[0];
|
|
33
|
+
const smallestEntry2 = entries[1];
|
|
34
|
+
entries.splice(0, 2);
|
|
30
35
|
// Join the two selected streams, and then join the result with the remaining streams
|
|
31
36
|
const firstEntry = {
|
|
32
37
|
output: bus_query_operation_1.ActorQueryOperation.getSafeBindings(await this.mediatorJoin
|
|
33
|
-
.mediate({ type: action.type, entries: [
|
|
38
|
+
.mediate({ type: action.type, entries: [smallestEntry1, smallestEntry2], context: action.context })),
|
|
34
39
|
operation: ActorRdfJoinMultiSmallest.FACTORY
|
|
35
|
-
.createJoin([
|
|
40
|
+
.createJoin([smallestEntry1.operation, smallestEntry2.operation], false),
|
|
36
41
|
};
|
|
37
42
|
entries.push(firstEntry);
|
|
38
43
|
return {
|
|
@@ -42,32 +47,27 @@ class ActorRdfJoinMultiSmallest extends bus_rdf_join_1.ActorRdfJoin {
|
|
|
42
47
|
context: action.context,
|
|
43
48
|
}),
|
|
44
49
|
physicalPlanMetadata: {
|
|
45
|
-
smallest: [
|
|
50
|
+
smallest: [smallestEntry1, smallestEntry2],
|
|
46
51
|
},
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
54
|
async getJoinCoefficients(action, metadatas) {
|
|
50
55
|
metadatas = [...metadatas];
|
|
56
|
+
// Determine the two smallest streams by sorting (e.g. via cardinality)
|
|
57
|
+
const entriesWithMetadata = await this.sortJoinEntries(action.entries
|
|
58
|
+
.map((entry, i) => ({ ...entry, metadata: metadatas[i] })), action.context);
|
|
59
|
+
metadatas = entriesWithMetadata.map(entry => entry.metadata);
|
|
51
60
|
const requestInitialTimes = bus_rdf_join_1.ActorRdfJoin.getRequestInitialTimes(metadatas);
|
|
52
61
|
const requestItemTimes = bus_rdf_join_1.ActorRdfJoin.getRequestItemTimes(metadatas);
|
|
53
|
-
// Determine the two smallest streams by estimated count
|
|
54
|
-
const smallestIndex1 = bus_rdf_join_1.ActorRdfJoin.getLowestCardinalityIndex(metadatas);
|
|
55
|
-
const metadataSmallest1 = metadatas.splice(smallestIndex1, 1)[0];
|
|
56
|
-
const requestInitialTimeSmallest1 = requestInitialTimes.splice(smallestIndex1, 1)[0];
|
|
57
|
-
const requestItemTimesSmallest1 = requestItemTimes.splice(smallestIndex1, 1)[0];
|
|
58
|
-
const smallestIndex2 = bus_rdf_join_1.ActorRdfJoin.getLowestCardinalityIndex(metadatas);
|
|
59
|
-
const metadataSmallest2 = metadatas.splice(smallestIndex2, 1)[0];
|
|
60
|
-
const requestInitialTimeSmallest2 = requestInitialTimes.splice(smallestIndex2, 1)[0];
|
|
61
|
-
const requestItemTimesSmallest2 = requestItemTimes.splice(smallestIndex2, 1)[0];
|
|
62
62
|
return {
|
|
63
|
-
iterations:
|
|
64
|
-
metadatas.reduce((acc, metadata) => acc * metadata.cardinality.value, 1),
|
|
63
|
+
iterations: metadatas[0].cardinality.value * metadatas[1].cardinality.value *
|
|
64
|
+
metadatas.slice(2).reduce((acc, metadata) => acc * metadata.cardinality.value, 1),
|
|
65
65
|
persistedItems: 0,
|
|
66
66
|
blockingItems: 0,
|
|
67
|
-
requestTime:
|
|
68
|
-
|
|
69
|
-
metadatas.reduce((sum, metadata, i) => sum + requestInitialTimes[i] +
|
|
70
|
-
metadata.cardinality.value * requestItemTimes[i], 0),
|
|
67
|
+
requestTime: requestInitialTimes[0] + metadatas[0].cardinality.value * requestItemTimes[0] +
|
|
68
|
+
requestInitialTimes[1] + metadatas[1].cardinality.value * requestItemTimes[1] +
|
|
69
|
+
metadatas.slice(2).reduce((sum, metadata, i) => sum + requestInitialTimes.slice(2)[i] +
|
|
70
|
+
metadata.cardinality.value * requestItemTimes.slice(2)[i], 0),
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-rdf-join-inner-multi-smallest",
|
|
3
|
-
"version": "2.0.1
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A multi-smallest rdf-join actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"lib/**/*.js"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@comunica/bus-query-operation": "2.0.1
|
|
35
|
-
"@comunica/bus-rdf-join": "2.0.1
|
|
36
|
-
"@comunica/
|
|
37
|
-
"@comunica/
|
|
38
|
-
"@comunica/
|
|
34
|
+
"@comunica/bus-query-operation": "^2.0.1",
|
|
35
|
+
"@comunica/bus-rdf-join": "^2.0.1",
|
|
36
|
+
"@comunica/bus-rdf-join-entries-sort": "^2.0.1",
|
|
37
|
+
"@comunica/core": "^2.0.1",
|
|
38
|
+
"@comunica/mediatortype-join-coefficients": "^2.0.1",
|
|
39
|
+
"@comunica/types": "^2.0.1",
|
|
39
40
|
"sparqlalgebrajs": "^4.0.0"
|
|
40
41
|
},
|
|
41
42
|
"scripts": {
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
44
45
|
"build:components": "componentsjs-generator"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4c66bfaa44f73786bc7403504e5fe571181430c7"
|
|
47
48
|
}
|
package/LICENSE.txt
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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.
|