@comunica/actor-rdf-join-inner-multi-bind-source 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/LICENSE.txt +22 -0
- package/README.md +50 -0
- package/components/ActorRdfJoinMultiBindSource.jsonld +237 -0
- package/components/components.jsonld +11 -0
- package/components/context.jsonld +64 -0
- package/lib/ActorRdfJoinMultiBindSource.d.ts +36 -0
- package/lib/ActorRdfJoinMultiBindSource.js +126 -0
- package/lib/ActorRdfJoinMultiBindSource.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 +50 -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,50 @@
|
|
|
1
|
+
# Comunica Inner Multi Bind Source RDF Join Actor
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/actor-rdf-join-inner-multi-bind-source)
|
|
4
|
+
|
|
5
|
+
An [RDF Join](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join) actor that inner-joins 2 or more streams
|
|
6
|
+
by picking the one with the lowest cardinality,
|
|
7
|
+
chunking it according to a certain block size,
|
|
8
|
+
and joining each chunk with the remaining query by pushing it into the source.
|
|
9
|
+
|
|
10
|
+
This actor can only work if the (equal) source of remaining join entries accept pushing down joins (selector shape must allow `joinBindings`).
|
|
11
|
+
|
|
12
|
+
This module is part of the [Comunica framework](https://github.com/comunica/comunica),
|
|
13
|
+
and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
|
|
14
|
+
|
|
15
|
+
[Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
$ yarn add @comunica/actor-rdf-join-inner-multi-bind-source
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configure
|
|
24
|
+
|
|
25
|
+
After installing, this package can be added to your engine's configuration as follows:
|
|
26
|
+
```text
|
|
27
|
+
{
|
|
28
|
+
"@context": [
|
|
29
|
+
...
|
|
30
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-multi-bind-source/^1.0.0/components/context.jsonld"
|
|
31
|
+
],
|
|
32
|
+
"actors": [
|
|
33
|
+
...
|
|
34
|
+
{
|
|
35
|
+
"@id": "urn:comunica:default:rdf-join/actors#inner-multi-bind-source",
|
|
36
|
+
"@type": "ActorRdfJoinMultiBindSource",
|
|
37
|
+
"mediatorJoinSelectivity": { "@id": "urn:comunica:default:rdf-join-selectivity/mediators#main" },
|
|
38
|
+
"mediatorJoinEntriesSort": { "@id": "urn:comunica:default:rdf-join-entries-sort/mediators#main" },
|
|
39
|
+
"mediatorQueryOperation": { "@id": "urn:comunica:default:query-operation/mediators#main" }
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Config Parameters
|
|
46
|
+
|
|
47
|
+
* `mediatorJoinSelectivity`: A mediator over the [RDF Join Selectivity bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join-selectivity).
|
|
48
|
+
* `mediatorJoinEntriesSort`: A mediator over the [RDF Join Entries Sort bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-join-entries-sort).
|
|
49
|
+
* `selectivityModifier`: Multiplier for selectivity values. _(defaults to `0.0001`)_
|
|
50
|
+
* `blockSize`: The maximum amount of bindings to send to the source per block. _(defaults to `16`)_
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-multi-bind-source/^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-rdf-join/^3.0.0/components/context.jsonld"
|
|
6
|
+
],
|
|
7
|
+
"@id": "npmd:@comunica/actor-rdf-join-inner-multi-bind-source",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource",
|
|
11
|
+
"@type": "Class",
|
|
12
|
+
"requireElement": "ActorRdfJoinMultiBindSource",
|
|
13
|
+
"extends": [
|
|
14
|
+
"cbrj:components/ActorRdfJoin.jsonld#ActorRdfJoin"
|
|
15
|
+
],
|
|
16
|
+
"comment": "A comunica Inner Multi Bind Source RDF Join Actor.",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_selectivityModifier",
|
|
20
|
+
"range": "xsd:double",
|
|
21
|
+
"default": "0.0001",
|
|
22
|
+
"comment": "Multiplier for selectivity values"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_blockSize",
|
|
26
|
+
"range": "xsd:number",
|
|
27
|
+
"default": "16",
|
|
28
|
+
"comment": "The maximum amount of bindings to send to the source per block."
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinEntriesSort",
|
|
32
|
+
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
33
|
+
"comment": "The join entries sort mediator"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinSelectivity",
|
|
37
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_name",
|
|
41
|
+
"range": "xsd:string",
|
|
42
|
+
"default": {
|
|
43
|
+
"@id": "rdf:subject"
|
|
44
|
+
},
|
|
45
|
+
"comment": "The name for this actor."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_bus",
|
|
49
|
+
"range": {
|
|
50
|
+
"@type": "ParameterRangeGenericComponent",
|
|
51
|
+
"component": "cc:components/Bus.jsonld#Bus",
|
|
52
|
+
"genericTypeInstances": [
|
|
53
|
+
{
|
|
54
|
+
"@type": "ParameterRangeGenericComponent",
|
|
55
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
56
|
+
"genericTypeInstances": [
|
|
57
|
+
{
|
|
58
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
59
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
63
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
67
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
73
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
77
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
81
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"default": {
|
|
86
|
+
"@id": "cbrj:components/ActorRdfJoin.jsonld#ActorRdfJoin_default_bus",
|
|
87
|
+
"@type": "cc:components/Bus.jsonld#Bus"
|
|
88
|
+
},
|
|
89
|
+
"comment": "The bus this actor subscribes to."
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_beforeActors",
|
|
93
|
+
"range": {
|
|
94
|
+
"@type": "ParameterRangeUnion",
|
|
95
|
+
"parameterRangeElements": [
|
|
96
|
+
{
|
|
97
|
+
"@type": "ParameterRangeArray",
|
|
98
|
+
"parameterRangeValue": {
|
|
99
|
+
"@type": "ParameterRangeGenericComponent",
|
|
100
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
101
|
+
"genericTypeInstances": [
|
|
102
|
+
{
|
|
103
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
104
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
108
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
112
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"@type": "ParameterRangeUndefined"
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"comment": "Actor that must be registered in the bus before this actor."
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"memberFields": [
|
|
126
|
+
{
|
|
127
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_selectivityModifier",
|
|
128
|
+
"memberFieldName": "selectivityModifier",
|
|
129
|
+
"range": "xsd:number"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_blockSize",
|
|
133
|
+
"memberFieldName": "blockSize",
|
|
134
|
+
"range": "xsd:number"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_mediatorJoinEntriesSort",
|
|
138
|
+
"memberFieldName": "mediatorJoinEntriesSort",
|
|
139
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_constructor",
|
|
143
|
+
"memberFieldName": "constructor"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_getOutput",
|
|
147
|
+
"memberFieldName": "getOutput"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_sortJoinEntries",
|
|
151
|
+
"memberFieldName": "sortJoinEntries"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_getJoinCoefficients",
|
|
155
|
+
"memberFieldName": "getJoinCoefficients"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource__member_createOperationFromEntries",
|
|
159
|
+
"memberFieldName": "createOperationFromEntries"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"constructorArguments": [
|
|
163
|
+
{
|
|
164
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args__constructorArgument",
|
|
165
|
+
"fields": [
|
|
166
|
+
{
|
|
167
|
+
"keyRaw": "selectivityModifier",
|
|
168
|
+
"value": {
|
|
169
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_selectivityModifier"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"keyRaw": "blockSize",
|
|
174
|
+
"value": {
|
|
175
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_blockSize"
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"keyRaw": "mediatorJoinEntriesSort",
|
|
180
|
+
"value": {
|
|
181
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinEntriesSort"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"keyRaw": "mediatorJoinSelectivity",
|
|
186
|
+
"value": {
|
|
187
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinSelectivity"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"keyRaw": "name",
|
|
192
|
+
"value": {
|
|
193
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_name"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"keyRaw": "bus",
|
|
198
|
+
"value": {
|
|
199
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_bus"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"keyRaw": "beforeActors",
|
|
204
|
+
"value": {
|
|
205
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_beforeActors"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#IActorRdfJoinInnerMultiBindSourceArgs",
|
|
214
|
+
"@type": "AbstractClass",
|
|
215
|
+
"requireElement": "IActorRdfJoinInnerMultiBindSourceArgs",
|
|
216
|
+
"extends": [
|
|
217
|
+
"cbrj:components/ActorRdfJoin.jsonld#IActorRdfJoinArgs"
|
|
218
|
+
],
|
|
219
|
+
"parameters": [],
|
|
220
|
+
"memberFields": [
|
|
221
|
+
{
|
|
222
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#IActorRdfJoinInnerMultiBindSourceArgs__member_selectivityModifier",
|
|
223
|
+
"memberFieldName": "selectivityModifier"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#IActorRdfJoinInnerMultiBindSourceArgs__member_blockSize",
|
|
227
|
+
"memberFieldName": "blockSize"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#IActorRdfJoinInnerMultiBindSourceArgs__member_mediatorJoinEntriesSort",
|
|
231
|
+
"memberFieldName": "mediatorJoinEntriesSort"
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
"constructorArguments": []
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-inner-multi-bind-source/^3.0.0/components/context.jsonld"
|
|
4
|
+
],
|
|
5
|
+
"@id": "npmd:@comunica/actor-rdf-join-inner-multi-bind-source",
|
|
6
|
+
"@type": "Module",
|
|
7
|
+
"requireName": "@comunica/actor-rdf-join-inner-multi-bind-source",
|
|
8
|
+
"import": [
|
|
9
|
+
"carjimbs:components/ActorRdfJoinMultiBindSource.jsonld"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
|
|
4
|
+
{
|
|
5
|
+
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
+
"carjimbs": "npmd:@comunica/actor-rdf-join-inner-multi-bind-source/^3.0.0/",
|
|
7
|
+
"ActorRdfJoinMultiBindSource": {
|
|
8
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource",
|
|
9
|
+
"@prefix": true,
|
|
10
|
+
"@context": {
|
|
11
|
+
"args_selectivityModifier": {
|
|
12
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_selectivityModifier"
|
|
13
|
+
},
|
|
14
|
+
"args_blockSize": {
|
|
15
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_blockSize"
|
|
16
|
+
},
|
|
17
|
+
"args_mediatorJoinEntriesSort": {
|
|
18
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinEntriesSort"
|
|
19
|
+
},
|
|
20
|
+
"args_mediatorJoinSelectivity": {
|
|
21
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinSelectivity"
|
|
22
|
+
},
|
|
23
|
+
"args_name": {
|
|
24
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_name"
|
|
25
|
+
},
|
|
26
|
+
"args_bus": {
|
|
27
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_bus"
|
|
28
|
+
},
|
|
29
|
+
"args_beforeActors": {
|
|
30
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_beforeActors",
|
|
31
|
+
"@container": "@list"
|
|
32
|
+
},
|
|
33
|
+
"selectivityModifier": {
|
|
34
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_selectivityModifier"
|
|
35
|
+
},
|
|
36
|
+
"blockSize": {
|
|
37
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_blockSize"
|
|
38
|
+
},
|
|
39
|
+
"mediatorJoinEntriesSort": {
|
|
40
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinEntriesSort"
|
|
41
|
+
},
|
|
42
|
+
"mediatorJoinSelectivity": {
|
|
43
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_mediatorJoinSelectivity"
|
|
44
|
+
},
|
|
45
|
+
"name": {
|
|
46
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_name"
|
|
47
|
+
},
|
|
48
|
+
"bus": {
|
|
49
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_bus"
|
|
50
|
+
},
|
|
51
|
+
"beforeActors": {
|
|
52
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#ActorRdfJoinMultiBindSource_args_beforeActors",
|
|
53
|
+
"@container": "@list"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"IActorRdfJoinInnerMultiBindSourceArgs": {
|
|
58
|
+
"@id": "carjimbs:components/ActorRdfJoinMultiBindSource.jsonld#IActorRdfJoinInnerMultiBindSourceArgs",
|
|
59
|
+
"@prefix": true,
|
|
60
|
+
"@context": {}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IActionRdfJoin, IActorRdfJoinArgs, IActorRdfJoinOutputInner } from '@comunica/bus-rdf-join';
|
|
2
|
+
import { ActorRdfJoin } from '@comunica/bus-rdf-join';
|
|
3
|
+
import type { MediatorRdfJoinEntriesSort } from '@comunica/bus-rdf-join-entries-sort';
|
|
4
|
+
import type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients';
|
|
5
|
+
import type { IJoinEntryWithMetadata, MetadataBindings, IActionContext } from '@comunica/types';
|
|
6
|
+
import type { Algebra } from 'sparqlalgebrajs';
|
|
7
|
+
/**
|
|
8
|
+
* A comunica Inner Multi Bind Source RDF Join Actor.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ActorRdfJoinMultiBindSource extends ActorRdfJoin {
|
|
11
|
+
readonly selectivityModifier: number;
|
|
12
|
+
readonly blockSize: number;
|
|
13
|
+
readonly mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort;
|
|
14
|
+
constructor(args: IActorRdfJoinInnerMultiBindSourceArgs);
|
|
15
|
+
getOutput(action: IActionRdfJoin): Promise<IActorRdfJoinOutputInner>;
|
|
16
|
+
protected sortJoinEntries(entries: IJoinEntryWithMetadata[], context: IActionContext): Promise<IJoinEntryWithMetadata[]>;
|
|
17
|
+
getJoinCoefficients(action: IActionRdfJoin, metadatas: MetadataBindings[]): Promise<IMediatorTypeJoinCoefficients>;
|
|
18
|
+
createOperationFromEntries(remainingEntries: IJoinEntryWithMetadata[]): Algebra.Operation;
|
|
19
|
+
}
|
|
20
|
+
export interface IActorRdfJoinInnerMultiBindSourceArgs extends IActorRdfJoinArgs {
|
|
21
|
+
/**
|
|
22
|
+
* Multiplier for selectivity values
|
|
23
|
+
* @range {double}
|
|
24
|
+
* @default {0.0001}
|
|
25
|
+
*/
|
|
26
|
+
selectivityModifier: number;
|
|
27
|
+
/**
|
|
28
|
+
* The maximum amount of bindings to send to the source per block.
|
|
29
|
+
* @default {16}
|
|
30
|
+
*/
|
|
31
|
+
blockSize: number;
|
|
32
|
+
/**
|
|
33
|
+
* The join entries sort mediator
|
|
34
|
+
*/
|
|
35
|
+
mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort;
|
|
36
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActorRdfJoinMultiBindSource = void 0;
|
|
4
|
+
const bus_query_operation_1 = require("@comunica/bus-query-operation");
|
|
5
|
+
const bus_rdf_join_1 = require("@comunica/bus-rdf-join");
|
|
6
|
+
const asynciterator_1 = require("asynciterator");
|
|
7
|
+
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
8
|
+
const AF = new sparqlalgebrajs_1.Factory();
|
|
9
|
+
/**
|
|
10
|
+
* A comunica Inner Multi Bind Source RDF Join Actor.
|
|
11
|
+
*/
|
|
12
|
+
class ActorRdfJoinMultiBindSource extends bus_rdf_join_1.ActorRdfJoin {
|
|
13
|
+
constructor(args) {
|
|
14
|
+
super(args, {
|
|
15
|
+
logicalType: 'inner',
|
|
16
|
+
physicalName: 'bind-source',
|
|
17
|
+
canHandleUndefs: true,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async getOutput(action) {
|
|
21
|
+
// Order the entries so we can pick the first one (usually the one with the lowest cardinality)
|
|
22
|
+
const entriesUnsorted = await bus_rdf_join_1.ActorRdfJoin.getEntriesWithMetadatas(action.entries);
|
|
23
|
+
const entries = await this.sortJoinEntries(entriesUnsorted, action.context);
|
|
24
|
+
this.logDebug(action.context, 'First entry for Bind Join Source: ', () => ({ entry: entries[0].operation, metadata: entries[0].metadata }));
|
|
25
|
+
// Close the non-smallest streams
|
|
26
|
+
for (const [i, element] of entries.entries()) {
|
|
27
|
+
if (i !== 0) {
|
|
28
|
+
element.output.bindingsStream.close();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Take the stream with the lowest cardinality
|
|
32
|
+
const smallestStream = entries[0].output;
|
|
33
|
+
const smallestMetadata = entries[0].metadata;
|
|
34
|
+
const remainingEntries = [...entries];
|
|
35
|
+
remainingEntries.splice(0, 1);
|
|
36
|
+
// Get source for remaining entries (guaranteed thanks to prior check in getJoinCoefficients())
|
|
37
|
+
const sourceWrapper = bus_query_operation_1.ActorQueryOperation.getOperationSource(remainingEntries[0].operation);
|
|
38
|
+
// Determine the operation to pass
|
|
39
|
+
const operation = this.createOperationFromEntries(remainingEntries);
|
|
40
|
+
// Slice the smallest stream into chunks according to the block size, so we avoid blocking too long.
|
|
41
|
+
const chunkedStreams = new bus_rdf_join_1.ChunkedIterator(smallestStream.bindingsStream, this.blockSize, { autoStart: false });
|
|
42
|
+
// For each chunk, pass the query and the bindings to the source for execution
|
|
43
|
+
const bindingsStream = new asynciterator_1.UnionIterator(chunkedStreams.transform({
|
|
44
|
+
map: chunk => sourceWrapper.source.queryBindings(operation, sourceWrapper.context ? action.context.merge(sourceWrapper.context) : action.context, { joinBindings: { bindings: chunk, metadata: smallestMetadata } }),
|
|
45
|
+
autoStart: false,
|
|
46
|
+
}));
|
|
47
|
+
return {
|
|
48
|
+
result: {
|
|
49
|
+
type: 'bindings',
|
|
50
|
+
bindingsStream,
|
|
51
|
+
metadata: () => this.constructResultMetadata(entries, entries.map(entry => entry.metadata), action.context),
|
|
52
|
+
},
|
|
53
|
+
physicalPlanMetadata: {
|
|
54
|
+
bindIndex: entriesUnsorted.indexOf(entries[0]),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async sortJoinEntries(entries, context) {
|
|
59
|
+
entries = await bus_rdf_join_1.ActorRdfJoin.sortJoinEntries(this.mediatorJoinEntriesSort, entries, context);
|
|
60
|
+
// Prioritize entries with modified operations, so these are not re-executed
|
|
61
|
+
entries = entries.sort((entryLeft, entryRight) => {
|
|
62
|
+
if (entryLeft.operationModified && !entryRight.operationModified) {
|
|
63
|
+
return -1;
|
|
64
|
+
}
|
|
65
|
+
return 0;
|
|
66
|
+
});
|
|
67
|
+
return entries;
|
|
68
|
+
}
|
|
69
|
+
async getJoinCoefficients(action, metadatas) {
|
|
70
|
+
// Order the entries so we can pick the first one (usually the one with the lowest cardinality)
|
|
71
|
+
const entries = await this.sortJoinEntries(action.entries
|
|
72
|
+
.map((entry, i) => ({ ...entry, metadata: metadatas[i] })), action.context);
|
|
73
|
+
metadatas = entries.map(entry => entry.metadata);
|
|
74
|
+
const requestInitialTimes = bus_rdf_join_1.ActorRdfJoin.getRequestInitialTimes(metadatas);
|
|
75
|
+
const requestItemTimes = bus_rdf_join_1.ActorRdfJoin.getRequestItemTimes(metadatas);
|
|
76
|
+
// Determine first stream and remaining ones
|
|
77
|
+
const remainingEntries = [...entries];
|
|
78
|
+
const remainingRequestInitialTimes = [...requestInitialTimes];
|
|
79
|
+
const remainingRequestItemTimes = [...requestItemTimes];
|
|
80
|
+
remainingEntries.splice(0, 1);
|
|
81
|
+
remainingRequestInitialTimes.splice(0, 1);
|
|
82
|
+
remainingRequestItemTimes.splice(0, 1);
|
|
83
|
+
// Reject binding on operations without sources
|
|
84
|
+
const sources = remainingEntries.map(entry => bus_query_operation_1.ActorQueryOperation.getOperationSource(entry.operation));
|
|
85
|
+
if (sources.some(source => !source)) {
|
|
86
|
+
throw new Error(`Actor ${this.name} can not bind on remaining operations without source annotation`);
|
|
87
|
+
}
|
|
88
|
+
// Reject binding on operations with un-equal sources
|
|
89
|
+
if (sources.some(source => source !== sources[0])) {
|
|
90
|
+
throw new Error(`Actor ${this.name} can not bind on remaining operations with non-equal source annotation`);
|
|
91
|
+
}
|
|
92
|
+
// Reject if the source can not handle bindings
|
|
93
|
+
const sourceWrapper = sources[0];
|
|
94
|
+
const testingOperation = this.createOperationFromEntries(remainingEntries);
|
|
95
|
+
const selectorShape = await sourceWrapper.source.getSelectorShape(action.context);
|
|
96
|
+
if (!bus_query_operation_1.ActorQueryOperation
|
|
97
|
+
.doesShapeAcceptOperation(selectorShape, testingOperation, { joinBindings: true })) {
|
|
98
|
+
throw new Error(`Actor ${this.name} detected a source that can not handle passing down join bindings`);
|
|
99
|
+
}
|
|
100
|
+
// Determine selectivities of smallest entry with all other entries
|
|
101
|
+
const selectivities = await Promise.all(remainingEntries
|
|
102
|
+
.map(async (entry) => (await this.mediatorJoinSelectivity.mediate({
|
|
103
|
+
entries: [entries[0], entry],
|
|
104
|
+
context: action.context,
|
|
105
|
+
})).selectivity * this.selectivityModifier));
|
|
106
|
+
// Determine coefficients for remaining entries
|
|
107
|
+
const cardinalityRemaining = remainingEntries
|
|
108
|
+
.map((entry, i) => entry.metadata.cardinality.value * selectivities[i])
|
|
109
|
+
.reduce((sum, element) => sum + element, 0);
|
|
110
|
+
return {
|
|
111
|
+
iterations: 1,
|
|
112
|
+
persistedItems: metadatas[0].cardinality.value,
|
|
113
|
+
blockingItems: metadatas[0].cardinality.value,
|
|
114
|
+
requestTime: requestInitialTimes[0] + metadatas[0].cardinality.value * requestItemTimes[0] +
|
|
115
|
+
requestInitialTimes[1] + cardinalityRemaining * requestItemTimes[1],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
createOperationFromEntries(remainingEntries) {
|
|
119
|
+
if (remainingEntries.length === 1) {
|
|
120
|
+
return remainingEntries[0].operation;
|
|
121
|
+
}
|
|
122
|
+
return AF.createJoin(remainingEntries.map(entry => entry.operation), true);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.ActorRdfJoinMultiBindSource = ActorRdfJoinMultiBindSource;
|
|
126
|
+
//# sourceMappingURL=ActorRdfJoinMultiBindSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActorRdfJoinMultiBindSource.js","sourceRoot":"","sources":["ActorRdfJoinMultiBindSource.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAIpE,yDAAuE;AAUvE,iDAA8C;AAE9C,qDAA0C;AAE1C,MAAM,EAAE,GAAG,IAAI,yBAAO,EAAE,CAAC;AAEzB;;GAEG;AACH,MAAa,2BAA4B,SAAQ,2BAAY;IAK3D,YAAmB,IAA2C;QAC5D,KAAK,CAAC,IAAI,EAAE;YACV,WAAW,EAAE,OAAO;YACpB,YAAY,EAAE,aAAa;YAC3B,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,MAAsB;QAC3C,+FAA+F;QAC/F,MAAM,eAAe,GAAG,MAAM,2BAAY,CAAC,uBAAuB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5E,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAC1B,oCAAoC,EACpC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAA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CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,GAAG,gBAAgB,CAAC,CAAC,CAAC;gBACxF,mBAAmB,CAAC,CAAC,CAAC,GAAG,oBAAoB,GAAG,gBAAgB,CAAC,CAAC,CAAC;SACtE,CAAC;IACJ,CAAC;IAEM,0BAA0B,CAAC,gBAA0C;QAC1E,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;YACjC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SACtC;QACD,OAAO,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC;CACF;AA1JD,kEA0JC","sourcesContent":["import { ActorQueryOperation } from '@comunica/bus-query-operation';\nimport type { IActionRdfJoin,\n IActorRdfJoinArgs,\n IActorRdfJoinOutputInner } from '@comunica/bus-rdf-join';\nimport { ActorRdfJoin, ChunkedIterator } from '@comunica/bus-rdf-join';\nimport type { MediatorRdfJoinEntriesSort } from '@comunica/bus-rdf-join-entries-sort';\nimport type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients';\nimport type { IJoinEntryWithMetadata,\n IQueryOperationResultBindings,\n IQuerySourceWrapper,\n MetadataBindings,\n IActionContext } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport { UnionIterator } from 'asynciterator';\nimport type { Algebra } from 'sparqlalgebrajs';\nimport { Factory } from 'sparqlalgebrajs';\n\nconst AF = new Factory();\n\n/**\n * A comunica Inner Multi Bind Source RDF Join Actor.\n */\nexport class ActorRdfJoinMultiBindSource extends ActorRdfJoin {\n public readonly selectivityModifier: number;\n public readonly blockSize: number;\n public readonly mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort;\n\n public constructor(args: IActorRdfJoinInnerMultiBindSourceArgs) {\n super(args, {\n logicalType: 'inner',\n physicalName: 'bind-source',\n canHandleUndefs: true,\n });\n }\n\n public async getOutput(action: IActionRdfJoin): Promise<IActorRdfJoinOutputInner> {\n // Order the entries so we can pick the first one (usually the one with the lowest cardinality)\n const entriesUnsorted = await ActorRdfJoin.getEntriesWithMetadatas(action.entries);\n const entries = await this.sortJoinEntries(entriesUnsorted, action.context);\n\n this.logDebug(action.context,\n 'First entry for Bind Join Source: ',\n () => ({ entry: entries[0].operation, metadata: entries[0].metadata }));\n\n // Close the non-smallest streams\n for (const [ i, element ] of entries.entries()) {\n if (i !== 0) {\n element.output.bindingsStream.close();\n }\n }\n\n // Take the stream with the lowest cardinality\n const smallestStream: IQueryOperationResultBindings = entries[0].output;\n const smallestMetadata = entries[0].metadata;\n const remainingEntries = [ ...entries ];\n remainingEntries.splice(0, 1);\n\n // Get source for remaining entries (guaranteed thanks to prior check in getJoinCoefficients())\n const sourceWrapper: IQuerySourceWrapper = ActorQueryOperation.getOperationSource(remainingEntries[0].operation)!;\n\n // Determine the operation to pass\n const operation = this.createOperationFromEntries(remainingEntries);\n\n // Slice the smallest stream into chunks according to the block size, so we avoid blocking too long.\n const chunkedStreams: AsyncIterator<AsyncIterator<RDF.Bindings>> = new ChunkedIterator(\n smallestStream.bindingsStream,\n this.blockSize,\n { autoStart: false },\n );\n\n // For each chunk, pass the query and the bindings to the source for execution\n const bindingsStream = new UnionIterator(chunkedStreams.transform({\n map: chunk => sourceWrapper.source.queryBindings(\n operation,\n sourceWrapper.context ? action.context.merge(sourceWrapper.context) : action.context,\n { joinBindings: { bindings: chunk, metadata: smallestMetadata }},\n ),\n autoStart: false,\n }));\n\n return {\n result: {\n type: 'bindings',\n bindingsStream,\n metadata: () => this.constructResultMetadata(entries, entries.map(entry => entry.metadata), action.context),\n },\n physicalPlanMetadata: {\n bindIndex: entriesUnsorted.indexOf(entries[0]),\n },\n };\n }\n\n protected async sortJoinEntries(\n entries: IJoinEntryWithMetadata[],\n context: IActionContext,\n ): Promise<IJoinEntryWithMetadata[]> {\n entries = await ActorRdfJoin.sortJoinEntries(this.mediatorJoinEntriesSort, entries, context);\n\n // Prioritize entries with modified operations, so these are not re-executed\n entries = entries.sort((entryLeft, entryRight) => {\n if (entryLeft.operationModified && !entryRight.operationModified) {\n return -1;\n }\n return 0;\n });\n\n return entries;\n }\n\n public async getJoinCoefficients(\n action: IActionRdfJoin,\n metadatas: MetadataBindings[],\n ): Promise<IMediatorTypeJoinCoefficients> {\n // Order the entries so we can pick the first one (usually the one with the lowest cardinality)\n const entries = await this.sortJoinEntries(action.entries\n .map((entry, i) => ({ ...entry, metadata: metadatas[i] })), action.context);\n metadatas = entries.map(entry => entry.metadata);\n\n const requestInitialTimes = ActorRdfJoin.getRequestInitialTimes(metadatas);\n const requestItemTimes = ActorRdfJoin.getRequestItemTimes(metadatas);\n\n // Determine first stream and remaining ones\n const remainingEntries = [ ...entries ];\n const remainingRequestInitialTimes = [ ...requestInitialTimes ];\n const remainingRequestItemTimes = [ ...requestItemTimes ];\n remainingEntries.splice(0, 1);\n remainingRequestInitialTimes.splice(0, 1);\n remainingRequestItemTimes.splice(0, 1);\n\n // Reject binding on operations without sources\n const sources = remainingEntries.map(entry => ActorQueryOperation.getOperationSource(entry.operation));\n if (sources.some(source => !source)) {\n throw new Error(`Actor ${this.name} can not bind on remaining operations without source annotation`);\n }\n\n // Reject binding on operations with un-equal sources\n if (sources.some(source => source !== sources[0])) {\n throw new Error(`Actor ${this.name} can not bind on remaining operations with non-equal source annotation`);\n }\n\n // Reject if the source can not handle bindings\n const sourceWrapper: IQuerySourceWrapper = sources[0]!;\n const testingOperation = this.createOperationFromEntries(remainingEntries);\n const selectorShape = await sourceWrapper.source.getSelectorShape(action.context);\n if (!ActorQueryOperation\n .doesShapeAcceptOperation(selectorShape, testingOperation, { joinBindings: true })) {\n throw new Error(`Actor ${this.name} detected a source that can not handle passing down join bindings`);\n }\n\n // Determine selectivities of smallest entry with all other entries\n const selectivities = await Promise.all(remainingEntries\n .map(async entry => (await this.mediatorJoinSelectivity.mediate({\n entries: [ entries[0], entry ],\n context: action.context,\n })).selectivity * this.selectivityModifier));\n\n // Determine coefficients for remaining entries\n const cardinalityRemaining = remainingEntries\n .map((entry, i) => entry.metadata.cardinality.value * selectivities[i])\n .reduce((sum, element) => sum + element, 0);\n\n return {\n iterations: 1,\n persistedItems: metadatas[0].cardinality.value,\n blockingItems: metadatas[0].cardinality.value,\n requestTime: requestInitialTimes[0] + metadatas[0].cardinality.value * requestItemTimes[0] +\n requestInitialTimes[1] + cardinalityRemaining * requestItemTimes[1],\n };\n }\n\n public createOperationFromEntries(remainingEntries: IJoinEntryWithMetadata[]): Algebra.Operation {\n if (remainingEntries.length === 1) {\n return remainingEntries[0].operation;\n }\n return AF.createJoin(remainingEntries.map(entry => entry.operation), true);\n }\n}\n\nexport interface IActorRdfJoinInnerMultiBindSourceArgs extends IActorRdfJoinArgs {\n /**\n * Multiplier for selectivity values\n * @range {double}\n * @default {0.0001}\n */\n selectivityModifier: number;\n /**\n * The maximum amount of bindings to send to the source per block.\n * @default {16}\n */\n blockSize: number;\n /**\n * The join entries sort mediator\n */\n mediatorJoinEntriesSort: MediatorRdfJoinEntriesSort;\n}\n"]}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActorRdfJoinMultiBindSource';
|
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("./ActorRdfJoinMultiBindSource"), 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,gEAA8C","sourcesContent":["export * from './ActorRdfJoinMultiBindSource';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/actor-rdf-join-inner-multi-bind-source",
|
|
3
|
+
"version": "3.0.1-alpha.43.0",
|
|
4
|
+
"description": "A inner-multi-bind-source rdf-join actor",
|
|
5
|
+
"lsd:module": true,
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"typings": "lib/index",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/comunica/comunica.git",
|
|
11
|
+
"directory": "packages/actor-rdf-join-inner-multi-bind-source"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"keywords": [
|
|
18
|
+
"comunica",
|
|
19
|
+
"actor",
|
|
20
|
+
"rdf-join",
|
|
21
|
+
"inner-multi-bind-source"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/comunica/comunica/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://comunica.dev/",
|
|
28
|
+
"files": [
|
|
29
|
+
"components",
|
|
30
|
+
"lib/**/*.d.ts",
|
|
31
|
+
"lib/**/*.js",
|
|
32
|
+
"lib/**/*.js.map"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@comunica/bus-query-operation": "3.0.1-alpha.43.0",
|
|
36
|
+
"@comunica/bus-rdf-join": "3.0.1-alpha.43.0",
|
|
37
|
+
"@comunica/bus-rdf-join-entries-sort": "3.0.1-alpha.43.0",
|
|
38
|
+
"@comunica/mediatortype-join-coefficients": "3.0.1-alpha.43.0",
|
|
39
|
+
"@comunica/types": "3.0.1-alpha.43.0",
|
|
40
|
+
"@rdfjs/types": "*",
|
|
41
|
+
"asynciterator": "^3.8.1",
|
|
42
|
+
"sparqlalgebrajs": "^4.3.3"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "npm run build:ts && npm run build:components",
|
|
46
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
47
|
+
"build:components": "componentsjs-generator"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "d11e44cf07d4699f9d2c51d5851b5ed443de1997"
|
|
50
|
+
}
|